-
Notifications
You must be signed in to change notification settings - Fork 2
Implementation of TKF92 #99
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
Merged
Merged
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
fb0b0c5
dirty impl of tkf92, not tested in this repo.
MattesMrzik 50995e8
added reassignment and fixed almost all warnings
MattesMrzik 84af102
added toy msa tree tkf92 test
MattesMrzik 6b80f73
test substitutions dont depend on indel points
MattesMrzik 6fceced
test reassignment parallel, dp prob not same as calculated from
MattesMrzik b64319e
forgot to commit test file
MattesMrzik d888403
fixed error mentioned in last commit, parallel
MattesMrzik 320dff9
compare runtimes of pip vs tkf cost (including reestimation)
MattesMrzik 872dfb0
removed reassignment
MattesMrzik fbd2db2
TKFModelSearchCost & tests, still unused warning
MattesMrzik 435b42f
Merge remote-tracking branch 'upstream' into 58-TKF92
MattesMrzik 55f6a82
missing added file change from last commit
MattesMrzik 09deae4
added pub to TKFCostBuilder
MattesMrzik be0f69e
removed unnecessary import
MattesMrzik f1d5fdf
sanity tests for model parameter change
MattesMrzik 27c80a6
params&freqs test, dont make indel model info invalid on substparam c…
MattesMrzik fd72ea4
fixed old bug
MattesMrzik 57e4b42
clean up and removing duplicate code
MattesMrzik d09e977
more tests for coverage
MattesMrzik e93addb
added param valid checks to builder and set_param
MattesMrzik d71f35c
tkf trait and tkf91 impl, no tkf91 tests yet
MattesMrzik 067ae57
tiny clean up
MattesMrzik 83ba149
more coverage; tk92 r cannot be zero fix
MattesMrzik e6c2143
fix set param bug, strip fasta in info builder,
MattesMrzik 431ea6c
Merge remote-tracking branch 'upstream' into 58-TKF92
MattesMrzik ec30d91
param ranges,
MattesMrzik 40a1333
clean up,fixed compatible: had spr instead of nni
MattesMrzik 2a19d81
tkf91 now without r, tkf92 r not zero in check
MattesMrzik 644d635
Update phylo/src/phylo_info/phyloinfo_builder.rs
MattesMrzik 6c54ff2
fix copilot review bug
MattesMrzik 41344ad
Update phylo/src/tkf_model/mod.rs
MattesMrzik b483408
Update phylo/src/tkf_model/mod.rs
MattesMrzik be968d0
implemented most requested changes
MattesMrzik 5f7451f
separated tkf into multiple files/modules
MattesMrzik a4dced0
reworked intermediate value caching
MattesMrzik 006962e
split tests into multiple fns
MattesMrzik 233d7a1
param range test
MattesMrzik 3eac852
before removing caching
MattesMrzik 817efe3
implemented requested changes
MattesMrzik c2e7b59
moved tkf indel stuff to separate file
MattesMrzik 11f6393
more polish
MattesMrzik 59bbf38
fixed borders of param range in tkf and tests
MattesMrzik be6f230
implemented requested changes
MattesMrzik 53f16b3
Merge remote-tracking branch 'upstream/develop' into 58-TKF92
MattesMrzik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| ((A:1.0,B:2.0):3.0,(C:3.5,D:0.5):5.25); | ||
| ((E:1.0,D:2.0):3.0,(C:3.5,F:0.5):5.25); | ||
| (K:1,L:1); | ||
| (K:1,L:1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| use std::fmt::Display; | ||
|
|
||
| use crate::alignment::AncestralAlignment; | ||
| use crate::likelihood::{ModelSearchCost, ParamRange}; | ||
| use crate::substitution_models::{FreqVector, QMatrix, SubstitutionCost}; | ||
|
|
||
| pub mod tkf91; | ||
| pub use tkf91::*; | ||
| pub mod tkf92; | ||
| pub use tkf92::*; | ||
| pub mod tkf_indel; | ||
| pub use tkf_indel::*; | ||
|
|
||
| #[derive(Clone, Debug)] | ||
| pub struct TKFCost<Q: QMatrix + Display, T: TKFModel, AA: AncestralAlignment> { | ||
| // TODO: if we have just the sum of the two costs like this, we need to keep track of the | ||
| // phylo (which is tree and alignment) twice, which might be too big of a downside, since the | ||
| // cost is copied often. Alternatively we could implement the substitution cost inside the | ||
| // tkf92 cost, which would duplicate some code. | ||
| indel_cost: TKFIndelCost<T, AA>, | ||
| subst_cost: SubstitutionCost<Q, AA>, | ||
| } | ||
|
|
||
| impl<Q: QMatrix, T: TKFModel, AA: AncestralAlignment> Display for TKFCost<Q, T, AA> { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| write!( | ||
| f, | ||
| "{} and {}", | ||
| self.indel_cost.model, self.subst_cost.model.qmatrix | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| impl<Q: QMatrix, T: TKFModel, AA: AncestralAlignment> ModelSearchCost for TKFCost<Q, T, AA> { | ||
| fn cost(&self) -> f64 { | ||
| self.indel_cost.cost() + self.subst_cost.cost() | ||
| } | ||
|
|
||
| fn param_count(&self) -> usize { | ||
| self.indel_cost.model.params().len() + self.subst_cost.model.qmatrix.params().len() | ||
| } | ||
|
|
||
| fn param(&self, idx: usize) -> f64 { | ||
| let num_params_indel_model = self.indel_cost.param_count(); | ||
MattesMrzik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if idx < num_params_indel_model { | ||
| return self.indel_cost.param(idx); | ||
| } | ||
| let idx = idx - num_params_indel_model; | ||
| self.subst_cost.param(idx) | ||
| } | ||
|
|
||
| fn set_param(&mut self, idx: usize, value: f64) { | ||
| let num_params_indel_model = self.indel_cost.param_count(); | ||
| if idx < num_params_indel_model { | ||
| self.indel_cost.set_param(idx, value); | ||
| return; | ||
| } | ||
| let idx = idx - num_params_indel_model; | ||
| self.subst_cost.set_param(idx, value); | ||
| } | ||
|
|
||
| fn param_range(&self, idx: usize) -> ParamRange { | ||
| let num_params_indel_model = self.indel_cost.param_count(); | ||
| if idx < num_params_indel_model { | ||
| return self.indel_cost.param_range(idx); | ||
| } | ||
| let idx = idx - num_params_indel_model; | ||
| self.subst_cost.param_range(idx) | ||
| } | ||
|
|
||
| fn set_freqs(&mut self, freqs: FreqVector) { | ||
| self.subst_cost.set_freqs(freqs); | ||
| } | ||
|
|
||
| fn empirical_freqs(&self) -> FreqVector { | ||
| self.subst_cost.info.freqs() | ||
| } | ||
|
|
||
| fn freqs(&self) -> &FreqVector { | ||
| self.subst_cost.freqs() | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| #[cfg_attr(coverage, coverage(off))] | ||
| mod tests; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering -- should this really panic? Or could you print a warning/error instead.
The reason why I'm asking is whether this would be something that breaks the reconstruction or could it just be safely ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like panic is fitting since if this method is called, there is something wrong with the logic of the calling code. When people use
update_ancestral_mapand then have code where a leaf is passed, sth is flawed with their logic and its nice to point that out directly as one might miss the warning in the log.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair, I agree with this explanation!