-#!/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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# Inverts an alignment showing only non-mathing residues using the first sequence as reference.
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
-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 );
+
+$options = Maasha::Biopieces::parse_options(
+ [
+ { long => 'soft', short => 's', type => 'flag', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ ]
+);
+
+$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" } ];
+ }
+ else
+ {
+ Maasha::Biopieces::put_record( $record, $out );
+ }
+}
+
+Maasha::Align::align_invert( \@entries, $options->{ "soft" } );
+
+map { Maasha::Biopieces::put_record( { SEQ_NAME => $_->[ SEQ_NAME ], SEQ => $_->[ SEQ ] }, $out ) } @entries;
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+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;
-#!/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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# Determines the length of all sequences in the stream as well as a total length.
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
-use warnings;
use strict;
+use Maasha::Biopieces;
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+my ( $run_time_beg, $run_time_end, $options, $in, $out, $record, $total );
+
+$options = Maasha::Biopieces::parse_options(
+ [
+ { long => 'no_stream', short => 'x', type => 'flag', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ { long => 'data_out', short => 'o', type => 'file', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ ]
+);
+
+$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" } )
+ {
+ $record->{ "SEQ_LEN" } = length $record->{ "SEQ" };
+ $total += $record->{ "SEQ_LEN" };
+ }
+
+ Maasha::Biopieces::put_record( $record, $out ) if not $options->{ "no_stream" };
+}
+
+Maasha::Biopieces::put_record( { TOTAL_SEQ_LEN => $total }, $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;
-#!/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 the length of values in the stream for given keys.
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
-use warnings;
use strict;
+use Maasha::Biopieces;
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+my ( $run_time_beg, $run_time_end, $options, $in, $out, $record, $key );
+
+$options = Maasha::Biopieces::parse_options(
+ [
+ { long => 'keys', short => 'k', type => 'list', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
+ ]
+);
+
+$in = Maasha::Biopieces::read_stream( $options->{ "stream_in" } );
+$out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } );
+
+while ( $record = Maasha::Biopieces::get_record( $in ) )
+{
+ foreach $key ( @{ $options->{ "keys" } } )
+ {
+ if ( $record->{ $key } ) {
+ $record->{ $key . "_LEN" } = length $record->{ $key };
+ }
+ }
+
+ 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;
elsif ( $script eq "read_solid" ) { script_read_solid( $in, $out, $options ) }
elsif ( $script eq "read_mysql" ) { script_read_mysql( $in, $out, $options ) }
elsif ( $script eq "read_ucsc_config" ) { script_read_ucsc_config( $in, $out, $options ) }
- elsif ( $script eq "length_seq" ) { script_length_seq( $in, $out, $options ) }
elsif ( $script eq "uppercase_seq" ) { script_uppercase_seq( $in, $out, $options ) }
elsif ( $script eq "complexity_seq" ) { script_complexity_seq( $in, $out, $options ) }
elsif ( $script eq "oligo_freq" ) { script_oligo_freq( $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 "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 "soap_seq" ) { script_soap_seq( $in, $out, $options ) }
elsif ( $script eq "match_seq" ) { script_match_seq( $in, $out, $options ) }
elsif ( $script eq "plot_matches" ) { script_plot_matches( $in, $out, $options ) }
elsif ( $script eq "plot_seqlogo" ) { script_plot_seqlogo( $in, $out, $options ) }
elsif ( $script eq "plot_phastcons_profiles" ) { script_plot_phastcons_profiles( $in, $out, $options ) }
- elsif ( $script eq "length_vals" ) { script_length_vals( $in, $out, $options ) }
elsif ( $script eq "sum_vals" ) { script_sum_vals( $in, $out, $options ) }
elsif ( $script eq "mean_vals" ) { script_mean_vals( $in, $out, $options ) }
elsif ( $script eq "median_vals" ) { script_median_vals( $in, $out, $options ) }
num|n=s
);
}
- elsif ( $script eq "length_seq" )
- {
- @options = qw(
- no_stream|x
- data_out|o=s
- );
- }
elsif ( $script eq "oligo_freq" )
{
@options = qw(
supress_indels|s
);
}
- elsif ( $script eq "invert_align" )
- {
- @options = qw(
- soft|s
- );
- }
elsif ( $script eq "patscan_seq" )
{
@options = qw(
direction|d=s
);
}
- elsif ( $script eq "length_vals" )
- {
- @options = qw(
- keys|k=s
- );
- }
elsif ( $script eq "sum_vals" )
{
@options = qw(
Maasha::Common::error( qq(both --in_file and --genome specified) ) if $script eq "soap_seq" and $options{ "genome" } and $options{ "in_file" };
Maasha::Common::error( qq(no --genome specified) ) if $script =~ /get_genome_align|get_genome_phastcons|plot_phastcons_profiles|plot_karyogram/ and not $options{ "genome" };
Maasha::Common::error( qq(no --key specified) ) if $script =~ /plot_lendist|plot_histogram/ and not $options{ "key" };
- Maasha::Common::error( qq(no --keys speficied) ) if $script =~ /sort_records|sum_vals|mean_vals|median_vals|length_vals/ and not $options{ "keys" };
+ Maasha::Common::error( qq(no --keys speficied) ) if $script =~ /sort_records|sum_vals|mean_vals|median_vals/ and not $options{ "keys" };
if ( $script eq "upload_to_ucsc" )
{
}
-sub script_length_seq
-{
- # Martin A. Hansen, August 2007.
-
- # Determine the length of sequences in stream.
-
- my ( $in, # handle to in stream
- $out, # handle to out stream
- $options, # options hash
- ) = @_;
-
- # Returns nothing.
-
- my ( $record, $total );
-
- while ( $record = Maasha::Biopieces::get_record( $in ) )
- {
- if ( $record->{ "SEQ" } )
- {
- $record->{ "SEQ_LEN" } = length $record->{ "SEQ" };
- $total += $record->{ "SEQ_LEN" };
- }
-
- Maasha::Biopieces::put_record( $record, $out ) if not $options->{ "no_stream" };
- }
-
- Maasha::Biopieces::put_record( { TOTAL_SEQ_LEN => $total }, $out );
-}
-
-
sub script_complexity_seq
{
# Martin A. Hansen, May 2008.
}
-sub script_invert_align
-{
- # Martin A. Hansen, February 2008.
-
- # Inverts an alignment showing only non-mathing residues
- # using the first sequence as reference.
-
- my ( $in, # handle to in stream
- $out, # handle to out stream
- $options, # options hash
- ) = @_;
-
- # Returns nothing.
-
- my ( $record, @entries );
-
- while ( $record = Maasha::Biopieces::get_record( $in ) )
- {
- if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } )
- {
- push @entries, [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ];
- }
- else
- {
- Maasha::Biopieces::put_record( $record, $out );
- }
- }
-
- Maasha::Align::align_invert( \@entries, $options->{ "soft" } );
-
- map { Maasha::Biopieces::put_record( { SEQ_NAME => $_->[ SEQ_NAME ], SEQ => $_->[ SEQ ] }, $out ) } @entries;
-}
-
-
sub script_patscan_seq
{
# Martin A. Hansen, August 2007.
}
-sub script_length_vals
-{
- # Martin A. Hansen, August 2007.
-
- # Determine the length of the value for given keys.
-
- my ( $in, # handle to in stream
- $out, # handle to out stream
- $options, # options hash
- ) = @_;
-
- # Returns nothing.
-
- my ( $record, $key );
-
- while ( $record = Maasha::Biopieces::get_record( $in ) )
- {
- foreach $key ( @{ $options->{ "keys" } } )
- {
- if ( $record->{ $key } ) {
- $record->{ $key . "_LEN" } = length $record->{ $key };
- }
- }
-
- Maasha::Biopieces::put_record( $record, $out );
- }
-}
-
-
sub script_sum_vals
{
# Martin A. Hansen, August 2007.