pub fn protect_first_codon_in_place(seq: &mut [Nuc]) {
  // TODO: this is a very C-like function. Try to replace the indexed loop with something more idiomatic
  let length = seq.len();
  let end = length - (length % 3);
  for i in 0..end {
    if !seq[i].is_gap() {
      let triplet_begin = i - (i % 3);
      let triplet = &mut seq[triplet_begin..triplet_begin + 3];
      protect_codon_in_place(triplet);
      break;
    }
  }
}
/// Finds the first non-GAP nucleotide and replaces GAPs in the corresponding triplet with Ns,
/// so that it's not getting stripped during subsequent gap stripping. This is to ensure the first codon is complete
/// and no shift is introduced during subsequent gap-stripping
Finds the first non-GAP nucleotide and replaces GAPs in the corresponding triplet with Ns,
so that it's not getting stripped during subsequent gap stripping. This is to ensure the first codon is complete
and no shift is introduced during subsequent gap-stripping
Finds the first non - GAP nucleotide and replaces GAPs in the corresponding triplet with Ns so that it ' s not getting stripped during subsequent gap stripping . This is to ensure the first codon is complete and no shift is introduced during subsequent gap - stripping
pub fn protect_first_codon_in_place(seq: &mut [Nuc]) {
  // TODO: this is a very C-like function. Try to replace the indexed loop with something more idiomatic
  let length = seq.len();
  let end = length - (length % 3);
  for i in 0..end {
    if !seq[i].is_gap() {
      let triplet_begin = i - (i % 3);
      let triplet = &mut seq[triplet_begin..triplet_begin + 3];
      protect_codon_in_place(triplet);
      break;
    }
  }
}
pub fn protect_first_codon_in_place ( seq : & mut [ Nuc ] ) { // TODO: this is a very C-like function. Try to replace the indexed loop with something more idiomatic let length = seq . len ( ) ; let end = length - ( length % 3 ) ; for i in 0 .. end { if ! seq [ i ] . is_gap ( ) { let triplet_begin = i - ( i % 3 ) ; let triplet = & mut seq [ triplet_begin .. triplet_begin + 3 ] ; protect_codon_in_place ( triplet ) ; break ; } } }
Finds the first non-GAP nucleotide and replaces GAPs in the corresponding triplet with Ns,
so that it's not getting stripped during subsequent gap stripping.
Finds the first non - GAP nucleotide and replaces GAPs in the corresponding triplet with Ns so that it ' s not getting stripped during subsequent gap stripping .
seq
&mut [Nuc]
seq
&mut [Nuc]