From 9df9d907cfee132c469c30a586778dd5fc5cf036 Mon Sep 17 00:00:00 2001 From: martinahansen Date: Wed, 27 May 2009 04:06:42 +0000 Subject: [PATCH] migrated match_seq git-svn-id: http://biopieces.googlecode.com/svn/trunk@423 74ccb610-7750-0410-82ae-013aeee3265d --- bp_bin/match_seq | 103 +++++++++++++++++++++++++++++++++++-- code_perl/Maasha/BioRun.pm | 50 ------------------ 2 files changed, 100 insertions(+), 53 deletions(-) diff --git a/bp_bin/match_seq b/bp_bin/match_seq index fdf5bd2..2b852f0 100755 --- a/bp_bin/match_seq +++ b/bp_bin/match_seq @@ -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; diff --git a/code_perl/Maasha/BioRun.pm b/code_perl/Maasha/BioRun.pm index be8d882..d0b3654 100644 --- a/code_perl/Maasha/BioRun.pm +++ b/code_perl/Maasha/BioRun.pm @@ -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. -- 2.39.5