Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ebedthan committed May 24, 2021
1 parent 618c81c commit e4e7521
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 167 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "sabreur"
version = "0.3.0"
authors = ["Anicet Ebou <[email protected]>"]
edition = "2018"
exclude = ["CODE_OF_CONDUCT.md", "tests/*", "benches/*", ".github/*"]
exclude = ["CODE_OF_CONDUCT.md", "tests/*", "benches/*", ".github/*", ".cargo/*"]
description = "sabreur is a barcode demultiplexing tool for fasta and fastq files"
homepage = "https://github.com/Ebedthan/sabreur"
readme = "README.md"
Expand Down
54 changes: 28 additions & 26 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,16 +323,15 @@ fn main() -> Result<()> {

// Demultiplexing
writeln!(ohandle, "[INFO] Demultiplexing ...")?;
let (stats, is_unk_r1_empty, is_unk_r2_empty) =
utils::pe_fa_demux(
forward,
reverse,
format,
utils::to_niffler_level(raw_level),
&barcode_info,
mismatch,
&mut nb_records,
)?;
let (stats, unk_status) = utils::pe_fa_demux(
forward,
reverse,
format,
utils::to_niffler_level(raw_level),
&barcode_info,
mismatch,
&mut nb_records,
)?;

if !quiet {
for (key, value) in stats.iter() {
Expand All @@ -344,11 +343,13 @@ fn main() -> Result<()> {
)?;
}
}
if is_unk_r1_empty {
if unk_status == *"truetrue" {
fs::remove_file(future_unk_path1)?;
}
if is_unk_r2_empty {
fs::remove_file(future_unk_path2)?;
} else if unk_status == *"falsetrue" {
fs::remove_file(future_unk_path2)?;
} else if unk_status == *"truefalse" {
fs::remove_file(future_unk_path1)?;
}
}
},
Expand Down Expand Up @@ -474,16 +475,15 @@ fn main() -> Result<()> {

// Demultiplexing
writeln!(ohandle, "[INFO] Demultiplexing ...")?;
let (stats, is_unk_r1_empty, is_unk_r2_empty) =
utils::pe_fq_demux(
forward,
reverse,
format,
utils::to_niffler_level(raw_level),
&barcode_info,
mismatch,
&mut nb_records,
)?;
let (stats, unk_status) = utils::pe_fq_demux(
forward,
reverse,
format,
utils::to_niffler_level(raw_level),
&barcode_info,
mismatch,
&mut nb_records,
)?;

if !quiet {
for (key, value) in stats.iter() {
Expand All @@ -495,11 +495,13 @@ fn main() -> Result<()> {
)?;
}
}
if is_unk_r1_empty {
if unk_status == *"truetrue" {
fs::remove_file(future_unk_path1)?;
}
if is_unk_r2_empty {
fs::remove_file(future_unk_path2)?;
} else if unk_status == *"falsetrue" {
fs::remove_file(future_unk_path2)?;
} else if unk_status == *"truefalse" {
fs::remove_file(future_unk_path1)?;
}
}
},
Expand Down
Loading

0 comments on commit e4e7521

Please sign in to comment.