-#!/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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# Add a unique identifier to each record in the stream.
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
-use warnings;
use strict;
+use Maasha::Biopieces;
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+my ( $run_time_beg, $run_time_end, $options, $in, $out, $record, $key, $prefix, $i );
+
+$options = Maasha::Biopieces::parse_options(
+ [
+ { long => 'key', short => 'k', type => 'string', mandatory => 'no', default => 'ID', allowed => undef, disallowed => undef },
+ { long => 'prefix', short => 'p', type => 'string', mandatory => 'no', default => 'ID', allowed => undef, disallowed => undef },
+ ]
+);
+
+$in = Maasha::Biopieces::read_stream( $options->{ "stream_in" } );
+$out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } );
+
+$key = $options->{ "key" };
+$prefix = $options->{ "prefix" };
+
+$i = 0;
+
+while ( $record = Maasha::Biopieces::get_record( $in ) )
+{
+ $record->{ $key } = sprintf( "$prefix%08d", $i );
+
+ Maasha::Biopieces::put_record( $record, $out );
+
+ $i++;
+}
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+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 "assemble_tag_contigs" ) { script_assemble_tag_contigs( $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 "shuffle_seq" ) { script_shuffle_seq( $in, $out, $options ) }
elsif ( $script eq "analyze_seq" ) { script_analyze_seq( $in, $out, $options ) }
elsif ( $script eq "analyze_tags" ) { script_analyze_tags( $in, $out, $options ) }
elsif ( $script eq "complexity_seq" ) { script_complexity_seq( $in, $out, $options ) }
elsif ( $script eq "merge_records" ) { script_merge_records( $in, $out, $options ) }
elsif ( $script eq "compute" ) { script_compute( $in, $out, $options ) }
elsif ( $script eq "flip_tab" ) { script_flip_tab( $in, $out, $options ) }
- elsif ( $script eq "add_ident" ) { script_add_ident( $in, $out, $options ) }
elsif ( $script eq "count_records" ) { script_count_records( $in, $out, $options ) }
elsif ( $script eq "random_records" ) { script_random_records( $in, $out, $options ) }
elsif ( $script eq "sort_records" ) { script_sort_records( $in, $out, $options ) }
eval|e=s
);
}
- elsif ( $script eq "add_ident" )
- {
- @options = qw(
- prefix|p=s
- key|k=s
- );
- }
elsif ( $script eq "count_records" )
{
@options = qw(
}
-sub script_shuffle_seq
-{
- # Martin A. Hansen, December 2007.
-
- # Shuffle sequences in stream.
-
- my ( $in, # handle to in stream
- $out, # handle to out stream
- ) = @_;
-
- # Returns nothing.
-
- my ( $record );
-
- while ( $record = Maasha::Biopieces::get_record( $in ) )
- {
- $record->{ "SEQ" } = Maasha::Seq::seq_shuffle( $record->{ "SEQ" } ) if $record->{ "SEQ" };
-
- Maasha::Biopieces::put_record( $record, $out );
- }
-}
-
-
sub script_analyze_seq
{
# Martin A. Hansen, August 2007.
}
-sub script_add_ident
-{
- # Martin A. Hansen, May 2008.
-
- # Add a unique identifier to each record in stream.
-
- my ( $in, # handle to in stream
- $out, # handle to out stream
- $options, # options hash
- ) = @_;
-
- # Returns nothing.
-
- my ( $record, $key, $prefix, $i );
-
- $key = $options->{ "key" } || "ID";
- $prefix = $options->{ "prefix" } || "ID";
-
- $i = 0;
-
- while ( $record = Maasha::Biopieces::get_record( $in ) )
- {
- $record->{ $key } = sprintf( "$prefix%08d", $i );
-
- Maasha::Biopieces::put_record( $record, $out );
-
- $i++;
- }
-}
-
-
sub script_count_records
{
# Martin A. Hansen, August 2007.