Skip to content

Commit

Permalink
linking newick to vector C++ code
Browse files Browse the repository at this point in the history
  • Loading branch information
jhellewell14 committed Apr 3, 2024
1 parent 29c1db8 commit cff70f1
Show file tree
Hide file tree
Showing 5 changed files with 785 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/dspsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ impl Tree {
println!("Tree log likelihood: {}", self.get_tree_likelihood());
// Generate peturbation vector
delta = peturbation_vec(n);
// println!("Peturbation vector: {:?}", delta);


// Generate pi vector
pivec = piv(&theta);
// println!("Pi vector: {:?}", pivec);
Expand Down
16 changes: 9 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,31 @@ pub fn main() {

let start = Instant::now();

let nw = phylo2vec_quad(random_tree(2)).newick();
println!("{:?}", nw);
let x = newick2vec(&nw, 3, true);
println!("{:?}", x);

// Define rate matrix
let q: na::Matrix4<f64> = na::Matrix4::new(
-1.0, 1.0 / 3.0, 1.0 / 3.0, 1.0 / 3.0,
1.0 / 3.0, -1.0, 1.0 / 3.0, 1.0 / 3.0,
1.0 / 3.0, 1.0 / 3.0, -1.0, 1.0 / 3.0,
1.0 / 3.0, 1.0 / 3.0, 1.0 / 3.0, -1.0,
);

let mut tr = phylo2vec_quad(random_tree(27));

let end = Instant::now();
// let filename = "listeria0.aln";
let mut myvec: Vec<usize> = vec![0; 27];
let mut tr = phylo2vec_quad(myvec);
let filename = "listeria0.aln";
tr.add_genetic_data(&args.alignment);

tr.update_likelihood_postorder(&q);

println!("{}", tr.get_tree_likelihood());
println!("{:?}", tr.newick());
println!("{:?}", tr.tree_vec);

if !args.no_optimise {
// tr.optimise(&q, 10);
tr.hillclimb(&q, 20);
// tr.hillclimb(&q, 20);
}

// let end = Instant::now();
Expand Down
Loading

0 comments on commit cff70f1

Please sign in to comment.