core.alphabet.SenseCodonAlphabet
core.alphabet.SenseCodonAlphabet(words, monomers, gap=None)represents the sense-codons of a GeneticCode
Attributes
| Name | Description |
|---|---|
| missing_char | not supported on CodonAlphabet |
| missing_index | not supported on CodonAlphabet |
| motif_len | always 3 for codon alphabets |
| num_canonical | returns the number of canonical states |
Methods
| Name | Description |
|---|---|
| from_index | returns a single codon from an index |
| from_indices | returns a list of codons from a numpy array of indices |
| from_rich_dict | returns an instance from a serialised dictionary |
| is_valid | seq is valid for alphabet |
| to_index | encodes a codon as a single integer |
| to_indices | returns a sequence of codon indices |
| to_json | returns a serialisable string |
| to_rich_dict | returns a serialisable dictionary |
| with_gap_motif | returns a new SenseCodonAlphabet with the gap motif ‘—’ added |
from_index
core.alphabet.SenseCodonAlphabet.from_index(index)returns a single codon from an index
from_indices
core.alphabet.SenseCodonAlphabet.from_indices(indices)returns a list of codons from a numpy array of indices
from_rich_dict
core.alphabet.SenseCodonAlphabet.from_rich_dict(data)returns an instance from a serialised dictionary
is_valid
core.alphabet.SenseCodonAlphabet.is_valid(seq)seq is valid for alphabet
to_index
core.alphabet.SenseCodonAlphabet.to_index(codon, validate=True)encodes a codon as a single integer
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| codon | str | string to be converted into index | required |
| validate | bool | raises an AlphabetError if the resulting sequence does not satisfy self.is_valid() | True |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | if codon is not of length 3 | |
| AlphabetError | if codon contains an invalid nucleotide or is not present in the code |
to_indices
core.alphabet.SenseCodonAlphabet.to_indices(seq, validate=True)returns a sequence of codon indices
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| seq | str | list[str] | tuple[str, …] | NumpyIntArrayType | input sequence to be converted to a numpy array of uint | required |
| validate | bool | raises an AlphabetError if the resulting sequence does not satisfy self.is_valid() | True |
Raises
| Name | Type | Description |
|---|---|---|
| TypeError | if seq is unsupported type | |
| AlphabetError | if resulting sequence is not valid |
to_json
core.alphabet.SenseCodonAlphabet.to_json()returns a serialisable string
to_rich_dict
core.alphabet.SenseCodonAlphabet.to_rich_dict(for_pickle=False)returns a serialisable dictionary
with_gap_motif
core.alphabet.SenseCodonAlphabet.with_gap_motif(**kwargs)returns a new SenseCodonAlphabet with the gap motif ‘—’ added
Notes
kwargs is for compatibility with the ABC method