SenseCodonAlphabet#
- class SenseCodonAlphabet(words: tuple[str | bytes, ...], monomers: CharAlphabet, gap: str | None = None)#
represents the sense-codons of a GeneticCode
- Attributes:
- gap_char
- gap_index
missing_char
not supported on CodonAlphabet
missing_index
not supported on CodonAlphabet
- moltype
motif_len
always 3 for codon alphabets
num_canonical
returns the number of canonical states
Methods
count
(value, /)Return number of occurrences of value.
from_index
(index)returns a single codon from an index
from_indices
(indices)returns a list of codons from a numpy array of indices
from_rich_dict
(data)returns an instance from a serialised dictionary
index
(value[, start, stop])Return first index of value.
is_valid
(-> bool)seq is valid for alphabet
to_index
(codon)encodes a codon as a single integer
to_indices
(...)returns a sequence of codon indices
to_json
()returns a serialisable string
to_rich_dict
([for_pickle])returns a serialisable dictionary
with_gap_motif
(**kwargs)returns a new SenseCodonAlphabet with the gap motif '---' added
- count(value, /)#
Return number of occurrences of value.
- from_index(index: int) str #
returns a single codon from an index
- from_indices(indices: ndarray[tuple[int, ...], dtype[integer]]) list[str] #
returns a list of codons from a numpy array of indices
- classmethod from_rich_dict(data: dict[str, Any]) SenseCodonAlphabet #
returns an instance from a serialised dictionary
- property gap_char: str#
- property gap_index: int | None#
- index(value, start=0, stop=sys.maxsize, /)#
Return first index of value.
Raises ValueError if the value is not present.
- is_valid(seq) bool #
- is_valid(seq: str) bool
- is_valid(seq: ndarray) bool
seq is valid for alphabet
- property missing_char: None#
not supported on CodonAlphabet
- property missing_index: None#
not supported on CodonAlphabet
- property motif_len: int#
always 3 for codon alphabets
- property num_canonical: int#
returns the number of canonical states
- to_index(codon: str) int #
encodes a codon as a single integer
- to_indices(seq) ndarray #
- to_indices(seq: str) ndarray
- to_indices(seq: list) ndarray
- to_indices(seq: tuple) ndarray[int]
- to_indices(seq: ndarray) ndarray
returns a sequence of codon indices
- to_json() str #
returns a serialisable string
- to_rich_dict(for_pickle: bool = False) dict #
returns a serialisable dictionary
- with_gap_motif(**kwargs) Self #
returns a new SenseCodonAlphabet with the gap motif ‘—’ added
Notes
kwargs is for compatibility with the ABC method