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

add strobealign to mappers in help #214

Merged
merged 14 commits into from
Jun 12, 2024
6 changes: 6 additions & 0 deletions .github/workflows/test-coverm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@ jobs:
os: ["ubuntu-latest"]
python-version: ["3.11"]
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
environment-file: coverm.yml
channels: conda-forge,defaults,bioconda
mamba-version: "*"
- name: Conda info
shell: bash -el {0}
run: conda info
- name: Conda list
shell: pwsh
run: conda list
- name: Run test
shell: bash -el {0}
run: |
cargo test
miniconda_osx:
Expand All @@ -35,18 +38,21 @@ jobs:
os: ["macos-latest"]
python-version: ["3.11"]
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
environment-file: coverm-osx.yml
channels: conda-forge,defaults,bioconda
mamba-version: "*"
- name: Conda info
shell: bash -el {0}
run: conda info
- name: Conda list
shell: pwsh
run: conda list
- name: Run test
shell: bash -el {0}
run: |
cargo test -- --skip bwa_mem2
12 changes: 8 additions & 4 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const MAPPING_SOFTWARE_LIST: &[&str] = &[
"minimap2-no-preset",
"strobealign",
];
const DEFAULT_MAPPING_SOFTWARE: &str = "minimap2-sr";
const DEFAULT_MAPPING_SOFTWARE: &str = "strobealign";

lazy_static! {
pub static ref COVERM_CLUSTER_COMMAND_DEFINITION: GalahClustererCommandDefinition = {
Expand Down Expand Up @@ -50,12 +50,12 @@ fn add_mapping_options(manual: Manual) -> Manual {
Section::new("Mapping algorithm options")
.option(Opt::new("NAME").short("-p").long("--mapper").help(&format!(
"Underlying mapping software used {}. One of: {}",
default_roff("minimap2-sr"),
default_roff("strobealign"),
bird_tool_utils::clap_utils::table_roff(&[
&["name", "description"],
&[
&monospace_roff("minimap2-sr"),
&format!("minimap2 with '{}' option", &monospace_roff("-x sr"))
&monospace_roff("strobealign"),
"strobealign using default parameters"
],
&[
&monospace_roff("bwa-mem"),
Expand All @@ -65,6 +65,10 @@ fn add_mapping_options(manual: Manual) -> Manual {
&monospace_roff("bwa-mem2"),
"bwa-mem2 using default parameters"
],
&[
&monospace_roff("minimap2-sr"),
&format!("minimap2 with '{}' option", &monospace_roff("-x sr"))
],
&[
&monospace_roff("minimap2-ont"),
&format!("minimap2 with '{}' option", &monospace_roff("-x map-ont"))
Expand Down
60 changes: 58 additions & 2 deletions src/coverage_printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ pub fn print_sparse_cached_coverage_taker(
"{}\t{}",
stoit,
match &entry_names[*entry_i] {
Some(s) => s,
Some(s) => s.trim_end_matches('\r'),
None => {
error!("Didn't find entry name string as expected");
process::exit(1);
Expand Down Expand Up @@ -471,6 +471,7 @@ pub fn print_dense_cached_coverage_taker(
entry_names[stoit_by_entry_by_coverage[0][my_entry_i].entry_index]
.as_ref()
.unwrap()
.trim_end_matches('\r')
)
.unwrap();
for (stoit_i, stoit_entries) in stoit_by_entry_by_coverage.iter().enumerate() {
Expand All @@ -482,7 +483,7 @@ pub fn print_dense_cached_coverage_taker(
print_stream,
"\t{}",
coverages[i]
// Divide first because then there is less
// Divide first because then there are fewer
// rounding errors, particularly when
// coverage == coverage_total
/coverage_totals[ecs.stoit_index][i].unwrap()
Expand Down Expand Up @@ -573,6 +574,31 @@ mod tests {
);
}

#[test]
fn test_dense_cached_printer_newline() {
let mut c = CoverageTakerType::new_cached_single_float_coverage_taker(2);
c.start_stoit("stoit1");
c.start_entry(0, "contig1\r");
c.add_single_coverage(1.1);
c.add_single_coverage(1.2);
let mut stream = Cursor::new(Vec::new());
print_dense_cached_coverage_taker(
"Contig",
&vec!["mean".to_string(), "std".to_string()],
&c,
&mut stream,
None,
&vec![],
None,
None,
);
assert_eq!(
"Contig\tstoit1 mean\tstoit1 std\n\
contig1\t1.1\t1.2\n",
str::from_utf8(stream.get_ref()).unwrap()
);
}

#[test]
fn test_dense_cached_printer_easy_normalised() {
let mut c = CoverageTakerType::new_cached_single_float_coverage_taker(2);
Expand Down Expand Up @@ -643,4 +669,34 @@ mod tests {
contig2\t1025\t12.1\t2.1\t2.2\t22.1\t22.2\n",
std::fs::read_to_string(tf.path()).unwrap());
}

#[test]
fn test_sparse_cached_printer_hello_world() {
let mut c = CoverageTakerType::new_cached_single_float_coverage_taker(2);
c.start_stoit("stoit1");
c.start_entry(0, "contig1");
c.add_single_coverage(1.1);
c.add_single_coverage(1.2);
let mut stream = Cursor::new(Vec::new());
print_sparse_cached_coverage_taker(&c, &mut stream, None, &vec![], None, None);
assert_eq!(
"stoit1\tcontig1\t1.1\t1.2\n",
str::from_utf8(stream.get_ref()).unwrap()
);
}

#[test]
fn test_sparse_cached_printer_newline() {
let mut c = CoverageTakerType::new_cached_single_float_coverage_taker(2);
c.start_stoit("stoit1");
c.start_entry(0, "contig1\r");
c.add_single_coverage(1.1);
c.add_single_coverage(1.2);
let mut stream = Cursor::new(Vec::new());
print_sparse_cached_coverage_taker(&c, &mut stream, None, &vec![], None, None);
assert_eq!(
"stoit1\tcontig1\t1.1\t1.2\n",
str::from_utf8(stream.get_ref()).unwrap()
);
}
}
Loading
Loading