Skip to content

Commit

Permalink
feat: fix splitting into masked+unmasked and split correct set
Browse files Browse the repository at this point in the history
  • Loading branch information
rneher committed Sep 11, 2023
1 parent d25c973 commit ddd2389
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
9 changes: 4 additions & 5 deletions packages_rs/nextclade/src/analyze/divergence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ pub fn score_nuc_muts(nuc_muts: &[NucSub], masked_ranges: &[NucRefGlobalRange],
let nuc_muts = nuc_muts.iter().filter(|m| m.ref_nuc.is_acgt() && m.qry_nuc.is_acgt());

// Split away masked mutations
let (muts, masked_muts): (Vec<_>, Vec<_>) =
let (masked_muts, muts): (Vec<_>, Vec<_>) =
nuc_muts.partition(|m| masked_ranges.iter().any(|range| range.contains(m.pos)));

let n_muts = muts.iter().count() as f64;
let n_masked_muts = masked_muts.iter().count() as f64;

return n_muts + n_masked_muts * params.masked_muts_weight;
let n_muts = muts.len() as f64;
let n_masked_muts = masked_muts.len() as f64;
n_muts + n_masked_muts * params.masked_muts_weight
}
2 changes: 1 addition & 1 deletion packages_rs/nextclade/src/tree/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Default for TreeBuilderParams {
fn default() -> Self {
Self {
without_greedy_tree_builder: false,
masked_muts_weight: 0.5,
masked_muts_weight: 0.05,
}
}
}
3 changes: 1 addition & 2 deletions packages_rs/nextclade/src/tree/tree_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ pub fn finetune_nearest_node(
params: &TreeBuilderParams,
) -> Result<(GraphNodeKey, BranchMutations), Report> {
let masked_ranges = graph.data.meta.placement_mask_ranges();

let mut best_node = graph.get_node(nearest_node_key)?;
let mut private_mutations = seq_private_mutations.clone();

Expand Down Expand Up @@ -180,7 +179,7 @@ fn find_shared_muts<'g>(
child.payload().name
)
})?;
let child_shared_muts_score = score_nuc_muts(&candidate_split.shared.nuc_muts, masked_ranges, params);
let child_shared_muts_score = score_nuc_muts(&child_split.shared.nuc_muts, masked_ranges, params);
if child_shared_muts_score > shared_muts_score {
shared_muts_score = child_shared_muts_score;
candidate_split = child_split;
Expand Down

0 comments on commit ddd2389

Please sign in to comment.