]> git.donarmstrong.com Git - biopieces.git/commitdiff
added tests for mean_vals
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 15 Oct 2010 10:04:59 +0000 (10:04 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 15 Oct 2010 10:04:59 +0000 (10:04 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1138 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/mean_vals
bp_bin/median_vals
bp_test/in/mean_vals.in [new file with mode: 0644]
bp_test/out/mean_vals.out.1 [new file with mode: 0644]
bp_test/out/mean_vals.out.2 [new file with mode: 0644]
bp_test/test/test_mean_vals [new file with mode: 0755]

index 007b287ab0bb7c56385627bc55d02b860fb0377e..974c9b4de1a53b64cbe46538f9c820f4ceab97ef 100755 (executable)
@@ -86,7 +86,7 @@ foreach $key ( @{ $options->{ "keys" } } )
     $new_record->{ $key . "_MEAN" } = $mean
 }
 
-if ( $options->{ "keys" } )
+if ( $options->{ "keys" } and $new_record )
 {
     $new_record->{ 'REC_TYPE' } = "MEAN";
 
index 36bfff5907bab1855a39a968a5508ce2f9fa8ab2..b999665e57d23b216dc813b77acc22272f783846 100755 (executable)
@@ -35,7 +35,7 @@ use Maasha::Calc;
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
-my ( $options, $in, $out, $record, $key, %median_hash, $median, $fh );
+my ( $options, $in, $out, $record, $new_record, $key, %median_hash, $median, $fh );
 
 $options = Maasha::Biopieces::parse_options(
     [
@@ -65,6 +65,9 @@ while ( $record = Maasha::Biopieces::get_record( $in ) )
     Maasha::Biopieces::put_record( $record, $out ) if not $options->{ "no_stream" };
 }
 
+Maasha::Biopieces::close_stream( $in );
+Maasha::Biopieces::close_stream( $out );
+
 $fh = Maasha::Biopieces::write_stream( $options->{ "data_out" } );
 
 foreach $key ( @{ $options->{ "keys" } } )
@@ -75,13 +78,17 @@ foreach $key ( @{ $options->{ "keys" } } )
         $median = "N/A";
     }
 
-    Maasha::Biopieces::put_record( { $key . "_MEDIAN" => $median } , $fh );
+    $new_record->{ $key . "_MEDIAN" } = $mean
 }
 
-close $fh;
+if ( $options->{ "keys" } )
+{
+    $new_record->{ 'REC_TYPE' } = "MEDIAN";
 
-Maasha::Biopieces::close_stream( $in );
-Maasha::Biopieces::close_stream( $out );
+    Maasha::Biopieces::put_record( $new_record, $fh );
+}
+
+close $fh;
 
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
diff --git a/bp_test/in/mean_vals.in b/bp_test/in/mean_vals.in
new file mode 100644 (file)
index 0000000..401f694
--- /dev/null
@@ -0,0 +1,15 @@
+V3: 0;1;2;3;4;5
+V0: Human
+V2: 78
+V1: 123
+---
+V3: 6;7;8
+V0: Dog
+V2: 81
+V1: 45
+---
+V3: 9
+V0: Mouse
+V2: 5
+V1: 6
+---
diff --git a/bp_test/out/mean_vals.out.1 b/bp_test/out/mean_vals.out.1
new file mode 100644 (file)
index 0000000..a10166e
--- /dev/null
@@ -0,0 +1,4 @@
+V1_MEAN: 58.00
+REC_TYPE: MEAN
+V2_MEAN: 54.67
+---
diff --git a/bp_test/out/mean_vals.out.2 b/bp_test/out/mean_vals.out.2
new file mode 100644 (file)
index 0000000..001cc5c
--- /dev/null
@@ -0,0 +1,18 @@
+V3_MEAN: 2.50
+V3: 0;1;2;3;4;5
+V0: Human
+V2: 78
+V1: 123
+---
+V3_MEAN: 7.00
+V3: 6;7;8
+V0: Dog
+V2: 81
+V1: 45
+---
+V3_MEAN: 9.00
+V3: 9
+V0: Mouse
+V2: 5
+V1: 6
+---
diff --git a/bp_test/test/test_mean_vals b/bp_test/test/test_mean_vals
new file mode 100755 (executable)
index 0000000..5fabaa4
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+source "$BP_DIR/bp_test/lib/test.sh"
+
+run "$bp -I $in -k V1,V2 -o $tmp -x"
+assert_no_diff $tmp $out.1
+clean
+
+run "$bp -I $in -l V3 -O $tmp"
+assert_no_diff $tmp $out.2
+clean