]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/blat_seq
removed debug message
[biopieces.git] / bp_bin / blat_seq
index 9c3ffa7f879f6c4ef8932aba5633165af0ef176a..1f327fab0997097901c1d060a46de4edc69062ff 100755 (executable)
@@ -1,6 +1,6 @@
-#!/usr/bin/env perl -w
+#!/usr/bin/env perl
 
-# Copyright (C) 2007-2009 Martin A. Hansen.
+# Copyright (C) 2007-2010 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
@@ -26,6 +26,7 @@
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
+use warnings;
 use strict;
 use Maasha::Biopieces;
 use Maasha::Filesys;
@@ -37,31 +38,45 @@ use Maasha::UCSC::PSL;
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
-my ( $options, $in, $out, $record, $blat_args, $genome_file, $query_file, $fh_in, $fh_out,
+my ( $options, $in, $out, $record, $blat_args, $subject_file, $query_file, $fh_in, $fh_out,
      $tmp_dir, $type, $result_file, $entry );
 
 $options = Maasha::Biopieces::parse_options(
     [
-        { long => 'genome',       short => 'g', type => 'genome', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
-        { long => 'occ',          short => 'c', type => 'flag',   mandatory => 'no',  default => undef, allowed => undef, disallowed => undef },
-        { long => 'tile_size',    short => 't', type => 'uint',   mandatory => 'no',  default => 11,    allowed => undef, disallowed => 0 },
-        { long => 'step_size',    short => 's', type => 'uint',   mandatory => 'no',  default => 11,    allowed => undef, disallowed => 0 },
-        { long => 'min_identity', short => 'm', type => 'uint',   mandatory => 'no',  default => 90,    allowed => undef, disallowed => 0 },
-        { long => 'min_score',    short => 'M', type => 'uint',   mandatory => 'no',  default => 0,     allowed => undef, disallowed => undef },
-        { long => 'one_off',      short => 'o', type => 'uint',   mandatory => 'no',  default => 0,     allowed => undef, disallowed => undef },
+        { long => 'database',       short => 'd', type => 'file',   mandatory => 'no', default => undef,  allowed => undef, disallowed => undef },
+        { long => 'genome',         short => 'g', type => 'genome', mandatory => 'no', default => undef,  allowed => undef, disallowed => undef },
+        { long => 'fast_map',       short => 'f', type => 'flag',   mandatory => 'no', default => undef,  allowed => undef, disallowed => undef },
+        { long => 'occ',            short => 'c', type => 'flag',   mandatory => 'no', default => undef,  allowed => undef, disallowed => undef },
+        { long => 'intron_max',     short => 'i', type => 'uint',   mandatory => 'no', default => 750000, allowed => undef, disallowed => undef },
+        { long => 'tile_size',      short => 't', type => 'uint',   mandatory => 'no', default => 11,     allowed => undef, disallowed => 0 },
+        { long => 'step_size',      short => 's', type => 'uint',   mandatory => 'no', default => 11,     allowed => undef, disallowed => 0 },
+        { long => 'min_identity',   short => 'm', type => 'uint',   mandatory => 'no', default => 90,     allowed => undef, disallowed => 0 },
+        { long => 'min_score',      short => 'M', type => 'uint',   mandatory => 'no', default => 0,      allowed => undef, disallowed => undef },
+        { long => 'one_off',        short => 'o', type => 'uint',   mandatory => 'no', default => 0,      allowed => undef, disallowed => undef },
+        { long => 'allow_N_blocks', short => 'N', type => 'flag',   mandatory => 'no', default => undef,  allowed => undef, disallowed => undef },
     ]   
 );
 
+Maasha::Common::error( qq(both --database and --genome specified) ) if     $options->{ "genome" } and     $options->{ "database" };
+Maasha::Common::error( qq(no --database or --genome specified) )    if not $options->{ "genome" } and not $options->{ "database" };
+
 $in  = Maasha::Biopieces::read_stream( $options->{ "stream_in" } );
 $out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } );
 
-$genome_file = "$ENV{ 'BP_DATA' }/genomes/$options->{ 'genome' }/fasta/$options->{ 'genome' }.fna";
+if ( $options->{ 'database' } ) {
+    $subject_file = $options->{ 'database' };
+} else {
+    $subject_file = "$ENV{ 'BP_DATA' }/genomes/$options->{ 'genome' }/fasta/$options->{ 'genome' }.fna";
+}
 
 $blat_args .= " -tileSize=$options->{ 'tile_size' }";
 $blat_args .= " -oneOff=$options->{ 'one_off' }";
 $blat_args .= " -minIdentity=$options->{ 'min_identity' }";
 $blat_args .= " -minScore=$options->{ 'min_score' }";
 $blat_args .= " -stepSize=$options->{ 'step_size' }";
+$blat_args .= " -maxIntron=$options->{ 'intron_max' }";
+$blat_args .= " -fastMap"        if $options->{ 'fast_map' }; 
+$blat_args .= " -extendThroughN" if $options->{ 'allow_N_blocks' }; 
 # $blat_args .= " -ooc=" . Maasha::Config::genome_blat_ooc( $options->{ "genome" }, 11 ) if $options->{ 'ooc' };
 
 $tmp_dir = Maasha::Biopieces::get_tmpdir();
@@ -82,16 +97,20 @@ while ( $record = Maasha::Biopieces::get_record( $in ) )
 
 close $fh_out;
 
-$blat_args .= " -t=dnax" if $type eq "protein";
+$blat_args .= " -t=dnax" if $type eq "PROTEIN";
 $blat_args .= " -q=$type";
 
 $result_file = "$tmp_dir/blat.psl";
 
-Maasha::Common::run( "blat", "$genome_file $query_file $blat_args $result_file > /dev/null 2>&1" );
+if ( $options->{ 'verbose' } ) {
+    Maasha::Common::run( "blat", "$subject_file $query_file $blat_args $result_file" );
+} else {
+    Maasha::Common::run( "blat", "$subject_file $query_file $blat_args $result_file > /dev/null 2>&1" );
+}
 
 unlink $query_file;
 
-$fh_in = Maasha::Filesys::file_read_opem( $result_file );
+$fh_in = Maasha::Filesys::file_read_open( $result_file );
 
 while ( $entry = Maasha::UCSC::PSL::psl_entry_get( $fh_in ) )
 {
@@ -103,7 +122,8 @@ while ( $entry = Maasha::UCSC::PSL::psl_entry_get( $fh_in ) )
 close  $fh_in;
 unlink $result_file;
 
-Maasha::Filesys::dir_remove( $tmp_dir );
+Maasha::Biopieces::close_stream( $in );
+Maasha::Biopieces::close_stream( $out );
 
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@@ -111,20 +131,13 @@ Maasha::Filesys::dir_remove( $tmp_dir );
 
 BEGIN
 {
-    $run_time_beg = Maasha::Biopieces::run_time();
-
-    Maasha::Biopieces::log_biopiece();
+    Maasha::Biopieces::status_set();
 }
 
 
 END
 {
-    Maasha::Biopieces::close_stream( $in );
-    Maasha::Biopieces::close_stream( $out );
-
-    $run_time_end = Maasha::Biopieces::run_time();
-
-    Maasha::Biopieces::run_time_print( $run_time_beg, $run_time_end, $options );
+    Maasha::Biopieces::status_log();
 }
 
 
@@ -132,4 +145,3 @@ END
 
 
 __END__
-