]> git.donarmstrong.com Git - biopieces.git/commitdiff
migrated match_seq
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 27 May 2009 04:06:42 +0000 (04:06 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 27 May 2009 04:06:42 +0000 (04:06 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@423 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/match_seq
code_perl/Maasha/BioRun.pm

index fdf5bd287f78613d2aea83bb9b15f855cad57e77..2b852f03ed7b5b44699d959ea8bdc1ae95c2cd67 100755 (executable)
@@ -1,6 +1,103 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl -w
+
+# Copyright (C) 2007-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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# Find all matches between sequences in the stream.
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
 
-use warnings;
 use strict;
+use Maasha::Biopieces;
+use Maasha::Match;
+use Maasha::Filesys;
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+my ( $run_time_beg, $run_time_end, $options, $in, $out, $record, @entries, $results, $tmp_dir );
+
+$options = Maasha::Biopieces::parse_options(
+    [
+        { long => 'word_size', short => 'w', type => 'uint',   mandatory => 'no', default => 20,     allowed => undef,                  disallowed => 0 },
+        { long => 'direction', short => 'd', type => 'string', mandatory => 'no', default => 'both', allowed => 'both,forward,reverse', disallowed => undef },
+    ]   
+);
+
+$in  = Maasha::Biopieces::read_stream( $options->{ "stream_in" } );
+$out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } );
+
+$tmp_dir = Maasha::Biopieces::get_tmpdir();
+
+while ( $record = Maasha::Biopieces::get_record( $in ) ) 
+{
+    if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) {
+        push @entries, [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ];
+    }
+
+    Maasha::Biopieces::put_record( $record, $out );
+}
+
+if ( @entries == 1 )
+{
+    $results = Maasha::Match::match_mummer( [ $entries[ 0 ] ], [ $entries[ 0 ] ], $options, $tmp_dir );
+
+    map { Maasha::Biopieces::put_record( $_, $out ) } @{ $results };
+}
+elsif ( @entries == 2 )
+{
+    $results = Maasha::Match::match_mummer( [ $entries[ 0 ] ], [ $entries[ 1 ] ], $options, $tmp_dir );
+
+    map { Maasha::Biopieces::put_record( $_, $out ) } @{ $results };
+}
+
+Maasha::Filesys::dir_remove( $tmp_dir );
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+BEGIN
+{
+    $run_time_beg = Maasha::Biopieces::run_time();
+
+    Maasha::Biopieces::log_biopiece();
+}
+
+
+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 );
+}
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+__END__
 
-use Maasha::BioRun;
index be8d8827ea92195fd84d88108e3387a0219f3710..d0b36543c3200a85d9f7f37bed65d639effb5e7d 100644 (file)
@@ -142,7 +142,6 @@ sub run_script
     elsif ( $script eq "tile_seq" )                 { script_tile_seq(                  $in, $out, $options ) }
     elsif ( $script eq "patscan_seq" )              { script_patscan_seq(               $in, $out, $options ) }
     elsif ( $script eq "soap_seq" )                 { script_soap_seq(                  $in, $out, $options ) }
-    elsif ( $script eq "match_seq" )                { script_match_seq(                 $in, $out, $options ) }
     elsif ( $script eq "write_bed" )                { script_write_bed(                 $in, $out, $options ) }
     elsif ( $script eq "write_psl" )                { script_write_psl(                 $in, $out, $options ) }
     elsif ( $script eq "write_fixedstep" )          { script_write_fixedstep(           $in, $out, $options ) }
@@ -395,13 +394,6 @@ sub get_options
             cpus|c=s
         );
     }
-    elsif ( $script eq "match_seq" )
-    {
-        @options = qw(
-            word_size|w=s
-            direction|d=s
-        );
-    }
     elsif ( $script eq "write_bed" )
     {
         @options = qw(
@@ -2197,48 +2189,6 @@ sub script_soap_seq
 }
 
 
-sub script_match_seq
-{
-    # Martin A. Hansen, August 2007.
-
-    # BLATs sequences in stream against a given genome.
-
-    my ( $in,        # handle to in stream
-         $out,       # handle to out stream
-         $options,   # options hash
-       ) = @_;
-
-    # Returns nothing.
-
-    my ( $record, @entries, $results );
-
-    $options->{ "word_size" } ||= 20;
-    $options->{ "direction" } ||= "both";
-
-    while ( $record = Maasha::Biopieces::get_record( $in ) ) 
-    {
-        if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) {
-            push @entries, [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ];
-        }
-
-        Maasha::Biopieces::put_record( $record, $out );
-    }
-
-    if ( @entries == 1 )
-    {
-        $results = Maasha::Match::match_mummer( [ $entries[ 0 ] ], [ $entries[ 0 ] ], $options, $BP_TMP );
-
-        map { Maasha::Biopieces::put_record( $_, $out ) } @{ $results };
-    }
-    elsif ( @entries == 2 )
-    {
-        $results = Maasha::Match::match_mummer( [ $entries[ 0 ] ], [ $entries[ 1 ] ], $options, $BP_TMP );
-
-        map { Maasha::Biopieces::put_record( $_, $out ) } @{ $results };
-    }
-}
-
-
 sub script_write_bed
 {
     # Martin A. Hansen, August 2007.