From e62c164bef1458244a4ee508cec0e2566c4fd284 Mon Sep 17 00:00:00 2001 From: martinahansen Date: Sun, 24 May 2009 10:08:01 +0000 Subject: [PATCH] migrated align_seq git-svn-id: http://biopieces.googlecode.com/svn/trunk@391 74ccb610-7750-0410-82ae-013aeee3265d --- bp_bin/align_seq | 100 +++++++++++++++++++++++++++++++++++-- code_perl/Maasha/BioRun.pm | 43 ---------------- 2 files changed, 97 insertions(+), 46 deletions(-) diff --git a/bp_bin/align_seq b/bp_bin/align_seq index fdf5bd2..33930cb 100755 --- a/bp_bin/align_seq +++ b/bp_bin/align_seq @@ -1,6 +1,100 @@ -#!/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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +# Align sequences in the stream. + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + -use warnings; use strict; +use Maasha::Biopieces; +use Maasha::Align; + +use constant { + SEQ_NAME => 0, + SEQ => 1, +}; + + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + +my ( $run_time_beg, $run_time_end, $options, $in, $out, $record, @entries, $entry ); + +$in = Maasha::Biopieces::read_stream( $options->{ "stream_in" } ); +$out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } ); + +while ( $record = Maasha::Biopieces::get_record( $in ) ) +{ + if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) { + push @entries, [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ]; + } elsif ( $record->{ "Q_ID" } and $record->{ "SEQ" } ) { + push @entries, [ $record->{ "Q_ID" }, $record->{ "SEQ" } ]; + } else { + Maasha::Biopieces::put_record( $record, $out ); + } +} + +@entries = Maasha::Align::align( \@entries ); + +foreach $entry ( @entries ) +{ + if ( $entry->[ SEQ_NAME ] and $entry->[ SEQ ] ) + { + $record = { + SEQ_NAME => $entry->[ SEQ_NAME ], + SEQ => $entry->[ SEQ ], + }; + + Maasha::Biopieces::put_record( $record, $out ); + } +} + + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + +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 ebbd3c5..c54c9ef 100644 --- a/code_perl/Maasha/BioRun.pm +++ b/code_perl/Maasha/BioRun.pm @@ -149,7 +149,6 @@ sub run_script elsif ( $script eq "fold_seq" ) { script_fold_seq( $in, $out, $options ) } elsif ( $script eq "split_seq" ) { script_split_seq( $in, $out, $options ) } elsif ( $script eq "split_bed" ) { script_split_bed( $in, $out, $options ) } - elsif ( $script eq "align_seq" ) { script_align_seq( $in, $out, $options ) } elsif ( $script eq "tile_seq" ) { script_tile_seq( $in, $out, $options ) } elsif ( $script eq "invert_align" ) { script_invert_align( $in, $out, $options ) } elsif ( $script eq "patscan_seq" ) { script_patscan_seq( $in, $out, $options ) } @@ -2584,48 +2583,6 @@ sub script_split_bed } -sub script_align_seq -{ - # Martin A. Hansen, August 2007. - - # Align sequences in stream. - - my ( $in, # handle to in stream - $out, # handle to out stream - ) = @_; - - # Returns nothing. - - my ( $record, @entries, $entry ); - - while ( $record = Maasha::Biopieces::get_record( $in ) ) - { - if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) { - push @entries, [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ]; - } elsif ( $record->{ "Q_ID" } and $record->{ "SEQ" } ) { - push @entries, [ $record->{ "Q_ID" }, $record->{ "SEQ" } ]; - } else { - Maasha::Biopieces::put_record( $record, $out ); - } - } - - @entries = Maasha::Align::align( \@entries ); - - foreach $entry ( @entries ) - { - if ( $entry->[ SEQ_NAME ] and $entry->[ SEQ ] ) - { - $record = { - SEQ_NAME => $entry->[ SEQ_NAME ], - SEQ => $entry->[ SEQ ], - }; - - Maasha::Biopieces::put_record( $record, $out ); - } - } -} - - sub script_tile_seq { # Martin A. Hansen, February 2008. -- 2.39.2