-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
Adam Taranto edited this page Sep 23, 2024
·
5 revisions
This page provides a quick guide to getting started with the Oxli Python API.
Initialise a new KmerCountTable
# Import oxli
from oxli import KmerCountTable
# Create new count table
kct = KmerCountTable(ksize=4) # Count 4-mers
Adding k-mer counts.
# Add single k-mer with count()
kct.count("AAAA")
>>> 1
# Increment count
kct.count("AAAA")
>>> 2
# Forward and Reverse complement counted together
kct.count("TTTT")
>>> 3
# Add many k-mers from a longer sequence with consume
kct.consume("GGGGGGGGGG") # 7 x 4-mers of 'GGGG'
Lookup counts by k-mer.
# Retrieve kmer counts
kct.get('GGGG') # Count for GGGG/CCCC
>>> 7
kct.get('AAAA') #Count for AAAA/TTTT
>>> 3
Extracting k-mers from files.
# Screed for FASTA/FASTQ parsing
import screed
# Create new table
counts = KmerCountTable(ksize=21)
# Read fasta records and extract k-mers
for record in screed.open('doc/example.fa'):
counts.consume(record.sequence)
>>> 349910
Installing Oxli
Basic Setup
For Developers
Getting Started
Getting Started
Counting Kmers
Basic Counting
Extracting from Files
Handling Bad Kmers
Looking up Counts
Single Kmer Lookup
Multiple Kmer Lookup
Removing Records Remove Kmers Abundance Filtering
Exploring Count Tables
Iterating Records
Attributes
Set Operations
Basic SetOps
Exporting Data
Histo: Export Frequency Counts
Dump: Write Hash:Count Pairs
Save and Load KmerCountTables