-#!/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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# Merge values of keys in a record.
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
-use warnings;
use strict;
+use Maasha::Biopieces;
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+my ( $run_time_beg, $run_time_end, $options, $in, $out, $record, @join, $i );
+
+$options = Maasha::Biopieces::parse_options(
+ [
+ { long => 'keys', short => 'k', type => 'list', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
+ { long => 'delimit', short => 'd', type => 'string', mandatory => 'no', default => '_', 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 ( exists $record->{ $options->{ "keys" }->[ 0 ] } )
+ {
+ @join = $record->{ $options->{ "keys" }->[ 0 ] };
+
+ for ( $i = 1; $i < @{ $options->{ "keys" } }; $i++ ) {
+ push @join, $record->{ $options->{ "keys" }->[ $i ] } if exists $record->{ $options->{ "keys" }->[ $i ] };
+ }
+
+ $record->{ $options->{ "keys" }->[ 0 ] } = join $options->{ "delimit" }, @join;
+ }
+
+ 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;
-#!/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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# Translate peptide sequences in the stream.
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
-use warnings;
use strict;
+use Maasha::Biopieces;
+use Maasha::Seq;
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+my ( $run_time_beg, $run_time_end, $options, $in, $out, $record, $frame, %new_record );
+
+$options = Maasha::Biopieces::parse_options(
+ [
+ { long => 'frames', short => 'f', type => 'list', mandatory => 'no', default => '1,2,3,-1,-2,-3', allowed => '1,2,3,-1,-2,-3', 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" } )
+ {
+ if ( Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ) eq "dna" )
+ {
+ foreach $frame ( @{ $options->{ "frames" } } )
+ {
+ %new_record = %{ $record };
+
+ $new_record{ "SEQ" } = Maasha::Seq::translate( $record->{ "SEQ" }, $frame );
+ $new_record{ "SEQ_LEN" } = length $new_record{ "SEQ" };
+ $new_record{ "FRAME" } = $frame;
+
+ Maasha::Biopieces::put_record( \%new_record, $out );
+ }
+ }
+ }
+ else
+ {
+ 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;
-#!/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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# Transliterate chars from sequences in stream.
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
-use warnings;
use strict;
+use Maasha::Biopieces;
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+my ( $run_time_beg, $run_time_end, $options, $in, $out, $record, $search, $replace, $delete );
+
+$options = Maasha::Biopieces::parse_options(
+ [
+ { long => 'search', short => 's', type => 'string', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ { long => 'replace', short => 'r', type => 'string', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ { long => 'delete', short => 'd', type => 'string', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ ]
+);
+
+$in = Maasha::Biopieces::read_stream( $options->{ "stream_in" } );
+$out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } );
+
+$search = $options->{ "search" } || "";
+$replace = $options->{ "replace" } || "";
+$delete = $options->{ "delete" } || "";
+
+while ( $record = Maasha::Biopieces::get_record( $in ) )
+{
+ if ( $record->{ "SEQ" } )
+ {
+ if ( $search and $replace ) {
+ eval "\$record->{ 'SEQ' } =~ tr/$search/$replace/";
+ } elsif ( $delete ) {
+ eval "\$record->{ 'SEQ' } =~ tr/$delete//d";
+ }
+ }
+
+ 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;
-#!/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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# Transliterate chars from values in stream.
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
-use warnings;
use strict;
+use Maasha::Biopieces;
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+my ( $run_time_beg, $run_time_end, $options, $in, $out, $record, $search, $replace, $delete, $key );
+
+$options = Maasha::Biopieces::parse_options(
+ [
+ { long => 'keys', short => 'k', type => 'list', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ { long => 'search', short => 's', type => 'string', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ { long => 'replace', short => 'r', type => 'string', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ { long => 'delete', short => 'd', type => 'string', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ ]
+);
+
+$in = Maasha::Biopieces::read_stream( $options->{ "stream_in" } );
+$out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } );
+
+$search = $options->{ "search" } || "";
+$replace = $options->{ "replace" } || "";
+$delete = $options->{ "delete" } || "";
+
+while ( $record = Maasha::Biopieces::get_record( $in ) )
+{
+ foreach $key ( @{ $options->{ "keys" } } )
+ {
+ if ( exists $record->{ $key } )
+ {
+ if ( $search and $replace ) {
+ eval "\$record->{ $key } =~ tr/$search/$replace/";
+ } elsif ( $delete ) {
+ eval "\$record->{ $key } =~ tr/$delete//d";
+ }
+ }
+ }
+
+ 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 "complexity_seq" ) { script_complexity_seq( $in, $out, $options ) }
elsif ( $script eq "oligo_freq" ) { script_oligo_freq( $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 ) }
- 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 "tile_seq" ) { script_tile_seq( $in, $out, $options ) }
elsif ( $script eq "remove_ucsc_tracks" ) { script_remove_ucsc_tracks( $in, $out, $options ) }
elsif ( $script eq "rename_keys" ) { script_rename_keys( $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 "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 ) }
all|a
);
}
- elsif ( $script eq "transliterate_seq" )
- {
- @options = qw(
- search|s=s
- replace|r=s
- delete|d=s
- );
- }
- elsif ( $script eq "transliterate_vals" )
- {
- @options = qw(
- keys|k=s
- search|s=s
- replace|r=s
- delete|d=s
- );
- }
- elsif ( $script eq "translate_seq" )
- {
- @options = qw(
- frames|f=s
- );
- }
elsif ( $script eq "get_genome_align" )
{
@options = qw(
invert|i
);
}
- elsif ( $script eq "merge_vals" )
- {
- @options = qw(
- keys|k=s
- delimit|d=s
- );
- }
elsif ( $script eq "sort_records" )
{
@options = qw(
}
-sub script_transliterate_seq
-{
- # Martin A. Hansen, August 2007.
-
- # Transliterate chars from sequence in record.
-
- my ( $in, # handle to in stream
- $out, # handle to out stream
- $options, # options hash
- ) = @_;
-
- # Returns nothing.
-
- my ( $record, $search, $replace, $delete );
-
- $search = $options->{ "search" } || "";
- $replace = $options->{ "replace" } || "";
- $delete = $options->{ "delete" } || "";
-
- while ( $record = Maasha::Biopieces::get_record( $in ) )
- {
- if ( $record->{ "SEQ" } )
- {
- if ( $search and $replace ) {
- eval "\$record->{ 'SEQ' } =~ tr/$search/$replace/";
- } elsif ( $delete ) {
- eval "\$record->{ 'SEQ' } =~ tr/$delete//d";
- }
- }
-
- Maasha::Biopieces::put_record( $record, $out );
- }
-}
-
-
-sub script_transliterate_vals
-{
- # Martin A. Hansen, April 2008.
-
- # Transliterate chars from values in record.
-
- my ( $in, # handle to in stream
- $out, # handle to out stream
- $options, # options hash
- ) = @_;
-
- # Returns nothing.
-
- my ( $record, $search, $replace, $delete, $key );
-
- $search = $options->{ "search" } || "";
- $replace = $options->{ "replace" } || "";
- $delete = $options->{ "delete" } || "";
-
- while ( $record = Maasha::Biopieces::get_record( $in ) )
- {
- foreach $key ( @{ $options->{ "keys" } } )
- {
- if ( exists $record->{ $key } )
- {
- if ( $search and $replace ) {
- eval "\$record->{ $key } =~ tr/$search/$replace/";
- } elsif ( $delete ) {
- eval "\$record->{ $key } =~ tr/$delete//d";
- }
- }
- }
-
- Maasha::Biopieces::put_record( $record, $out );
- }
-}
-
-
-sub script_translate_seq
-{
- # Martin A. Hansen, February 2008.
-
- # Translate DNA sequence into protein sequence.
-
- my ( $in, # handle to in stream
- $out, # handle to out stream
- $options, # options hash
- ) = @_;
-
- # Returns nothing.
-
- my ( $record, $frame, %new_record );
-
- $options->{ "frames" } ||= [ 1, 2, 3, -1, -2, -3 ];
-
- while ( $record = Maasha::Biopieces::get_record( $in ) )
- {
- if ( $record->{ "SEQ" } )
- {
- if ( Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ) eq "dna" )
- {
- foreach $frame ( @{ $options->{ "frames" } } )
- {
- %new_record = %{ $record };
-
- $new_record{ "SEQ" } = Maasha::Seq::translate( $record->{ "SEQ" }, $frame );
- $new_record{ "SEQ_LEN" } = length $new_record{ "SEQ" };
- $new_record{ "FRAME" } = $frame;
-
- Maasha::Biopieces::put_record( \%new_record, $out );
- }
- }
- }
- else
- {
- Maasha::Biopieces::put_record( $record, $out );
- }
- }
-}
-
-
sub script_get_genome_align
{
# Martin A. Hansen, April 2008.
}
-sub script_merge_vals
-{
- # Martin A. Hansen, August 2007.
-
- # Rename keys in stream.
-
- my ( $in, # handle to in stream
- $out, # handle to out stream
- $options, # options hash
- ) = @_;
-
- # Returns nothing.
-
- my ( $record, @join, $i );
-
- $options->{ "delimit" } ||= '_';
-
- while ( $record = Maasha::Biopieces::get_record( $in ) )
- {
- if ( exists $record->{ $options->{ "keys" }->[ 0 ] } )
- {
- @join = $record->{ $options->{ "keys" }->[ 0 ] };
-
- for ( $i = 1; $i < @{ $options->{ "keys" } }; $i++ ) {
- push @join, $record->{ $options->{ "keys" }->[ $i ] } if exists $record->{ $options->{ "keys" }->[ $i ] };
- }
-
- $record->{ $options->{ "keys" }->[ 0 ] } = join $options->{ "delimit" }, @join;
- }
-
- Maasha::Biopieces::put_record( $record, $out );
- }
-}
-
-
sub script_sort_records
{
# Martin A. Hansen, August 2007.