-
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.
Huge changes as I tried to make tree moves use an iterator, broke eve…
…rything, fixed it again finally
- Loading branch information
1 parent
f1fdbdf
commit 702ad73
Showing
10 changed files
with
946 additions
and
878 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,39 @@ | ||
use crate::{rate_matrix::RateMatrix, treestate::TreeMove}; | ||
use rand::prelude::Distribution; | ||
// use rand::distributions::Normal; | ||
use statrs::distribution::Normal; | ||
use crate::topology::Topology; | ||
use crate::TreeState; | ||
pub struct BranchMove{ | ||
indices: Vec<usize>, | ||
} | ||
// use crate::{rate_matrix::RateMatrix, treestate::TreeMove}; | ||
// use rand::prelude::Distribution; | ||
// // use rand::distributions::Normal; | ||
// use statrs::distribution::Normal; | ||
// use crate::topology::Topology; | ||
// use crate::TreeState; | ||
// pub struct BranchMove{ | ||
// indices: Vec<usize>, | ||
// } | ||
|
||
impl<R: RateMatrix> TreeMove<R> for BranchMove { | ||
fn generate(&self, ts: &crate::treestate::TreeState<R>) -> crate::treestate::TreeState<R> { | ||
let normal = Normal::new(0.0, 1.0).unwrap(); | ||
let mut changes: Vec<usize> = Vec::new(); | ||
// impl<R: RateMatrix> TreeMove<R> for BranchMove { | ||
// fn generate(&self, ts: &crate::treestate::TreeState<R>) -> crate::treestate::TreeState<R> { | ||
// let normal = Normal::new(0.0, 1.0).unwrap(); | ||
// let mut changes: Vec<usize> = Vec::new(); | ||
|
||
// This is not ideal | ||
let mut nodes = ts.top.nodes.clone(); | ||
// // This is not ideal | ||
// let mut nodes = ts.top.nodes.clone(); | ||
|
||
for i in self.indices.iter() { | ||
let ind = *i; | ||
let mut bl = nodes[ind].get_branchlen(); | ||
bl = bl.ln() + normal.sample(&mut rand::thread_rng()); | ||
nodes[ind].set_branchlen(bl.exp()); | ||
changes.push(ind); | ||
} | ||
// for i in self.indices.iter() { | ||
// let ind = *i; | ||
// let mut bl = nodes[ind].get_branchlen(); | ||
// bl = bl.ln() + normal.sample(&mut rand::thread_rng()); | ||
// nodes[ind].set_branchlen(bl.exp()); | ||
// changes.push(ind); | ||
// } | ||
|
||
let new_top = Topology{ | ||
nodes: nodes, | ||
tree_vec: ts.top.tree_vec.clone(), | ||
likelihood: ts.top.likelihood, | ||
}; | ||
// let new_top = Topology{ | ||
// nodes: nodes, | ||
// tree_vec: ts.top.tree_vec.clone(), | ||
// }; | ||
|
||
TreeState{ | ||
top: new_top, | ||
mat: ts.mat, | ||
ll: ts.ll, | ||
changed_nodes: Some(changes), | ||
} | ||
} | ||
} | ||
// TreeState{ | ||
// top: new_top, | ||
// mat: ts.mat, | ||
// ll: ts.ll, | ||
// changed_nodes: Some(changes), | ||
// } | ||
// } | ||
// } |
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
Oops, something went wrong.