Skip to content

Commit

Permalink
Use bwa-mem2 not bwa-mem.
Browse files Browse the repository at this point in the history
Fixes #72.

Suggested by: @jianshu93.
  • Loading branch information
wwood committed May 21, 2021
1 parent d480921 commit 0eb2a52
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ install:
- conda config --add channels bioconda
- conda config --add channels conda-forge

- conda create -q -n test-environment bwa 'samtools>=1.9' 'minimap2=2.17' 'dashing>=0.4.0' 'fastani>=1.3'
- conda create -q -n test-environment bwa-mem2 'samtools>=1.9' 'minimap2=2.17' 'dashing>=0.4.0' 'fastani>=1.3'
- source activate test-environment
- cargo build --verbose

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ For the full suite of options, these additional programs must be installed:

and some mapping software:
* [minimap2](https://github.com/lh3/minimap2) v2.17-r941 (2.18 will _not_ work)
* [bwa](https://github.com/lh3/bwa) v0.7.17-r1188
* [bwa-mem2](https://github.com/bwa-mem2/bwa-mem2) v2.0

For dereplication:
* [Dashing](https://github.com/dnbaker/dashing) v0.4.0
Expand Down
2 changes: 1 addition & 1 deletion src/bam_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ pub fn build_mapping_command(
return format!(
"{} {} -t {} {} '{}' {}",
match mapping_program {
MappingProgram::BWA_MEM => "bwa mem".to_string(),
MappingProgram::BWA_MEM => "bwa-mem2 mem".to_string(),
_ => {
let split_prefix = tempfile::NamedTempFile::new().expect(&format!(
"Failed to create {:?} minimap2 split_prefix file",
Expand Down
4 changes: 3 additions & 1 deletion src/external_command_checker.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use bird_tool_utils::external_command_checker::*;

pub fn check_for_bwa() {
check_for_external_command_presence("BWA", "which bwa").expect("Failed to find installed BWA");
check_for_external_command_presence("BWA", "which bwa-mem2").expect("Failed to find installed BWA");
default_version_check("bwa-mem2", "2.0", false, Some("bwa-mem2 version"))
.expect("Failed to find sufficient version of bwa-mem2");
}

pub fn check_for_minimap2() {
Expand Down
4 changes: 2 additions & 2 deletions src/mapping_index_maintenance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl TemporaryIndexStruct {
mapping_program, reference_path
);
let mut cmd = match mapping_program {
MappingProgram::BWA_MEM => std::process::Command::new("bwa"),
MappingProgram::BWA_MEM => std::process::Command::new("bwa-mem2"),
MappingProgram::MINIMAP2_SR
| MappingProgram::MINIMAP2_ONT
| MappingProgram::MINIMAP2_PB
Expand Down Expand Up @@ -158,7 +158,7 @@ pub fn generate_bwa_index(
reference_path: &str,
index_creation_parameters: Option<&str>,
) -> Box<dyn MappingIndex> {
let bwa_extensions = vec!["amb", "ann", "bwt", "pac", "sa"];
let bwa_extensions = vec!["0123", "amb", "ann", "bwt.2bit.64", "pac"];
let num_extensions = bwa_extensions.len();
let mut num_existing: u8 = 0;
for extension in bwa_extensions {
Expand Down
Binary file added tests/data/7seqs.fna.0123
Binary file not shown.
Binary file removed tests/data/7seqs.fna.bwt
Binary file not shown.
Binary file added tests/data/7seqs.fna.bwt.2bit.64
Binary file not shown.
Binary file added tests/data/7seqs.fna.bwt.8bit.32
Binary file not shown.
Binary file removed tests/data/7seqs.fna.sa
Binary file not shown.

2 comments on commit 0eb2a52

@jianshu93
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To support For MacOS, I reverse this commit and compile from source, now it works on both Intel and Apple M1 ARM64 processor MacOS system. Bwa-mem2 was not supported on MacOS because of the Clang compiler but bwa mem does (both intel and Apple M1 ARM64).

Jianshu

@wwood
Copy link
Owner Author

@wwood wwood commented on 0eb2a52 Jul 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jianshu93 thank you for the helpful feedback - I hadn't considered that.

In 68333c1 I pushed support for both, so now you can specify -p bwa-mem or -p bwa-mem2. This reverts the behaviour of the above commit, so now -p bwa-mem is the old BWA, but since there hasn't been a release since I'm OK with flip flopping on that.

Please # to comment.