Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ambiguity fix #20

Open
wants to merge 83 commits into
base: develop
Choose a base branch
from
Open

Ambiguity fix #20

wants to merge 83 commits into from

Conversation

junniest
Copy link
Contributor

Fixing the bug where ambiguous characters were not being handled correctly, now the handling matches phyml 1 to 1.

Added try_idx method to get the idx of the node in the tree by its id, checked method
that returns a result. Changed idx() to be unchecked and panic if the node isn't there.
Changed create_postorder to compute_postorder and set it to recompute each time when called
as otherwise it does not get triggered when the tree changes.
Added methods for spr and unchecked spr moves as well as getting node sibling
Changed preorder_subroot to always need a subroot index instead of Option,
as it was just adding unnecessary complexity.
Fixed SPR bug where the parent of the pruned node didn't get the right new parent set.
Added test that helped find the bug.
Added tests to verify that the likelihood computation for gaps and ambiguous
characters matches PhyML for substitution models.
Added tests to check optimised model parameters in K80 and HKY against the
values optimised by PhyML
Added two tests for comparing the topology optimisation and likelihoods on gapped
example with fixed or empirical frequencies
Refactored topology tests to either optimise or use precomputed results if available
Copy link
Contributor

github-actions bot commented Nov 12, 2024

Test Results

318 tests  +74   316 ✅ +72   40m 25s ⏱️ + 34m 29s
  2 suites ± 0     2 💤 + 2 
  1 files   ± 0     0 ❌ ± 0 

Results for commit 6c14ccb. ± Comparison against base commit 151a4e2.

♻️ This comment has been updated with latest results.

@@ -24,14 +24,14 @@ fn check_likelihood_opt_k80() {
.build()
.unwrap();
let model = DNASubstModel::new(K80, &[4.0, 1.0]).unwrap();
let unopt_logl = model.cost(&info);
let unopt_logl = model.cost(&info, false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not clear from the code, what is that false. consider adding a method that would make it clear e.g. cost_with_blah

}

impl<'a, EM: PhyloCostFunction + Clone> PhyloOptimiser<'a, EM> for TopologyOptimiser<'a, EM> {
fn new(model: &'a EM, info: &PhyloInfo) -> Self {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend passing values instead of references here, and doing .clone() outside. This will make things cleaner

let mut moves: Vec<(f64, Tree)> = Vec::with_capacity(regraft_locations.len());
for regraft_branch in &regraft_locations {
let mut new_info = info.clone();
new_info.tree = info.tree.rooted_spr(prune_branch, regraft_branch).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: something feels wrong here. is it certain this place cannot fail? I'd recommend error handling. probably ? should be better than just unwrap

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also it's a strange clone() here. I would recommend moving this type of "cloning" to the tree inteself. e.g. clone_for_tree

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should never fail, but yes, ? is definitely better than unwrap().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed for the second point, I am cloning a big structure that I don't need to clone at all. I will refactor that.

curr_cost = o.final_logl;
info = o.i;
}
info.tree.clean(true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it isn't clear what this true is here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants