-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The Tree struct now has a RateParam struct that can be used to update…
… a rate_matrix. Trees initialise with a default RateParams. Likelihood functions no longer require an external rate matrix and now use the Tree's rate_matrix
- Loading branch information
1 parent
0f2387c
commit 362e3db
Showing
7 changed files
with
91 additions
and
68 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,42 @@ | ||
use crate::Tree; | ||
|
||
#[derive(Debug)] | ||
pub struct RateParam(pub f64, pub f64, pub f64, pub f64, pub f64, pub f64, pub Vec<f64>); | ||
|
||
impl Default for RateParam { | ||
fn default() -> Self { | ||
RateParam(4.0 / 3.0, 4.0 / 3.0, 4.0 / 3.0, 4.0 / 3.0, 4.0 / 3.0, 4.0 / 3.0, vec![0.25, 0.25, 0.25, 0.25]) | ||
} | ||
} | ||
|
||
impl Tree { | ||
|
||
pub fn update_rate_param(&mut self, a: f64, b: f64, c: f64, d: f64, e: f64, f: f64, pv: Vec<f64>) { | ||
self.rate_param = RateParam(a, b, c, d, e, f, pv); | ||
// self.update_rate_matrix_GTR(); | ||
} | ||
|
||
pub fn update_rate_matrix_GTR(&mut self) { | ||
let RateParam(a, b, c, d, e, f, pv) = &self.rate_param; | ||
// pv = pivec defined as (piA, piC, piG, piT) | ||
let mut q = na::Matrix4::new( | ||
-(a * pv[1] + b * pv[2] + c * pv[3]), | ||
a * pv[1], | ||
b * pv[2], | ||
c * pv[3], | ||
a * pv[0], | ||
-(a * pv[0] + d * pv[2] + e * pv[3]), | ||
d * pv[2], | ||
e * pv[3], | ||
b * pv[0], | ||
d * pv[1], | ||
-(b * pv[0] + d * pv[1] + f * pv[3]), | ||
f * pv[3], | ||
c * pv[0], | ||
e * pv[1], | ||
f * pv[2], | ||
-(c * pv[0] + e * pv[1] + f * pv[2])); | ||
|
||
self.rate_matrix = q; | ||
} | ||
} |
This file contains 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 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