Skip to content

Commit

Permalink
Test for phyloinfor from sequences and newick
Browse files Browse the repository at this point in the history
  • Loading branch information
junniest committed Nov 16, 2023
1 parent 75a241f commit 217a767
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion phylo/src/phylo_info/phylo_info_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use bio::io::fasta::Record;

use super::{phyloinfo_from_files, PhyloInfo};
use crate::io::DataError;
use crate::phylo_info::get_msa_if_aligned;
use crate::phylo_info::{get_msa_if_aligned, phyloinfo_from_sequences_newick};
use crate::tree::tree_parser::ParsingError;

#[test]
Expand Down Expand Up @@ -151,3 +151,32 @@ fn test_aligned_check() {
];
assert!(get_msa_if_aligned(&sequences).is_some());
}

#[test]
fn check_phyloinfo_creation_newick() {
let sequences = vec![
Record::with_attrs("A", None, b"CTATATATAC"),
Record::with_attrs("B", None, b"ATATATATAA"),
Record::with_attrs("C", None, b"TTATATATAT"),
];
let info = phyloinfo_from_sequences_newick(&sequences, "((A:2.0,B:2.0):1.0,C:2.0):0.0;");
assert!(info.is_ok());
assert!(info.unwrap().msa.is_some());
let sequences = vec![
Record::with_attrs("A", None, b"CTATATAAC"),
Record::with_attrs("B", None, b"ATATATATAA"),
Record::with_attrs("C", None, b"TTATATATAT"),
];
let info = phyloinfo_from_sequences_newick(&sequences, "((A:2.0,B:2.0):1.0,C:2.0):0.0;");
assert!(info.is_ok());
assert!(info.unwrap().msa.is_none());
let info = phyloinfo_from_sequences_newick(&[], "((A:2.0,B:2.0):1.0,C:2.0):0.0;");
assert!(info.is_err());
let sequences = vec![
Record::with_attrs("D", None, b"CTATATAAC"),
Record::with_attrs("E", None, b"ATATATATAA"),
Record::with_attrs("F", None, b"TTATATATAT"),
];
let info = phyloinfo_from_sequences_newick(&sequences, "((A:2.0,B:2.0):1.0,C:2.0):0.0;");
assert!(info.is_err());
}

0 comments on commit 217a767

Please sign in to comment.