]> git.donarmstrong.com Git - biopieces.git/commitdiff
added BWA index support
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 8 Sep 2009 08:15:50 +0000 (08:15 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 8 Sep 2009 08:15:50 +0000 (08:15 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@662 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/create_bwa_index
bp_bin/format_genome
code_perl/Maasha/BWA.pm [new file with mode: 0644]

index 9ccb0e427568b65d20b0f5e11337a2ec75455e78..aff3befad90496105aa885a0981af9f3b348c482 100755 (executable)
@@ -32,6 +32,7 @@ use Maasha::Common;
 use Maasha::Biopieces;
 use Maasha::Filesys;
 use Maasha::Fasta;
+use Maasha::BWA;
 
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@@ -69,13 +70,7 @@ while ( $record = Maasha::Biopieces::get_record( $in ) )
 
 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;
 
index af7de5c4ca25f3e18f5a64eeb85baff16a554055..35aa8b3af7354de14d65ef00aa444ebed767e149 100755 (executable)
@@ -31,6 +31,7 @@ use strict;
 use Maasha::Fasta;
 use Maasha::Biopieces;
 use Maasha::Bowtie;
+use Maasha::BWA;
 use Maasha::NCBI;
 use Maasha::Match;
 use Maasha::UCSC;
@@ -44,7 +45,7 @@ my ( $default, $formats, $options, $in, $out, $record, $data_out, $entry,
 
 $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(
     [
@@ -64,7 +65,7 @@ $genome = $options->{ 'genome' };
 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" )
     {
@@ -117,6 +118,7 @@ foreach $format ( @{ $options->{ 'formats' } } )
     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' };
diff --git a/code_perl/Maasha/BWA.pm b/code_perl/Maasha/BWA.pm
new file mode 100644 (file)
index 0000000..a54bc79
--- /dev/null
@@ -0,0 +1,69 @@
+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;