pub fn tree_find_nearest_node<'node>(
  tree: &'node AuspiceTree,
  qry_nuc_subs: &[NucSub],
  qry_missing: &[NucRange],
  aln_range: &Range,
) -> TreeFindNearestNodeOutput<'node> {
  // Iterate over tree nodes and calculate distance metric between the sample and each node
  tree
    .iter_depth_first_preorder()
    .map(|(_, node)| {
      let distance = tree_calculate_node_distance(node, qry_nuc_subs, qry_missing, aln_range);
      TreeFindNearestNodeOutput { node, distance }
    })

    // Find nearest node (having minimum distance)
    .min_by_key(|out| out.distance)

    // If none can be found, return default (e.g. if tree is empty, which is unlikely)
    .unwrap_or(TreeFindNearestNodeOutput {
      node: &tree.tree,
      distance: 0,
    })
}
/// For a given query sample, finds nearest node on the reference tree (according to the distance metric)
For a given query sample, finds nearest node on the reference tree (according to the distance metric)
For a given query sample finds nearest node on the reference tree ( according to the distance metric )
pub fn tree_find_nearest_node<'node>(
  tree: &'node AuspiceTree,
  qry_nuc_subs: &[NucSub],
  qry_missing: &[NucRange],
  aln_range: &Range,
) -> TreeFindNearestNodeOutput<'node> {
  // Iterate over tree nodes and calculate distance metric between the sample and each node
  tree
    .iter_depth_first_preorder()
    .map(|(_, node)| {
      let distance = tree_calculate_node_distance(node, qry_nuc_subs, qry_missing, aln_range);
      TreeFindNearestNodeOutput { node, distance }
    })
    // Find nearest node (having minimum distance)
    .min_by_key(|out| out.distance)
    // If none can be found, return default (e.g. if tree is empty, which is unlikely)
    .unwrap_or(TreeFindNearestNodeOutput {
      node: &tree.tree,
      distance: 0,
    })
}
pub fn tree_find_nearest_node < ' node > ( tree : & ' node AuspiceTree , qry_nuc_subs : & [ NucSub ] , qry_missing : & [ NucRange ] , aln_range : & Range , ) -> TreeFindNearestNodeOutput < ' node > { // Iterate over tree nodes and calculate distance metric between the sample and each node tree . iter_depth_first_preorder ( ) . map ( | ( _ , node ) | { let distance = tree_calculate_node_distance ( node , qry_nuc_subs , qry_missing , aln_range ) ; TreeFindNearestNodeOutput { node , distance } } ) // Find nearest node (having minimum distance) . min_by_key ( | out | out . distance ) // If none can be found, return default (e.g. if tree is empty, which is unlikely) . unwrap_or ( TreeFindNearestNodeOutput { node : & tree . tree , distance : 0 , } ) }
For a given query sample, finds nearest node on the reference tree (according to the distance metric)
For a given query sample finds nearest node on the reference tree ( according to the distance metric )
tree
&'node AuspiceTree
qry_nuc_subs
&[NucSub]
qry_missing
&[NucRange]
aln_range
&Range
tree
&'node AuspiceTree
qry_nuc_subs
&[NucSub]
qry_missing
&[NucRange]
aln_range
&Range