From b0e1158d43866ed65e9851065320957c4cf31f04 Mon Sep 17 00:00:00 2001 From: martinahansen Date: Sun, 24 May 2009 09:10:21 +0000 Subject: [PATCH] migrated complement_seq and reverse_seq git-svn-id: http://biopieces.googlecode.com/svn/trunk@385 74ccb610-7750-0410-82ae-013aeee3265d --- bp_bin/complement_seq | 89 ++++++++++++++++++++++++++++++++++++-- bp_bin/reverse_seq | 74 +++++++++++++++++++++++++++++-- bp_bin/uppercase_seq | 2 - code_perl/Maasha/BioRun.pm | 61 -------------------------- 4 files changed, 157 insertions(+), 69 deletions(-) diff --git a/bp_bin/complement_seq b/bp_bin/complement_seq index fdf5bd2..9ff22c8 100755 --- a/bp_bin/complement_seq +++ b/bp_bin/complement_seq @@ -1,6 +1,89 @@ -#!/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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +# Uppercases sequences in stream. + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + -use warnings; use strict; +use Maasha::Biopieces; +use Maasha::Seq; + + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + +my ( $run_time_beg, $run_time_end, $options, $in, $out, $record, $type ); + +$options = Maasha::Biopieces::parse_options(); + +$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" } ) + { + if ( not $type ) { + $type = Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ); + } + + if ( $type eq "rna" ) { + Maasha::Seq::rna_comp( \$record->{ "SEQ" } ); + } elsif ( $type eq "dna" ) { + Maasha::Seq::dna_comp( \$record->{ "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/bp_bin/reverse_seq b/bp_bin/reverse_seq index fdf5bd2..95e122a 100755 --- a/bp_bin/reverse_seq +++ b/bp_bin/reverse_seq @@ -1,6 +1,74 @@ -#!/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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +# Reverse sequences in the stream. + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + -use warnings; use strict; +use Maasha::Biopieces; + + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + +my ( $run_time_beg, $run_time_end, $options, $in, $out, $record ); + +$options = Maasha::Biopieces::parse_options(); + +$in = Maasha::Biopieces::read_stream( $options->{ "stream_in" } ); +$out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } ); + +while ( $record = Maasha::Biopieces::get_record( $in ) ) +{ + $record->{ "SEQ" } = reverse $record->{ "SEQ" } if $record->{ "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 ); +} + + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + -use Maasha::BioRun; +__END__ diff --git a/bp_bin/uppercase_seq b/bp_bin/uppercase_seq index 774cfe7..703d383 100755 --- a/bp_bin/uppercase_seq +++ b/bp_bin/uppercase_seq @@ -27,8 +27,6 @@ use strict; -use Maasha::Common; -use Maasha::Fasta; use Maasha::Biopieces; diff --git a/code_perl/Maasha/BioRun.pm b/code_perl/Maasha/BioRun.pm index a44bdb0..ecf32f2 100644 --- a/code_perl/Maasha/BioRun.pm +++ b/code_perl/Maasha/BioRun.pm @@ -141,8 +141,6 @@ sub run_script elsif ( $script eq "create_weight_matrix" ) { script_create_weight_matrix( $in, $out, $options ) } elsif ( $script eq "calc_bit_scores" ) { script_calc_bit_scores( $in, $out, $options ) } elsif ( $script eq "calc_fixedstep" ) { script_calc_fixedstep( $in, $out, $options ) } - elsif ( $script eq "reverse_seq" ) { script_reverse_seq( $in, $out, $options ) } - elsif ( $script eq "complement_seq" ) { script_complement_seq( $in, $out, $options ) } elsif ( $script eq "remove_indels" ) { script_remove_indels( $in, $out, $options ) } elsif ( $script eq "transliterate_seq" ) { script_transliterate_seq( $in, $out, $options ) } elsif ( $script eq "transliterate_vals" ) { script_transliterate_vals( $in, $out, $options ) } @@ -2193,65 +2191,6 @@ sub script_calc_fixedstep } -sub script_reverse_seq -{ - # Martin A. Hansen, August 2007. - - # Reverse sequence in record. - - my ( $in, # handle to in stream - $out, # handle to out stream - ) = @_; - - # Returns nothing. - - my ( $record ); - - while ( $record = Maasha::Biopieces::get_record( $in ) ) - { - if ( $record->{ "SEQ" } ) { - $record->{ "SEQ" } = reverse $record->{ "SEQ" }; - } - - Maasha::Biopieces::put_record( $record, $out ); - } -} - - -sub script_complement_seq -{ - # Martin A. Hansen, August 2007. - - # Complement sequence in record. - - my ( $in, # handle to in stream - $out, # handle to out stream - ) = @_; - - # Returns nothing. - - my ( $record, $type ); - - while ( $record = Maasha::Biopieces::get_record( $in ) ) - { - if ( $record->{ "SEQ" } ) - { - if ( not $type ) { - $type = Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ); - } - - if ( $type eq "rna" ) { - Maasha::Seq::rna_comp( \$record->{ "SEQ" } ); - } elsif ( $type eq "dna" ) { - Maasha::Seq::dna_comp( \$record->{ "SEQ" } ); - } - } - - Maasha::Biopieces::put_record( $record, $out ); - } -} - - sub script_remove_indels { # Martin A. Hansen, August 2007. -- 2.39.5