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

Feature/bwamem2 #54

Merged
merged 8 commits into from
Feb 14, 2020
Prev Previous commit
Next Next commit
This would do a full switch to bwa-mem2, probably want it to be optio…
…nal, but default
  • Loading branch information
keiranmraine committed Feb 4, 2020
commit 0b3c0c36aaa2c5d71152ccdb9ad27da0e27a28f9
2 changes: 1 addition & 1 deletion bin/bwa_mem.pl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ sub setup {
exit 0;
}

my $version = PCAP::Bwa::bwa_version();
my $version = PCAP::Bwa::bwamem2_version();
die "bwa mem can only be used with bwa version 0.7+, the version found in path is: $version\n" unless(version->parse($version) >= version->parse('0.7.0'));

# then check for no args:
Expand Down
10 changes: 10 additions & 0 deletions build/opt-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ if [ ! -e $SETUP_DIR/bwa.success ]; then
touch $SETUP_DIR/bwa.success
fi

## build BWA-mem2 (tar.gz)
if [ ! -e $SETUP_DIR/bwa2.success ]; then
curl -sSL https://github.com/bwa-mem2/bwa-mem2/releases/download/v2.0pre2/bwa-mem2-2.0pre2_x64-linux.tar.bz2 > distro.tar.bz2
rm -rf distro/*
tar --strip-components 1 -C distro -jxf distro.tar.bz2
cp distro/bwa-mem2* $INST_PATH/bin/.
rm -rf distro.* distro/*
touch $SETUP_DIR/bwa2.success
fi

## Bio::DB::HTS (tar.gz)
if [ ! -e $SETUP_DIR/Bio-DB-HTS.success ]; then
## add perl deps
Expand Down
14 changes: 13 additions & 1 deletion lib/PCAP/Bwa.pm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ sub bwa_mem_max_cores {
return $BWA_MEM_MAX_CORES;
}

sub bwamem2_version {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

bwa-mem2 has a much cleaner version string... root command is different too

my $bwa = _which('bwa-mem2');
my $version;
{
my ($stdout, $stderr, $exit) = capture{ system("$bwa version"); };
chomp $stdout;
($version) = $stdout =~ /([[:digit:]\.]+)/m;
}
return $version;
}

sub bwa_version {
my $bwa = _which('bwa');
my $version;
Expand Down Expand Up @@ -279,7 +290,8 @@ sub bwa_mem {
if(exists $options->{'bwa_pl'}) {
$bwa .= 'LD_PRELOAD='.$options->{'bwa_pl'}.' ';
}
$bwa .= _which('bwa') || die "Unable to find 'bwa' in path";
# may want to test for chipset abilities
$bwa .= _which('bwa-mem2') || die "Unable to find 'bwa-mem2' in path";

$ENV{SHELL} = '/bin/bash'; # ensure bash to allow pipefail
my $command = 'set -o pipefail; ';
Expand Down
1 change: 1 addition & 0 deletions t/pcapBwa.t
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ subtest 'Initialisation checks' => sub {

subtest 'Non object checks' => sub {
ok(PCAP::Bwa::bwa_version(), 'Version returned for BWA');
ok(PCAP::Bwa::bwamem2_version(), 'Version returned for bwa-mem2');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Confirm version check works

};

done_testing();