/// Iterates over sequence substitutions, compares sequence and node substitutions and finds the private ones.
Iterates over sequence substitutions, compares sequence and node substitutions and finds the private ones.
Iterates over sequence substitutions compares sequence and node substitutions and finds the private ones .
fn process_seq_substitutions(
  node_mut_map: &BTreeMap<usize, Aa>,
  substitutions: &[&AaSub],
  seq_positions_mutated_or_deleted: &mut BTreeSet<usize>,
) -> Vec<AaSubMinimal> {
  let mut non_reversion_substitutions = Vec::<AaSubMinimal>::new();
  for seq_mut in substitutions {
    let pos = seq_mut.pos;
    seq_positions_mutated_or_deleted.insert(pos);
    if seq_mut.qry.is_unknown() {
      // Cases 5/6: Unknown in sequence
      // Action: Skip nucleotide N and aminoacid X in sequence.
      //         We don't know whether they match the node character or not,
      //         so we decide to not take them into account.
      continue;
    }
    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_substitutions.push(AaSubMinimal {
          reff: seq_mut.reff,
          pos,
          qry: seq_mut.qry,
        });
      }
      Some(node_qry) => {
        if &seq_mut.qry != node_qry {
          // 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_substitutions.push(AaSubMinimal {
            reff: *node_qry,
            pos,
            qry: seq_mut.qry,
          });
        }
      }
    }
    // Otherwise case 1: mutation in sequence and in node, same query character, i.e. the mutation is not private:
    // nothing to do.
  }
  non_reversion_substitutions.sort();
  non_reversion_substitutions.dedup();
  non_reversion_substitutions
}
fn process_seq_substitutions ( node_mut_map : & BTreeMap < usize , Aa > , substitutions : & [ & AaSub ] , seq_positions_mutated_or_deleted : & mut BTreeSet < usize > , ) -> Vec < AaSubMinimal > { let mut non_reversion_substitutions = Vec :: < AaSubMinimal > :: new ( ) ; for seq_mut in substitutions { let pos = seq_mut . pos ; seq_positions_mutated_or_deleted . insert ( pos ) ; if seq_mut . qry . is_unknown ( ) { // Cases 5/6: Unknown in sequence // Action: Skip nucleotide N and aminoacid X in sequence. //         We don't know whether they match the node character or not, //         so we decide to not take them into account. continue ; } 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_substitutions . push ( AaSubMinimal { reff : seq_mut . reff , pos , qry : seq_mut . qry , } ) ; } Some ( node_qry ) => { if & seq_mut . qry != node_qry { // 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_substitutions . push ( AaSubMinimal { reff : * node_qry , pos , qry : seq_mut . qry , } ) ; } } } // Otherwise case 1: mutation in sequence and in node, same query character, i.e. the mutation is not private: // nothing to do. } non_reversion_substitutions . sort ( ) ; non_reversion_substitutions . dedup ( ) ; non_reversion_substitutions }
Iterates over sequence substitutions, compares sequence and node substitutions and finds the private ones.
Iterates over sequence substitutions compares sequence and node substitutions and finds the private ones .
node_mut_map
&BTreeMap<usize, Aa>
substitutions
&[&AaSub]
seq_positions_mutated_or_deleted
&mut BTreeSet<usize>