fn find_reversions(
  node_mut_map: &BTreeMap<usize, Aa>,
  aa_unknowns: &[&GeneAaRange],
  ref_peptide: &[Aa],
  seq_positions_mutated_or_deleted: &mut BTreeSet<usize>,
) -> Vec<AaSubMinimal> {
  let mut reversion_substitutions = Vec::<AaSubMinimal>::new();

  for (pos, node_qry) in node_mut_map {
    let pos = *pos;
    let seq_has_no_mut_or_del_here = !seq_positions_mutated_or_deleted.contains(&pos);
    let pos_is_sequenced = is_aa_sequenced(pos, aa_unknowns);
    let is_not_node_deletion = !node_qry.is_gap();
    if seq_has_no_mut_or_del_here && pos_is_sequenced && is_not_node_deletion {
      // Case 4: Mutation in node, but not in sequence. This is a so-called reversion. Mutation in sequence reverts
      // the character to ref seq.
      // Action: Add mutation from node query character to character in reference sequence.
      reversion_substitutions.push(AaSubMinimal {
        reff: *node_qry,
        pos,
        qry: ref_peptide[pos],
      });
    }
  }

  reversion_substitutions.sort();
  reversion_substitutions.dedup();

  reversion_substitutions
}
/// Iterates over node mutations, compares node and sequence mutations and finds reversion mutations.
Iterates over node mutations, compares node and sequence mutations and finds reversion mutations.
Iterates over node mutations compares node and sequence mutations and finds reversion mutations .
fn find_reversions(
  node_mut_map: &BTreeMap<usize, Aa>,
  aa_unknowns: &[&GeneAaRange],
  ref_peptide: &[Aa],
  seq_positions_mutated_or_deleted: &mut BTreeSet<usize>,
) -> Vec<AaSubMinimal> {
  let mut reversion_substitutions = Vec::<AaSubMinimal>::new();
  for (pos, node_qry) in node_mut_map {
    let pos = *pos;
    let seq_has_no_mut_or_del_here = !seq_positions_mutated_or_deleted.contains(&pos);
    let pos_is_sequenced = is_aa_sequenced(pos, aa_unknowns);
    let is_not_node_deletion = !node_qry.is_gap();
    if seq_has_no_mut_or_del_here && pos_is_sequenced && is_not_node_deletion {
      // Case 4: Mutation in node, but not in sequence. This is a so-called reversion. Mutation in sequence reverts
      // the character to ref seq.
      // Action: Add mutation from node query character to character in reference sequence.
      reversion_substitutions.push(AaSubMinimal {
        reff: *node_qry,
        pos,
        qry: ref_peptide[pos],
      });
    }
  }
  reversion_substitutions.sort();
  reversion_substitutions.dedup();
  reversion_substitutions
}
fn find_reversions ( node_mut_map : & BTreeMap < usize , Aa > , aa_unknowns : & [ & GeneAaRange ] , ref_peptide : & [ Aa ] , seq_positions_mutated_or_deleted : & mut BTreeSet < usize > , ) -> Vec < AaSubMinimal > { let mut reversion_substitutions = Vec :: < AaSubMinimal > :: new ( ) ; for ( pos , node_qry ) in node_mut_map { let pos = * pos ; let seq_has_no_mut_or_del_here = ! seq_positions_mutated_or_deleted . contains ( & pos ) ; let pos_is_sequenced = is_aa_sequenced ( pos , aa_unknowns ) ; let is_not_node_deletion = ! node_qry . is_gap ( ) ; if seq_has_no_mut_or_del_here && pos_is_sequenced && is_not_node_deletion { // Case 4: Mutation in node, but not in sequence. This is a so-called reversion. Mutation in sequence reverts // the character to ref seq. // Action: Add mutation from node query character to character in reference sequence. reversion_substitutions . push ( AaSubMinimal { reff : * node_qry , pos , qry : ref_peptide [ pos ] , } ) ; } } reversion_substitutions . sort ( ) ; reversion_substitutions . dedup ( ) ; reversion_substitutions }
Iterates over node mutations, compares node and sequence mutations and finds reversion mutations.
Iterates over node mutations compares node and sequence mutations and finds reversion mutations .
node_mut_map
&BTreeMap<usize, Aa>
aa_unknowns
&[&GeneAaRange]
ref_peptide
&[Aa]
seq_positions_mutated_or_deleted
&mut BTreeSet<usize>
node_mut_map
&BTreeMap<usize, Aa>
aa_unknowns
&[&GeneAaRange]
ref_peptide
&[Aa]
seq_positions_mutated_or_deleted
&mut BTreeSet<usize>