/// Calculates distance metric between a given query sample and a tree node
Calculates distance metric between a given query sample and a tree node
Calculates distance metric between a given query sample and a tree node
pub fn tree_calculate_node_distance(
  node: &AuspiceTreeNode,
  qry_nuc_subs: &[NucSub],
  qry_missing: &[NucRange],
  aln_range: &Range,
) -> i64 {
  let mut shared_differences = 0_i64;
  let mut shared_sites = 0_i64;
  for qmut in qry_nuc_subs {
    let der = node.tmp.substitutions.get(&qmut.pos);
    if let Some(der) = der {
      // position is also mutated in node
      if qmut.qry == *der {
        shared_differences += 1; // the exact mutation is shared between node and seq
      } else {
        shared_sites += 1; // the same position is mutated, but the states are different
      }
    }
  }
  // determine the number of sites that are mutated in the node but missing in seq.
  // for these we can't tell whether the node agrees with seq
  let mut undetermined_sites = 0_i64;
  for pos in node.tmp.substitutions.keys() {
    if !is_nuc_sequenced(*pos, qry_missing, aln_range) {
      undetermined_sites += 1;
    }
  }
  let total_node_muts = node.tmp.substitutions.len() as i64;
  let total_seq_muts = qry_nuc_subs.len() as i64;
  // calculate distance from set overlaps.
  total_node_muts + total_seq_muts - 2 * shared_differences - shared_sites - undetermined_sites
}
pub fn tree_calculate_node_distance ( node : & AuspiceTreeNode , qry_nuc_subs : & [ NucSub ] , qry_missing : & [ NucRange ] , aln_range : & Range , ) -> i64 { let mut shared_differences = 0_i64 ; let mut shared_sites = 0_i64 ; for qmut in qry_nuc_subs { let der = node . tmp . substitutions . get ( & qmut . pos ) ; if let Some ( der ) = der { // position is also mutated in node if qmut . qry == * der { shared_differences += 1 ; // the exact mutation is shared between node and seq } else { shared_sites += 1 ; // the same position is mutated, but the states are different } } } // determine the number of sites that are mutated in the node but missing in seq. // for these we can't tell whether the node agrees with seq let mut undetermined_sites = 0_i64 ; for pos in node . tmp . substitutions . keys ( ) { if ! is_nuc_sequenced ( * pos , qry_missing , aln_range ) { undetermined_sites += 1 ; } } let total_node_muts = node . tmp . substitutions . len ( ) as i64 ; let total_seq_muts = qry_nuc_subs . len ( ) as i64 ; // calculate distance from set overlaps. total_node_muts + total_seq_muts - 2 * shared_differences - shared_sites - undetermined_sites }
Calculates distance metric between a given query sample and a tree node
Calculates distance metric between a given query sample and a tree node
node
&AuspiceTreeNode
qry_nuc_subs
&[NucSub]
qry_missing
&[NucRange]
aln_range
&Range