-
Notifications
You must be signed in to change notification settings - Fork 0
Extracting from files
This section describes how to extract k-mers from files.
Import necessary modules:
import screed # FASTA/FASTQ parsing
import oxli # This package!
Create a KmerCountTable
with a k-mer size of 31:
# New KmerCountTable object that will count 31-mers
kct = oxli.KmerCountTable(ksize=31)
Open a FASTA file and consume k-mers from all the sequences within.
consume
will report the total number of k-mers consumed.
for record in screed.open('example.fa'):
kct.consume(record.sequence)
# 349900 # Report total k-mers consumed
Use .get()
to look up the count of CGGAGGAAGCAAGAACAAAATATTTTTTCAT
in the count table:
kct.get('CGGAGGAAGCAAGAACAAAATATTTTTTCAT')
#1 # get() returns k-mer count
Kmers and their reverse complement sequences are counted as one and will always have the save value.
kct.get('ATGAAAAAATATTTTGTTCTTGCTTCCTCCG') #revcomp of 'CGGAGGAAGCAAGAACAAAATATTTTTTCAT'
#1
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