From: martinahansen Date: Tue, 8 Sep 2009 08:15:50 +0000 (+0000) Subject: added BWA index support X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=29472b5aae00354d6b521fcdca902d09e08f7823;p=biopieces.git added BWA index support git-svn-id: http://biopieces.googlecode.com/svn/trunk@662 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/bp_bin/create_bwa_index b/bp_bin/create_bwa_index index 9ccb0e4..aff3bef 100755 --- a/bp_bin/create_bwa_index +++ b/bp_bin/create_bwa_index @@ -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; diff --git a/bp_bin/format_genome b/bp_bin/format_genome index af7de5c..35aa8b3 100755 --- a/bp_bin/format_genome +++ b/bp_bin/format_genome @@ -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 index 0000000..a54bc79 --- /dev/null +++ b/code_perl/Maasha/BWA.pm @@ -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;