use Maasha::Biopieces;
use Maasha::Filesys;
use Maasha::Fasta;
+use Maasha::BWA;
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
close $fh_tmp;
-Maasha::Filesys::dir_create_if_not_exists( $options->{ 'directory' } );
-
-if ( $options->{ 'verbose' } ) {
- Maasha::Common::run( "bwa", "index -p $options->{ 'directory' }/$options->{ 'index_name' } $file_tmp" );
-} else {
- Maasha::Common::run( "bwa", "index -p $options->{ 'directory' }/$options->{ 'index_name' } $file_tmp > /dev/null 2>&1" );
-}
+Maasha::BWA::bwa_index( $file_tmp, $options->{ 'directory' }, $options->{ 'index_name' }, $options->{ 'verbose' } );
unlink $file_tmp;
use Maasha::Fasta;
use Maasha::Biopieces;
use Maasha::Bowtie;
+use Maasha::BWA;
use Maasha::NCBI;
use Maasha::Match;
use Maasha::UCSC;
$tmp_dir = Maasha::Biopieces::get_tmpdir();
$default = $ENV{ 'BP_DATA' };
-$formats = 'fasta,blast,vmatch,bowtie,phastcons';
+$formats = 'fasta,blast,vmatch,bowtie,bwa,phastcons';
$options = Maasha::Biopieces::parse_options(
[
Maasha::Filesys::dir_create_if_not_exists( "$dir/genomes" );
Maasha::Filesys::dir_create_if_not_exists( "$dir/genomes/$genome" );
-if ( grep { $_ =~ /fasta|blast|vmatch|bowtie/i } @{ $options->{ "formats" } } )
+if ( grep { $_ =~ /fasta|blast|vmatch|bowtie|bwa/i } @{ $options->{ "formats" } } )
{
if ( -f "$dir/genomes/$genome/fasta/$genome.fna" )
{
elsif ( $format =~ /^blat$/i ) { warn "BLAT FORMAT NOT IMPLEMENTED" }
elsif ( $format =~ /^vmatch$/i ) { Maasha::Match::vmatch_index( "$genome.fna", $fasta_dir, "$dir/genomes/$genome/vmatch", $tmp_dir ) }
elsif ( $format =~ /^bowtie$/i ) { Maasha::Bowtie::bowtie_index( "$fasta_dir/$genome.fna", "$dir/genomes/$genome/bowtie", $genome, $options->{ 'verbose' } ) }
+ elsif ( $format =~ /^bwa$/i ) { Maasha::BWA::bwa_index( "$fasta_dir/$genome.fna", "$dir/genomes/$genome/bwa", $genome, $options->{ 'verbose' } ) }
elsif ( $format =~ /^phastcons$/i ) { Maasha::UCSC::phastcons_index( "$genome.pp", $phastcons_dir ) }
print STDERR qq(done.\n) if $options->{ 'verbose' };
--- /dev/null
+package Maasha::BWA;
+
+# Copyright (C) 2006-2009 Martin A. Hansen.
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# http://www.gnu.org/copyleft/gpl.html
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+# Routines for manipulation of bowtie indexes and results.
+
+# http://maq.sourceforge.net/bwa-man.shtml
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+use warnings;
+use strict;
+use Data::Dumper;
+use vars qw( @ISA @EXPORT );
+
+@ISA = qw( Exporter );
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+sub bwa_index
+{
+ # Martin A. Hansen, September 2009.
+
+ # Create a BWA index for fast sequence mapping.
+
+ my ( $src_file, # filename of source file
+ $dst_dir, # destination dir to store index
+ $base_name, # base name of index
+ $verbose, # verbose flag
+ ) = @_;
+
+ Maasha::Filesys::dir_create_if_not_exists( $dst_dir );
+
+ if ( $verbose ) {
+ Maasha::Common::run( "bwa", "index -p $dst_dir/$base_name $src_file" );
+ } else {
+ Maasha::Common::run( "bwa", "index -p $dst_dir/$base_name $src_file > /dev/null 2>&1" );
+ }
+}
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+1;