]> git.donarmstrong.com Git - biopieces.git/commitdiff
added 3 more
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 27 May 2009 03:52:20 +0000 (03:52 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 27 May 2009 03:52:20 +0000 (03:52 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@421 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/invert_align
bp_bin/length_seq
bp_bin/length_vals
code_perl/Maasha/BioRun.pm

index fdf5bd287f78613d2aea83bb9b15f855cad57e77..413ab29f9d7d949b8194cf5b9aac51ce3ccdf03a 100755 (executable)
@@ -1,6 +1,96 @@
-#!/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;
index fdf5bd287f78613d2aea83bb9b15f855cad57e77..2ca4b0f950ae56029513bb090cf8c9d2ecf75a11 100755 (executable)
@@ -1,6 +1,88 @@
-#!/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;
index fdf5bd287f78613d2aea83bb9b15f855cad57e77..8bcb33ea968645e158e30760b077b86af9b08082 100755 (executable)
@@ -1,6 +1,86 @@
-#!/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;
index d79617c95e4e9f6dd32e41ffa281fab2ba29bb08..be8d8827ea92195fd84d88108e3387a0219f3710 100644 (file)
@@ -130,7 +130,6 @@ sub run_script
     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 ) }
@@ -141,7 +140,6 @@ sub run_script
     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 ) }
@@ -167,7 +165,6 @@ sub run_script
     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 ) }
@@ -317,13 +314,6 @@ sub get_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(
@@ -383,12 +373,6 @@ sub get_options
             supress_indels|s
         );
     }
-    elsif ( $script eq "invert_align" )
-    {
-        @options = qw(
-            soft|s
-        );
-    }
     elsif ( $script eq "patscan_seq" )
     {
         @options = qw(
@@ -620,12 +604,6 @@ sub get_options
             direction|d=s
         );
     }
-    elsif ( $script eq "length_vals" )
-    {
-        @options = qw(
-            keys|k=s
-        );
-    }
     elsif ( $script eq "sum_vals" )
     {
         @options = qw(
@@ -791,7 +769,7 @@ sub get_options
     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" )
     {
@@ -1620,36 +1598,6 @@ sub script_read_ucsc_config
 }
 
 
-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.
@@ -2054,40 +2002,6 @@ sub script_tile_seq
 }
 
 
-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.
@@ -3387,35 +3301,6 @@ sub script_plot_matches
 }
 
 
-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.