/// 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, Nuc>,
  deletions: &[NucDel],
  ref_seq: &[Nuc],
  seq_positions_mutated_or_deleted: &mut BTreeSet<usize>,
) -> Vec<NucDelMinimal> {
  let mut non_reversion_deletions = Vec::<NucDelMinimal>::new();
  for del in deletions {
    let start = del.start;
    let end = del.end();
    #[allow(clippy::needless_range_loop)]
    for pos in start..end {
      seq_positions_mutated_or_deleted.insert(pos);
      match node_mut_map.get(&pos) {
        None => {
          // Case 3: Deletion in sequence but not in node, i.e. this is a newly occurred deletion.
          // Action: Add the sequence deletion itself (take refNuc from reference sequence).
          non_reversion_deletions.push(NucDelMinimal {
            reff: ref_seq[pos],
            pos,
          });
        }
        Some(node_qry) => {
          if !node_qry.is_gap() {
            {
              // Case 2: Mutation in node but deletion in sequence (mutation to '-'), i.e. the query character is not the
              // same. Action: Add deletion of node query character.
              non_reversion_deletions.push(NucDelMinimal { 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 , Nuc > , deletions : & [ NucDel ] , ref_seq : & [ Nuc ] , seq_positions_mutated_or_deleted : & mut BTreeSet < usize > , ) -> Vec < NucDelMinimal > { let mut non_reversion_deletions = Vec :: < NucDelMinimal > :: new ( ) ; for del in deletions { let start = del . start ; let end = del . end ( ) ; # [ allow ( clippy needless_range_loop ) ] for pos in start .. end { seq_positions_mutated_or_deleted . insert ( pos ) ; match node_mut_map . get ( & pos ) { None => { // Case 3: Deletion in sequence but not in node, i.e. this is a newly occurred deletion. // Action: Add the sequence deletion itself (take refNuc from reference sequence). non_reversion_deletions . push ( NucDelMinimal { reff : ref_seq [ pos ] , pos , } ) ; } Some ( node_qry ) => { if ! node_qry . is_gap ( ) { { // Case 2: Mutation in node but deletion in sequence (mutation to '-'), i.e. the query character is not the // same. Action: Add deletion of node query character. non_reversion_deletions . push ( NucDelMinimal { 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, Nuc>
deletions
&[NucDel]
ref_seq
&[Nuc]
seq_positions_mutated_or_deleted
&mut BTreeSet<usize>