Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions docs/coverm-contig.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ <h1>MAPPING ALGORITHM OPTIONS</h1>
<td align="left">minimap2 with &#39;<code>-x map-hifi</code>&#39; option</td>
</tr>
<tr class="odd">
<td align="left"><code>minimap2-lr-hq</code></td>
<td align="left">minimap2 with &#39;<code>-x lr:hq</code>&#39; option</td>
</tr>
<tr class="even">
<td align="left"><code>minimap2-no-preset</code></td>
<td align="left">minimap2 with no &#39;<code>-x</code>&#39; option</td>
</tr>
Expand Down
4 changes: 4 additions & 0 deletions docs/coverm-genome.html
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ <h1>MAPPING ALGORITHM OPTIONS</h1>
<td align="left">minimap2 with &#39;<code>-x map-hifi</code>&#39; option</td>
</tr>
<tr class="odd">
<td align="left"><code>minimap2-lr-hq</code></td>
<td align="left">minimap2 with &#39;<code>-x lr:hq</code>&#39; option</td>
</tr>
<tr class="even">
<td align="left"><code>minimap2-no-preset</code></td>
<td align="left">minimap2 with no &#39;<code>-x</code>&#39; option</td>
</tr>
Expand Down
4 changes: 4 additions & 0 deletions docs/coverm-make.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ <h1>MAPPING ALGORITHM OPTIONS</h1>
<td align="left">minimap2 with &#39;<code>-x map-hifi</code>&#39; option</td>
</tr>
<tr class="odd">
<td align="left"><code>minimap2-lr-hq</code></td>
<td align="left">minimap2 with &#39;<code>-x lr:hq</code>&#39; option</td>
</tr>
<tr class="even">
<td align="left"><code>minimap2-no-preset</code></td>
<td align="left">minimap2 with no &#39;<code>-x</code>&#39; option</td>
</tr>
Expand Down
4 changes: 4 additions & 0 deletions src/bam_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub enum MappingProgram {
MINIMAP2_ONT,
MINIMAP2_PB,
MINIMAP2_HIFI,
MINIMAP2_LR_HQ,
MINIMAP2_NO_PRESET,
STROBEALIGN,
}
Expand Down Expand Up @@ -421,6 +422,7 @@ pub fn generate_named_bam_readers_from_reads(
| MappingProgram::MINIMAP2_ONT
| MappingProgram::MINIMAP2_PB
| MappingProgram::MINIMAP2_HIFI
| MappingProgram::MINIMAP2_LR_HQ
| MappingProgram::MINIMAP2_NO_PRESET => Some(0),
};

Expand Down Expand Up @@ -870,6 +872,7 @@ pub fn build_mapping_command(
| MappingProgram::MINIMAP2_ONT
| MappingProgram::MINIMAP2_HIFI
| MappingProgram::MINIMAP2_PB
| MappingProgram::MINIMAP2_LR_HQ
| MappingProgram::MINIMAP2_NO_PRESET => "",
MappingProgram::BWA_MEM | MappingProgram::BWA_MEM2 => match read_format {
ReadFormat::Interleaved => "-p",
Expand Down Expand Up @@ -917,6 +920,7 @@ pub fn build_mapping_command(
MappingProgram::MINIMAP2_ONT => "-x map-ont",
MappingProgram::MINIMAP2_HIFI => "-x map-hifi",
MappingProgram::MINIMAP2_PB => "-x map-pb",
MappingProgram::MINIMAP2_LR_HQ => "-x lr:hq",
MappingProgram::MINIMAP2_NO_PRESET => "",
}
)
Expand Down
3 changes: 3 additions & 0 deletions src/bin/coverm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ fn setup_mapping_index(
| MappingProgram::MINIMAP2_ONT
| MappingProgram::MINIMAP2_HIFI
| MappingProgram::MINIMAP2_PB
| MappingProgram::MINIMAP2_LR_HQ
| MappingProgram::MINIMAP2_NO_PRESET => {
if m.get_flag("minimap2-reference-is-index") || reference_wise_params.len() == 1 {
info!("Not pre-generating minimap2 index");
Expand Down Expand Up @@ -877,6 +878,7 @@ fn parse_mapping_program(m: &clap::ArgMatches) -> MappingProgram {
Some("minimap2-ont") => MappingProgram::MINIMAP2_ONT,
Some("minimap2-pb") => MappingProgram::MINIMAP2_PB,
Some("minimap2-hifi") => MappingProgram::MINIMAP2_HIFI,
Some("minimap2-lr-hq") => MappingProgram::MINIMAP2_LR_HQ,
Some("minimap2-no-preset") => MappingProgram::MINIMAP2_NO_PRESET,
Some("strobealign") => MappingProgram::STROBEALIGN,
None => DEFAULT_MAPPING_SOFTWARE_ENUM,
Expand All @@ -896,6 +898,7 @@ fn parse_mapping_program(m: &clap::ArgMatches) -> MappingProgram {
| MappingProgram::MINIMAP2_ONT
| MappingProgram::MINIMAP2_HIFI
| MappingProgram::MINIMAP2_PB
| MappingProgram::MINIMAP2_LR_HQ
| MappingProgram::MINIMAP2_NO_PRESET => {
external_command_checker::check_for_minimap2();
}
Expand Down
5 changes: 5 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const MAPPING_SOFTWARE_LIST: &[&str] = &[
"minimap2-ont",
"minimap2-pb",
"minimap2-hifi",
"minimap2-lr-hq",
"minimap2-no-preset",
"strobealign",
];
Expand Down Expand Up @@ -85,6 +86,10 @@ fn add_mapping_options(manual: Manual) -> Manual {
&monospace_roff("minimap2-hifi"),
&format!("minimap2 with '{}' option", &monospace_roff("-x map-hifi"))
],
&[
&monospace_roff("minimap2-lr-hq"),
&format!("minimap2 with '{}' option", &monospace_roff("-x lr:hq"))
],
&[
&monospace_roff("minimap2-no-preset"),
&format!("minimap2 with no '{}' option", &monospace_roff("-x"))
Expand Down
5 changes: 2 additions & 3 deletions src/coverage_printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,8 @@ pub fn print_sparse_cached_coverage_taker(
}
coverage_totals[*i] = Some(total_coverage);

if reads_mapped_per_sample.is_some() {
let reads_mapped =
&reads_mapped_per_sample.as_ref().unwrap()[current_stoit_index];
if let Some(reads_mapped_per_sample) = reads_mapped_per_sample.as_ref() {
let reads_mapped = &reads_mapped_per_sample[current_stoit_index];
let fraction_mapped = reads_mapped.num_mapped_reads as f32
/ reads_mapped.num_reads as f32;
coverage_multipliers[*i] = Some(fraction_mapped);
Expand Down
8 changes: 7 additions & 1 deletion src/mapping_index_maintenance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ impl TemporaryIndexStruct {
| MappingProgram::MINIMAP2_ONT
| MappingProgram::MINIMAP2_PB
| MappingProgram::MINIMAP2_HIFI
| MappingProgram::MINIMAP2_LR_HQ
| MappingProgram::MINIMAP2_NO_PRESET => std::process::Command::new("minimap2"),
MappingProgram::STROBEALIGN => std::process::Command::new("strobealign"),
};
Expand All @@ -79,6 +80,7 @@ impl TemporaryIndexStruct {
| MappingProgram::MINIMAP2_ONT
| MappingProgram::MINIMAP2_HIFI
| MappingProgram::MINIMAP2_PB
| MappingProgram::MINIMAP2_LR_HQ
| MappingProgram::MINIMAP2_NO_PRESET => {
match &mapping_program {
MappingProgram::MINIMAP2_SR => {
Expand All @@ -93,6 +95,9 @@ impl TemporaryIndexStruct {
MappingProgram::MINIMAP2_PB => {
cmd.arg("-x").arg("map-pb");
}
MappingProgram::MINIMAP2_LR_HQ => {
cmd.arg("-x").arg("lr:hq");
}
MappingProgram::MINIMAP2_NO_PRESET
| MappingProgram::BWA_MEM
| MappingProgram::BWA_MEM2
Expand Down Expand Up @@ -180,7 +185,7 @@ fn check_for_bwa_index_existence(reference_path: &str, mapping_program: &Mapping
if num_existing == 0 {
false
} else if num_existing == num_extensions {
return true;
true
} else {
error!("BWA index appears to be incomplete, cannot continue.");
process::exit(1);
Expand All @@ -200,6 +205,7 @@ pub fn check_reference_existence(reference_path: &str, mapping_program: &Mapping
| MappingProgram::MINIMAP2_ONT
| MappingProgram::MINIMAP2_HIFI
| MappingProgram::MINIMAP2_PB
| MappingProgram::MINIMAP2_LR_HQ
| MappingProgram::MINIMAP2_NO_PRESET
| MappingProgram::STROBEALIGN => {}
};
Expand Down
17 changes: 10 additions & 7 deletions src/mapping_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ impl<'a> MappingParameters<'a> {
match mapping_program {
MappingProgram::MINIMAP2_ONT
| MappingProgram::MINIMAP2_PB
| MappingProgram::MINIMAP2_HIFI => {
| MappingProgram::MINIMAP2_HIFI
| MappingProgram::MINIMAP2_LR_HQ => {
if !read1.is_empty() || !interleaved.is_empty() {
error!(
"Paired-end read input specified to be mapped \
with minimap2-ont, minimap2-pb, or minimap2-hifi which is presumably \
with minimap2-ont, minimap2-pb, minimap2-hifi, or minimap2-lr-hq \
which is presumably \
incorrect. Mapping paired reads can be run via \
minimap2-no-params if -ont or -pb mapping \
is desired."
Expand All @@ -120,6 +122,7 @@ impl<'a> MappingParameters<'a> {
| MappingProgram::MINIMAP2_ONT
| MappingProgram::MINIMAP2_HIFI
| MappingProgram::MINIMAP2_PB
| MappingProgram::MINIMAP2_LR_HQ
| MappingProgram::MINIMAP2_NO_PRESET => "minimap2-params",
MappingProgram::STROBEALIGN => "strobealign-params",
};
Expand Down Expand Up @@ -239,27 +242,27 @@ impl<'a> Iterator for SingleReferenceMappingParameters<'a> {
} else if self.iter_interleaved_index < self.interleaved.len() {
let i = self.iter_interleaved_index;
self.iter_interleaved_index += 1;
return Some(OneSampleMappingParameters {
Some(OneSampleMappingParameters {
reference: self.reference,
read_format: ReadFormat::Interleaved,
read1: self.interleaved[i],
read2: None,
threads: self.threads,
mapping_options: self.mapping_options,
});
})
} else if self.iter_unpaired_index < self.unpaired.len() {
let i = self.iter_unpaired_index;
self.iter_unpaired_index += 1;
return Some(OneSampleMappingParameters {
Some(OneSampleMappingParameters {
reference: self.reference,
read_format: ReadFormat::Single,
read1: self.unpaired[i],
read2: None,
threads: self.threads,
mapping_options: self.mapping_options,
});
})
} else {
return None;
None
}
}
}
Expand Down
51 changes: 51 additions & 0 deletions tests/test_cmdline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1875,6 +1875,57 @@ genome6 26.697144
.unwrap();
}

#[test]
fn test_lr_hq_single_sample_two_zero_means() {
Assert::main_binary()
.with_args(&[
"contig",
"-m",
"mean",
"-p",
"minimap2-lr-hq",
"--single",
"tests/data/2seqs.fasta",
"-r",
"tests/data/7seqs.fna",
])
.succeeds()
.stdout()
.satisfies(
|observed| {
let mut lines = observed.lines();
let header = lines.next().unwrap_or("");
assert!(
header.starts_with("Contig\t"),
"Unexpected header: {header}",
header = header
);

let mut total = 0;
let mut zero_means = 0;
for line in lines {
let fields: Vec<&str> = line.split('\t').collect();
assert_eq!(
fields.len(),
2,
"Expected contig and mean columns in '{line}'"
);
let mean: f64 = fields[1].parse().unwrap();
if mean == 0.0 {
zero_means += 1;
}
total += 1;
}

assert_eq!(total, 7, "Expected 7 contig rows");
assert_eq!(zero_means, 2, "Expected 2 zero-mean contigs");
true
},
"unexpected output",
)
.unwrap();
}

#[test]
fn test_ont_two_samples() {
// Also tests that -t is being set when minimap2 indexing
Expand Down
Loading