From: martinahansen Date: Tue, 26 May 2009 17:41:50 +0000 (+0000) Subject: migrated 3 biopieces X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=5a59ed9dbeb22cb93a18a6c08cfb6815d4ee9dc1;p=biopieces.git migrated 3 biopieces git-svn-id: http://biopieces.googlecode.com/svn/trunk@419 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/bp_bin/flip_tab b/bp_bin/flip_tab index fdf5bd2..489e2b7 100755 --- a/bp_bin/flip_tab +++ b/bp_bin/flip_tab @@ -1,6 +1,95 @@ -#!/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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +# Flip table records so rows becomes columns and visa versa. + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + -use warnings; use strict; +use Maasha::Biopieces; +use Maasha::Matrix; + + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + +my ( $run_time_beg, $run_time_end, $options, $in, $out, $record, $key, $A, $B, @rows, @matrix, $row, $i ); + +$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 ) ) +{ + undef @rows; + + foreach $key ( sort { $A = $a; $B = $b; $A =~ s/^V(\d+)$/$1/; $B =~ s/^V(\d+)$/$1/; $A <=> $B } keys %{ $record } ) + { + push @rows, $record->{ $key }; + + } + + push @matrix, [ @rows ]; +} + +undef $record; + +@matrix = Maasha::Matrix::matrix_flip( \@matrix ); + +foreach $row ( @matrix ) +{ + for ( $i = 0; $i < @{ $row }; $i++ ) { + $record->{ "V$i" } = $row->[ $i ]; + } + + 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/fold_seq b/bp_bin/fold_seq index fdf5bd2..cb14436 100755 --- a/bp_bin/fold_seq +++ b/bp_bin/fold_seq @@ -1,6 +1,90 @@ -#!/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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +# Fold sequences in stream. + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + -use warnings; use strict; +use Maasha::Biopieces; + + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + +my ( $run_time_beg, $run_time_end, $options, $in, $out, $record, $type, $struct, $index ); + +$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 ne "protein" ) + { + ( $struct, $index ) = Maasha::Seq::fold_struct_rnafold( $record->{ "SEQ" } ); + $record->{ "SEC_STRUCT" } = $struct; + $record->{ "FREE_ENERGY" } = $index; + $record->{ "SCORE" } = abs int $index; + $record->{ "SIZE" } = length $struct; + $record->{ "CONF" } = "1," x $record->{ "SIZE" }; + } + } + + 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/head_records b/bp_bin/head_records index fdf5bd2..bc26919 100755 --- a/bp_bin/head_records +++ b/bp_bin/head_records @@ -1,6 +1,85 @@ -#!/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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +# Emit the only the first number of records in the stream. + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + -use warnings; use strict; +use Maasha::Biopieces; + + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + +my ( $run_time_beg, $run_time_end, $options, $in, $out, $record, $count ); + +$options = Maasha::Biopieces::parse_options( + [ + { long => 'num', short => 'n', type => 'uint', mandatory => 'no', default => 10, allowed => undef, disallowed => 0 }, + ] +); + +$in = Maasha::Biopieces::read_stream( $options->{ "stream_in" } ); +$out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } ); + +$count = 0; + +while ( $record = Maasha::Biopieces::get_record( $in ) ) +{ + $count++; + + Maasha::Biopieces::put_record( $record, $out ); + + last if $count == $options->{ "num" }; +} + + +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + +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 d245f2b..d79617c 100644 --- a/code_perl/Maasha/BioRun.pm +++ b/code_perl/Maasha/BioRun.pm @@ -140,7 +140,6 @@ sub run_script elsif ( $script eq "translate_seq" ) { script_translate_seq( $in, $out, $options ) } elsif ( $script eq "get_genome_align" ) { script_get_genome_align( $in, $out, $options ) } elsif ( $script eq "get_genome_phastcons" ) { script_get_genome_phastcons( $in, $out, $options ) } - elsif ( $script eq "fold_seq" ) { script_fold_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 ) } @@ -152,7 +151,6 @@ sub run_script elsif ( $script eq "write_2bit" ) { script_write_2bit( $in, $out, $options ) } elsif ( $script eq "write_solid" ) { script_write_solid( $in, $out, $options ) } elsif ( $script eq "write_ucsc_config" ) { script_write_ucsc_config( $in, $out, $options ) } - elsif ( $script eq "head_records" ) { script_head_records( $in, $out, $options ) } elsif ( $script eq "remove_keys" ) { script_remove_keys( $in, $out, $options ) } elsif ( $script eq "remove_adaptor" ) { script_remove_adaptor( $in, $out, $options ) } elsif ( $script eq "remove_mysql_tables" ) { script_remove_mysql_tables( $in, $out, $options ) } @@ -161,7 +159,6 @@ sub run_script elsif ( $script eq "uniq_vals" ) { script_uniq_vals( $in, $out, $options ) } elsif ( $script eq "merge_vals" ) { script_merge_vals( $in, $out, $options ) } elsif ( $script eq "merge_records" ) { script_merge_records( $in, $out, $options ) } - elsif ( $script eq "flip_tab" ) { script_flip_tab( $in, $out, $options ) } elsif ( $script eq "sort_records" ) { script_sort_records( $in, $out, $options ) } elsif ( $script eq "plot_histogram" ) { script_plot_histogram( $in, $out, $options ) } elsif ( $script eq "plot_lendist" ) { script_plot_lendist( $in, $out, $options ) } @@ -493,12 +490,6 @@ sub get_options ylabel|Y=s ); } - elsif ( $script eq "head_records" ) - { - @options = qw( - num|n=s - ); - } elsif ( $script eq "remove_keys" ) { @options = qw( @@ -2018,44 +2009,6 @@ sub script_get_genome_phastcons } -sub script_fold_seq -{ - # Martin A. Hansen, December 2007. - - # Folds sequences in stream into secondary structures. - - my ( $in, # handle to in stream - $out, # handle to out stream - ) = @_; - - # Returns nothing. - - my ( $record, $type, $struct, $index ); - - while ( $record = Maasha::Biopieces::get_record( $in ) ) - { - if ( $record->{ "SEQ" } ) - { - if ( not $type ) { - $type = Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ); - } - - if ( $type ne "protein" ) - { - ( $struct, $index ) = Maasha::Seq::fold_struct_rnafold( $record->{ "SEQ" } ); - $record->{ "SEC_STRUCT" } = $struct; - $record->{ "FREE_ENERGY" } = $index; - $record->{ "SCORE" } = abs int $index; - $record->{ "SIZE" } = length $struct; - $record->{ "CONF" } = "1," x $record->{ "SIZE" }; - } - } - - Maasha::Biopieces::put_record( $record, $out ); - } -} - - sub script_tile_seq { # Martin A. Hansen, February 2008. @@ -2666,36 +2619,6 @@ sub script_plot_phastcons_profiles } -sub script_head_records -{ - # Martin A. Hansen, August 2007. - - # Display the first sequences in stream. - - my ( $in, # handle to in stream - $out, # handle to out stream - $options, # options hash - ) = @_; - - # Returns nothing. - - my ( $record, $count ); - - $options->{ "num" } ||= 10; - - $count = 0; - - while ( $record = Maasha::Biopieces::get_record( $in ) ) - { - $count++; - - Maasha::Biopieces::put_record( $record, $out ); - - last if $count == $options->{ "num" }; - } -} - - sub script_remove_keys { # Martin A. Hansen, August 2007. @@ -3194,49 +3117,6 @@ sub script_merge_records } -sub script_flip_tab -{ - # Martin A. Hansen, June 2008. - - # Flip a table. - - my ( $in, # handle to in stream - $out, # handle to out stream - $options, # options hash - ) = @_; - - # Returns nothing. - - my ( $record, $key, $A, $B, @rows, @matrix, $row, $i ); - - while ( $record = Maasha::Biopieces::get_record( $in ) ) - { - undef @rows; - - foreach $key ( sort { $A = $a; $B = $b; $A =~ s/^V(\d+)$/$1/; $B =~ s/^V(\d+)$/$1/; $A <=> $B } keys %{ $record } ) - { - push @rows, $record->{ $key }; - - } - - push @matrix, [ @rows ]; - } - - undef $record; - - @matrix = Maasha::Matrix::matrix_flip( \@matrix ); - - foreach $row ( @matrix ) - { - for ( $i = 0; $i < @{ $row }; $i++ ) { - $record->{ "V$i" } = $row->[ $i ]; - } - - Maasha::Biopieces::put_record( $record, $out ); - } -} - - sub script_sort_records { # Martin A. Hansen, August 2007.