Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

22 changes #41

Merged
merged 4 commits into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 33 additions & 18 deletions tests/tpf_fasta.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use assert_cmd::Command;
use noodles::fasta::fai;
use std::fs;
use std::fs::File;
use std::io::Write;

use noodles::fasta::record::Sequence;
use tempfile::Builder;
use tempfile::NamedTempFile;
// pub use fasta_manipulation::tpf_fasta::*;
use fasta_manipulation::tpf_fasta_mod::{
Expand Down Expand Up @@ -275,39 +278,51 @@ fn check_save_to_fasta() {
};
}

#[ignore = "Work in Progress (WIP)"]
//#[ignore = "Work in Progress (WIP)"]
#[test]
fn check_curate_fasta() {
let mut cmd = Command::cargo_bin("fasta_manipulation").unwrap();
let mut fasta = NamedTempFile::new().unwrap();
let mut tpf = NamedTempFile::new().unwrap();
let mut output = NamedTempFile::new().unwrap();

// Create temp directory that will get cleaned up
let dir = Builder::new().prefix("local_tests").tempdir().unwrap();

// Generate paths for mock files
let fasta_path = &dir.path().join("input_fasta.fa");
let fai_path = &dir.path().join("input_fasta.fa.fai");
let tpf_path = &dir.path().join("input.tpf");

// Actually generate the mock files
let mut fasta = File::create(fasta_path).unwrap();
let mut fai = File::create(fai_path).unwrap();
let mut tpf = File::create(tpf_path).unwrap();

let output = "./output.fa";

write!(
fai,
"SCAFFOLD_1\t16\t12\t16\t17\nSCAFFOLD_3\t16\t41\t16\t17"
)
.unwrap();

write!(
fasta,
r"
>SCAFFOLD_1
ATGCATGCCGTATAGA
>SCAFFOLD_3
AGTGTATTTTTATGCA
"
">SCAFFOLD_1\nATGCATGCCGTATAGA\n>SCAFFOLD_3\nAGTGTATTTTTATGCA"
)
.unwrap();

write!(
tpf,
r"
? SCAFFOLD_1:1-9 RL_1 MINUS
GAP TYPE-2 200
? SCAFFOLD_3:1-5 RL_2 PLUS
"
"?\tSCAFFOLD_1:1-9\tRL_1\tMINUS\nGAP\tTYPE-2\t200\n?\tSCAFFOLD_3:1-5\tRL_2\tPLUS"
)
.unwrap();

cmd.arg("curate")
.arg("-f")
.arg(fasta.path())
.arg(fasta_path)
.arg("-t")
.arg(tpf.path())
.arg(tpf_path)
.arg("-o")
.arg(output.path())
.arg(output)
.assert()
.success();
}
Loading