-#!/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__
-#!/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__
-#!/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;
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 ) }
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 ) }
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 ) }
ylabel|Y=s
);
}
- elsif ( $script eq "head_records" )
- {
- @options = qw(
- num|n=s
- );
- }
elsif ( $script eq "remove_keys" )
{
@options = qw(
}
-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.
}
-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.
}
-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.