The cortexpy API reference

Random access of cortexpy graphs

This module contains classes for inspecting cortex graphs with random access to their kmers.

class cortexpy.graph.parser.random_access.RandomAccess(graph_handle, kmer_cache_size=None)[source]

Provide fast k-mer access to Cortex graph in log(n) time (n = number of kmers in graph)

__getitem__(lexlo_string)[source]

Return kmer associated with kmer string

No check is performed to make sure that the input string is a lexicographically-lowest kmer string. Use get_kmer_for_string() in order to convert a kmer string to its lexlo form before retrieving it from the cortex object.

__iter__()[source]

Iterate over kmer strings in graph in order stored in graph

get_kmer_for_string(string)[source]

Will compute the revcomp of kmer string before getting a kmer

items()[source]

Iterate over kmer strings and kmers in graph in order stored in graph

values()[source]

Iterate over kmers in cortex graph

Utility functions

This module contains utility functions that are used inside cortexpy. These functions may also be useful outside of cortexpy.

cortexpy.utils.kmerize_contig(contig, kmer_size)[source]

Return generator of kmers in contig

The returned kmers are not lexicographically lowest.

>>> list(kmerize_contig('ATTT', 3))
['ATT', 'TTT']
cortexpy.utils.kmerize_fasta(fasta, kmer_size)[source]

Return generator to all kmers in fasta

cortexpy.utils.lexlo[source]

Return lexicographically lowest version of a kmer string and its reverse complement

The reverse complement of a kmer string is generated and the lexicographically-lowest kmer string is returned.

>>> lexlo('AAA')
'AAA'
>>> lexlo('TTT')
'AAA'