]> git.donarmstrong.com Git - biopieces.git/commitdiff
added bowtie to format_genome
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Mon, 20 Jul 2009 14:18:28 +0000 (14:18 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Mon, 20 Jul 2009 14:18:28 +0000 (14:18 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@568 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/format_genome
code_perl/Maasha/Solexa.pm

index dbd4182ce02c18cddba67faf12f62fe3f6a670c7..71e1d21e2bc179ce9cde2e9af3e7614025dc0089 100755 (executable)
@@ -43,7 +43,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,phastcons';
+$formats = 'fasta,blast,vmatch,bowtie,phastcons';
 
 $options = Maasha::Biopieces::parse_options(
     [
@@ -63,7 +63,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/i } @{ $options->{ "formats" } } )
+if ( grep { $_ =~ /fasta|blast|vmatch|bowtie/i } @{ $options->{ "formats" } } )
 {
     if ( -f "$dir/genomes/$genome/fasta/$genome.fna" )
     {
@@ -111,8 +111,9 @@ foreach $format ( @{ $options->{ 'formats' } } )
 {
     if    ( $format =~ /^fasta$/i )     { Maasha::Fasta::fasta_index( "$fasta_dir/$genome.fna", "$dir/genomes/$genome/fasta/$genome.index" ) }
     elsif ( $format =~ /^blast$/i )     { Maasha::NCBI::blast_index( "$genome.fna", $fasta_dir, "$dir/genomes/$genome/blast", "dna", $genome ) }
-    elsif ( $format =~ /^blat$/i )      { print STDERR "BLAT FORMAT NOT IMPLEMENTED" }
+    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 )    { bowtie_index( "$fasta_dir/$genome.fna", "$dir/genomes/$genome/bowtie", $genome, $option->{ 'verbose' } ) }
     elsif ( $format =~ /^phastcons$/i ) { Maasha::UCSC::phastcons_index( "$genome.pp", $phastcons_dir ) }
 }
 
@@ -122,6 +123,31 @@ 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" );
+    }
+}
+
+
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
index 058a00a6a73322216abe41b25567391e6b1c446c..f5396584248c044310ef73887f1378e87ac90c9d 100644 (file)
@@ -104,7 +104,7 @@ sub score_oct2dec
 
     # Returns a float
 
-    return 10 * log(1 + 10 ** ((ord( $char ) - 64) / 10.0)) / log(10);
+    return 10 * log( 1 + 10 ** ( ( ord( $char ) - 64 ) / 10.0 ) ) / log( 10 );
 }