core.genetic_code.GeneticCode
core.genetic_code.GeneticCode(
ID,
name,
ncbi_code_sequence,
ncbi_start_codon_map,
moltype=c3_moltype.DNA,
)Holds codon to amino acid mapping, and vice versa.
Notes
We add additional states to the genetic code to represent gapped codons and missing data.
Methods
| Name | Description |
|---|---|
| get_alphabet | returns a codon alphabet |
| is_start | Returns True if codon is a start codon, False otherwise. |
| is_stop | Returns True if codon is a stop codon, False otherwise. |
| sixframes | Returns the six reading frames of the genetic code. |
| to_regex | returns a regex pattern with an amino acid expanded to its codon set |
| to_table | returns aa to codon mapping as a cogent3 Table |
| translate | Translates DNA to protein. |
get_alphabet
core.genetic_code.GeneticCode.get_alphabet(
include_gap=False,
include_missing=False,
include_stop=False,
)returns a codon alphabet
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| include_gap | bool | alphabet includes the gap motif | False |
| include_missing | bool | alphabet includes the missing state as 3 * IUPAC_missing | False |
| include_stop | bool | if True, this is just a kmer alphabet | False |
Notes
If include_stop, the returned alphabet includes all codons, and is thus a KmerAlphabet. Otherwise its a SenseCodonAlphabet.
is_start
core.genetic_code.GeneticCode.is_start(codon)Returns True if codon is a start codon, False otherwise.
is_stop
core.genetic_code.GeneticCode.is_stop(codon)Returns True if codon is a stop codon, False otherwise.
sixframes
core.genetic_code.GeneticCode.sixframes(seq)Returns the six reading frames of the genetic code.
Returns
| Name | Type | Description |
|---|---|---|
| A dictionary with keys (strand, start) where strand is "+"/"-" |
to_regex
core.genetic_code.GeneticCode.to_regex(seq)returns a regex pattern with an amino acid expanded to its codon set
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| seq | str | PySeq[str] | Sequence | a Sequence or string of amino acids | required |
to_table
core.genetic_code.GeneticCode.to_table()returns aa to codon mapping as a cogent3 Table
translate
core.genetic_code.GeneticCode.translate(
dna,
start=0,
rc=False,
incomplete_ok=True,
)Translates DNA to protein.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| dna | str | npt.NDArray[numpy.integer] | a string of nucleotides | required |
| start | int | position to begin translation (used to implement frames) | 0 |
| rc | bool | if True, returns the translation of the reverse complement sequence | False |
| incomplete_ok | bool | if True, translates codons that are a mix of gaps and bases as a gap. If False, raises an AlphabetError on those incomplete cases. | True |
Notes
Sequences are truncated to be a multiple of 3. Codons containing ambiguous nucleotides are translated as ‘X’, codons containing a gap character are translated as ‘-’ unless incomplete_ok is False. Codons with a mix of ambiguous nucleotides are translated as ‘X’.
Returns
| Name | Type | Description |
|---|---|---|
| The amino acid sequence as a string. |