use strict;
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" )
{
{
Maasha::Fasta::put_entry( $entry, $fh_out );
}
- elsif ( $fh_out and $record->{ "CHR" } and $record->{ "CHR_BEG" } and $record->{ "STEP" } and $record->{ "VALS" } )
+ elsif ( $fh_out and $record->{ "CHR" } and $record->{ "CHR_BEG" } and $record->{ "STEP" } and $record->{ "VALS" } ) # TODO: clean this!
{
print $fh_out "fixedStep chrom=$record->{ 'CHR' } start=$record->{ 'CHR_BEG' } step=$record->{ 'STEP' }\n";
Maasha::Biopieces::put_record( $record, $out ) if not $options->{ "no_stream" };
}
+close $fh_out if $fh_out;
+
foreach $format ( @{ $options->{ 'formats' } } )
{
print STDERR qq(Creating format: $format for $genome ... ) if $options->{ 'verbose' };
- if ( $format =~ /^fasta$/i ) { Maasha::Fasta::fasta_index( "$fasta_dir/$genome.fna", "$dir/genomes/$genome/fasta/$genome.index" ) }
+ if ( $format =~ /^fasta$/i ) { Maasha::Fasta::fasta_index( "$fasta_dir/$genome.fna", $fasta_dir, "$genome.index" ) }
elsif ( $format =~ /^blast$/i ) { Maasha::NCBI::blast_index( "$genome.fna", $fasta_dir, "$dir/genomes/$genome/blast", "dna", $genome ) }
- elsif ( $format =~ /^blat$/i ) { warn "BLAT FORMAT NOT IMPLEMENTED" }
+ elsif ( $format =~ /^blat$/i ) { warn "BLAT FORMAT NOT IMPLEMENTED\n" }
elsif ( $format =~ /^vmatch$/i ) { Maasha::Match::vmatch_index( "$genome.fna", $fasta_dir, "$dir/genomes/$genome/vmatch", $tmp_dir ) }
- elsif ( $format =~ /^bowtie$/i ) { bowtie_index( "$fasta_dir/$genome.fna", "$dir/genomes/$genome/bowtie", $genome, $options->{ 'verbose' } ) }
+ 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' };
}
-close $fh_out if $fh_out;
-
Maasha::Biopieces::close_stream( $in );
Maasha::Biopieces::close_stream( $out );
-# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SUBROUTINES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
-
-sub bowtie_index
-{
- # Martin A. Hansen, July 2009.
-
- # Create a bowtie 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( "bowtie-build", "$src_file $dst_dir/$base_name" );
- } else {
- Maasha::Common::run( "bowtie-build", "$src_file $dst_dir/$base_name > /dev/null 2>&1" );
- }
-}
-
-
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<