]> git.donarmstrong.com Git - biopieces.git/commitdiff
added list switch to *_vals biopieces
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 17 Jun 2010 12:22:58 +0000 (12:22 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 17 Jun 2010 12:22:58 +0000 (12:22 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@990 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/max_vals
bp_bin/mean_vals
bp_bin/median_vals
bp_bin/min_vals

index 4cb794b8019cca8d487004a8a623dd3256ea75ca..d25bee4d4c9ec6fe9ed3587fc8cf5a73885fbd2f 100755 (executable)
@@ -29,6 +29,7 @@
 use warnings;
 use strict;
 use Maasha::Biopieces;
+use Maasha::Calc;
 
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@@ -38,12 +39,16 @@ my ( $options, $in, $out, $record, $key, $fh, %max_hash, $max_record );
 
 $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 },
-        { long => 'keys',      short => 'k', type => 'list', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
+        { 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 },
+        { long => 'keys',      short => 'k', type => 'list',   mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+        { long => 'list',      short => 'l', type => 'string', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
     ]   
 );
 
+Maasha::Common::error( qq(both --keys and --list specified) ) if     $options->{ "keys" } and     $options->{ "list" };
+Maasha::Common::error( qq(no --keys or --list specified) )    if not $options->{ "keys" } and not $options->{ "list" };
+
 $in  = Maasha::Biopieces::read_stream( $options->{ "stream_in" } );
 $out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } );
 
@@ -61,6 +66,11 @@ while ( $record = Maasha::Biopieces::get_record( $in ) )
         }
     }
 
+    if ( $options->{ 'list' } and $record->{ $options->{ 'list' } } ) {
+        $record->{ $options->{ 'list' } . "_MAX" } = sprintf( "%.2f", Maasha::Calc::list_max( [ split ";", $record->{ $options->{ 'list' } } ] ) );
+    }
+
+
     Maasha::Biopieces::put_record( $record, $out ) if not $options->{ "no_stream" };
 }
 
index 44ce791e58eade41bb2f9ed04e1f4a127bcda9a0..583ec4effa8bccff8972a8bd52e46e87c7fdd23d 100755 (executable)
@@ -63,8 +63,7 @@ while ( $record = Maasha::Biopieces::get_record( $in ) )
         }
     }
 
-    if ( $options->{ 'list' } and $record->{ $options->{ 'list' } } )
-    {
+    if ( $options->{ 'list' } and $record->{ $options->{ 'list' } } ) {
         $record->{ $options->{ 'list' } . "_MEAN" } = sprintf( "%.2f", Maasha::Calc::mean( [ split ";", $record->{ $options->{ 'list' } } ] ) );
     }
 
index 91cdd36d8b895b03219063f8aa6abd763e8e671b..36bfff5907bab1855a39a968a5508ce2f9fa8ab2 100755 (executable)
@@ -39,12 +39,16 @@ my ( $options, $in, $out, $record, $key, %median_hash, $median, $fh );
 
 $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 },
-        { long => 'keys',      short => 'k', type => 'list', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
+        { 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 },
+        { long => 'keys',      short => 'k', type => 'list',   mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+        { long => 'list',      short => 'l', type => 'string', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
     ]   
 );
 
+Maasha::Common::error( qq(both --keys and --list specified) ) if     $options->{ "keys" } and     $options->{ "list" };
+Maasha::Common::error( qq(no --keys or --list specified) )    if not $options->{ "keys" } and not $options->{ "list" };
+
 $in  = Maasha::Biopieces::read_stream( $options->{ "stream_in" } );
 $out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } );
 
@@ -54,6 +58,10 @@ while ( $record = Maasha::Biopieces::get_record( $in ) )
         push @{ $median_hash{ $key } }, $record->{ $key } if defined $record->{ $key };
     }
 
+    if ( $options->{ 'list' } and $record->{ $options->{ 'list' } } ) {
+        $record->{ $options->{ 'list' } . "_MEDIAN" } = sprintf( "%.2f", Maasha::Calc::median( [ split ";", $record->{ $options->{ 'list' } } ] ) );
+    }
+
     Maasha::Biopieces::put_record( $record, $out ) if not $options->{ "no_stream" };
 }
 
index bff25a7464286ddb6f9b8286e0a1e19c79c433db..1f73ed0fd46bbbfa80501c583dfbb7f609b7bab1 100755 (executable)
@@ -29,6 +29,7 @@
 use warnings;
 use strict;
 use Maasha::Biopieces;
+use Maasha::Calc;
 
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@@ -38,12 +39,16 @@ my ( $options, $in, $out, $record, $key, $fh, %min_hash, $min_record );
 
 $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 },
-        { long => 'keys',      short => 'k', type => 'list', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
+        { 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 },
+        { long => 'keys',      short => 'k', type => 'list',   mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+        { long => 'list',      short => 'l', type => 'string', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
     ]   
 );
 
+Maasha::Common::error( qq(both --keys and --list specified) ) if     $options->{ "keys" } and     $options->{ "list" };
+Maasha::Common::error( qq(no --keys or --list specified) )    if not $options->{ "keys" } and not $options->{ "list" };
+
 $in  = Maasha::Biopieces::read_stream( $options->{ "stream_in" } );
 $out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } );
 
@@ -61,6 +66,10 @@ while ( $record = Maasha::Biopieces::get_record( $in ) )
         }
     }
 
+    if ( $options->{ 'list' } and $record->{ $options->{ 'list' } } ) {
+        $record->{ $options->{ 'list' } . "_MIN" } = sprintf( "%.2f", Maasha::Calc::list_min( [ split ";", $record->{ $options->{ 'list' } } ] ) );
+    }
+
     Maasha::Biopieces::put_record( $record, $out ) if not $options->{ "no_stream" };
 }