/// Translates a nucleotide sequence of a gene into the corresponding aminoacid sequence (peptide)
/// NOTE: we accept gene sequence by value here to avoid copying (it should be moved) and then process it in-place
Translates a nucleotide sequence of a gene into the corresponding aminoacid sequence (peptide)
NOTE: we accept gene sequence by value here to avoid copying (it should be moved) and then process it in-place
Translates a nucleotide sequence of a gene into the corresponding aminoacid sequence ( peptide ) NOTE : we accept gene sequence by value here to avoid copying ( it should be moved ) and then process it in - place
pub fn translate(gene_nuc_seq: &[Nuc], gene: &Gene, params: &AlignPairwiseParams) -> Result<Translation, Report> {
  // NOTE: rounds the result to the multiple of 3 (floor) so that translation does not overrun the buffer
  let peptide_length = gene_nuc_seq.len() / 3;
  let mut peptide = Vec::<Aa>::with_capacity(peptide_length);
  for i_aa in 0..peptide_length {
    let i_nuc = i_aa * 3;
    let triplet: &[Nuc] = &gene_nuc_seq[i_nuc..(i_nuc + 3)];
    let aminoacid = decode(triplet);
    peptide.push(aminoacid);
    if params.no_translate_past_stop && aminoacid == Aa::Stop {
      break;
    }
  }
  peptide.shrink_to_fit();
  Ok(Translation {
    gene_name: gene.gene_name.clone(),
    seq: peptide,
    insertions: vec![],
    frame_shifts: vec![],
  })
}
pub fn translate ( gene_nuc_seq : & [ Nuc ] , gene : & Gene , params : & AlignPairwiseParams ) -> Result < Translation , Report > { // NOTE: rounds the result to the multiple of 3 (floor) so that translation does not overrun the buffer let peptide_length = gene_nuc_seq . len ( ) / 3 ; let mut peptide = Vec :: < Aa > :: with_capacity ( peptide_length ) ; for i_aa in 0 .. peptide_length { let i_nuc = i_aa * 3 ; let triplet : & [ Nuc ] = & gene_nuc_seq [ i_nuc .. ( i_nuc + 3 ) ] ; let aminoacid = decode ( triplet ) ; peptide . push ( aminoacid ) ; if params . no_translate_past_stop && aminoacid == Aa :: Stop { break ; } } peptide . shrink_to_fit ( ) ; Ok ( Translation { gene_name : gene . gene_name . clone ( ) , seq : peptide , insertions : vec ! [ ] , frame_shifts : vec ! [ ] , } ) }
Translates a nucleotide sequence of a gene into the corresponding aminoacid sequence (peptide)
NOTE: we accept gene sequence by value here to avoid copying (it should be moved) and then process it in-place
Translates a nucleotide sequence of a gene into the corresponding aminoacid sequence ( peptide ) NOTE : we accept gene sequence by value here to avoid copying ( it should be moved ) and then process it in - place
gene_nuc_seq
&[Nuc]
gene
&Gene
params
&AlignPairwiseParams