Skip to content

Commit

Permalink
Add test for get_subset_of_tpfs
Browse files Browse the repository at this point in the history
  • Loading branch information
stevieing committed Jun 18, 2024
1 parent 44c1109 commit 1ebaa8d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/tpf_fasta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub mod tpf_fasta_mod {
all_tpf
}

fn subset_vec_tpf<'a>(
pub fn subset_vec_tpf<'a>(
tpf: &'a Vec<Tpf>,
fasta: (&std::string::String, &usize),
) -> Vec<&'a Tpf> {
Expand Down
33 changes: 32 additions & 1 deletion tests/tpf_fasta.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// pub use fasta_manipulation::tpf_fasta::*;
use fasta_manipulation::tpf_fasta_mod::{check_orientation, get_uniques, Tpf};
use fasta_manipulation::tpf_fasta_mod::{check_orientation, get_uniques, subset_vec_tpf, Tpf};
use noodles::fasta::record::Sequence;

// To test the check orientation function we need to publicly expose it
Expand Down Expand Up @@ -53,3 +53,34 @@ fn get_uniques_returns_unique_scaffold_names() {
vec!["newScaffold1".to_string(), "newScaffold2".to_string()]
);
}

// Need to add some docs for function
// as we were not entirely sure what it was doing
#[test]
fn get_subset_of_tpfs() {
let tpf1 = Tpf {
ori_scaffold: "scaffold1".to_string(),
start_coord: 1,
end_coord: 100,
new_scaffold: "newScaffold1".to_string(),
orientation: "PLUS".to_string(),
};
let tpf2 = Tpf {
ori_scaffold: "scaffold2".to_string(),
start_coord: 1,
end_coord: 100,
new_scaffold: "newScaffold2".to_string(),
orientation: "PLUS".to_string(),
};
let tpf3 = Tpf {
ori_scaffold: "scaffold1".to_string(),
start_coord: 1,
end_coord: 100,
new_scaffold: "newScaffold1".to_string(),
orientation: "PLUS".to_string(),
};
let tpfs = vec![tpf1, tpf2, tpf3];
let fasta = (&"scaffold1".to_string(), &(1 as usize));
let result = subset_vec_tpf(&tpfs, fasta);
assert_eq!(result.len(), 2);
}

0 comments on commit 1ebaa8d

Please sign in to comment.