pub struct GeneticCode { /* private fields */ }Expand description
A genetic code translation table.
Wraps a 64-element amino acid lookup array and a 64-element start codon mask.
Use GeneticCode::from_id or GeneticCode::standard to create.
Implementations§
Source§impl GeneticCode
impl GeneticCode
Sourcepub fn from_id(id: GeneticCodeId) -> Self
pub fn from_id(id: GeneticCodeId) -> Self
Create a genetic code table from an NCBI table identifier.
Sourcepub fn id(&self) -> GeneticCodeId
pub fn id(&self) -> GeneticCodeId
Table identifier.
Sourcepub fn translate_codon(&self, codon: &[u8]) -> Option<u8>
pub fn translate_codon(&self, codon: &[u8]) -> Option<u8>
Translate a single codon (3-byte slice) to an amino acid.
Returns None for stop codons (encoded as b'*' internally) and
for unrecognizable/ambiguous codons.
Sourcepub fn translate_sequence(&self, seq: &[u8]) -> Vec<u8> ⓘ
pub fn translate_sequence(&self, seq: &[u8]) -> Vec<u8> ⓘ
Translate a nucleotide sequence, stopping at the first stop codon.
Incomplete trailing codons are ignored.
Sourcepub fn translate_sequence_full(&self, seq: &[u8]) -> Vec<u8> ⓘ
pub fn translate_sequence_full(&self, seq: &[u8]) -> Vec<u8> ⓘ
Translate a nucleotide sequence, including stop codons as '*'.
Does not stop at stop codons — translates the entire sequence. Incomplete trailing codons are ignored.
Sourcepub fn is_start(&self, codon: &[u8]) -> bool
pub fn is_start(&self, codon: &[u8]) -> bool
Check whether a codon is a start codon in this table.
Sourcepub fn is_stop(&self, codon: &[u8]) -> bool
pub fn is_stop(&self, codon: &[u8]) -> bool
Check whether a codon is a stop codon in this table.
Sourcepub fn stop_codons(&self) -> Vec<[u8; 3]>
pub fn stop_codons(&self) -> Vec<[u8; 3]>
Return all stop codons for this table (as DNA).
Sourcepub fn start_codons(&self) -> Vec<[u8; 3]>
pub fn start_codons(&self) -> Vec<[u8; 3]>
Return all start codons for this table (as DNA).
Trait Implementations§
Source§impl Clone for GeneticCode
impl Clone for GeneticCode
Source§fn clone(&self) -> GeneticCode
fn clone(&self) -> GeneticCode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more