-
Notifications
You must be signed in to change notification settings - Fork 0
Serialize KmerCountTable
Adam Taranto edited this page Sep 24, 2024
·
1 revision
Serialize KmerCountTable
objects to JSON format, save and load serialized objects.
from oxli import KmerCountTable
kct = KmerCountTable(ksize=4)
kct.count("AAAA") # Count 'AAAA'
kct.count("AATT") # Count 'AATT'
kct.count("GGGG") # Count 'GGGG'
kct.count("GGGG") # Count again.
Serialize the object to a JSON string:
kct.serialize_json()
>>> '{"counts":{"17832910516274425539":1,"382727017318141683":1,"73459868045630124":2},"ksize":4,"version":"0.3.0","consumed":16}'
Serialize and save as GZipped JSON:
kct.save(filepath='kct.json.gz')
Load a saved KmerCountTable
object:
# Load returns a new KmerCountTable object
new_kct = KmerCountTable.load('kct.json.gz')
# Inspect the loaded object
new_kct.serialize_json()
>>> '{"counts":{"73459868045630124":2,"17832910516274425539":1,"382727017318141683":1},"ksize":4,"version":"0.3.0","consumed":16}'
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