torchcell.sequence.compute_codon_frequency

compute_codon_frequency(cds_str: str) → CodonFrequency[source]

Compute relative codon frequencies for a coding sequence.

Parameters:

cds_str – Coding sequence whose length must be a positive multiple of three.

Returns:

A CodonFrequency mapping every codon to its relative frequency.

Raises:

ValueError – If the CDS is empty, its length is not a multiple of three, or it carries a base other than A, T, G, C.