/// Iterates over sequence deletions, compares sequence and node deletion and finds the private ones.
///
/// This is a generic declaration, but the implementation for nucleotide and aminoacid deletions is different and the
/// two specializations are provided below. This is due to deletions having different data structure for nucleotides
/// and for amino acids (range vs point).
Iterates over sequence deletions, compares sequence and node deletion and finds the private ones.
This is a generic declaration, but the implementation for nucleotide and aminoacid deletions is different and the
two specializations are provided below. This is due to deletions having different data structure for nucleotides
and for amino acids (range vs point).
Iterates over sequence deletions compares sequence and node deletion and finds the private ones . This is a generic declaration but the implementation for nucleotide and aminoacid deletions is different and the two specializations are provided below . This is due to deletions having different data structure for nucleotides and for amino acids ( range vs point ) .
fn process_seq_deletions(
  node_mut_map: &BTreeMap<usize, Aa>,
  deletions: &[&AaDel],
  ref_seq: &[Aa],
  seq_positions_mutated_or_deleted: &mut BTreeSet<usize>,
) -> Vec<AaDelMinimal> {
  let mut non_reversion_deletions = Vec::<AaDelMinimal>::new();
  for del in deletions {
    let pos = del.pos;
    seq_positions_mutated_or_deleted.insert(pos);
    match node_mut_map.get(&pos) {
      None => {
        // Case 3: Mutation in sequence but not in node, i.e. a newly occurred mutation.
        // Action: Add the sequence mutation itself.
        non_reversion_deletions.push(AaDelMinimal { reff: del.reff, pos });
      }
      Some(node_qry) => {
        if !node_qry.is_gap() {
          // Case 2: Mutation in sequence and in node, but the query character is not the same.
          // Action: Add mutation from node query character to sequence query character.
          non_reversion_deletions.push(AaDelMinimal { reff: *node_qry, pos });
        }
      }
    }
    // Otherwise case 1: mutation in sequence and in node, same query character, i.e. the mutation is not private:
    // nothing to do.
  }
  non_reversion_deletions.sort();
  non_reversion_deletions.dedup();
  non_reversion_deletions
}
fn process_seq_deletions ( node_mut_map : & BTreeMap < usize , Aa > , deletions : & [ & AaDel ] , ref_seq : & [ Aa ] , seq_positions_mutated_or_deleted : & mut BTreeSet < usize > , ) -> Vec < AaDelMinimal > { let mut non_reversion_deletions = Vec :: < AaDelMinimal > :: new ( ) ; for del in deletions { let pos = del . pos ; seq_positions_mutated_or_deleted . insert ( pos ) ; match node_mut_map . get ( & pos ) { None => { // Case 3: Mutation in sequence but not in node, i.e. a newly occurred mutation. // Action: Add the sequence mutation itself. non_reversion_deletions . push ( AaDelMinimal { reff : del . reff , pos } ) ; } Some ( node_qry ) => { if ! node_qry . is_gap ( ) { // Case 2: Mutation in sequence and in node, but the query character is not the same. // Action: Add mutation from node query character to sequence query character. non_reversion_deletions . push ( AaDelMinimal { reff : * node_qry , pos } ) ; } } } // Otherwise case 1: mutation in sequence and in node, same query character, i.e. the mutation is not private: // nothing to do. } non_reversion_deletions . sort ( ) ; non_reversion_deletions . dedup ( ) ; non_reversion_deletions }
Iterates over sequence deletions, compares sequence and node deletion and finds the private ones.
Iterates over sequence deletions compares sequence and node deletion and finds the private ones .
node_mut_map
&BTreeMap<usize, Aa>
deletions
&[&AaDel]
ref_seq
&[Aa]
seq_positions_mutated_or_deleted
&mut BTreeSet<usize>