]> git.donarmstrong.com Git - biopieces.git/commitdiff
migrated add_ident
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Sun, 24 May 2009 09:56:12 +0000 (09:56 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Sun, 24 May 2009 09:56:12 +0000 (09:56 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@390 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/add_ident
code_perl/Maasha/BioRun.pm

index fdf5bd287f78613d2aea83bb9b15f855cad57e77..26497ef0c57afaf781a40cf210473f5fac5671fc 100755 (executable)
@@ -1,6 +1,89 @@
-#!/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;
index ecf32f239eeb714f125983b859fd20b63209073f..ebbd3c53578deafe5451648d72596112021a580f 100644 (file)
@@ -133,7 +133,6 @@ sub run_script
     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 ) }
@@ -176,7 +175,6 @@ sub run_script
     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 ) }
@@ -660,13 +658,6 @@ sub get_options
             eval|e=s
         );
     }
-    elsif ( $script eq "add_ident" )
-    {
-        @options = qw(
-            prefix|p=s
-            key|k=s
-        );
-    }
     elsif ( $script eq "count_records" )
     {
         @options = qw(
@@ -1845,29 +1836,6 @@ sub script_length_seq
 }
 
 
-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.
@@ -4147,37 +4115,6 @@ sub script_flip_tab
 }
 
 
-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.