]> git.donarmstrong.com Git - biopieces.git/commitdiff
polishing min max sum etc
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 15 Oct 2010 14:14:08 +0000 (14:14 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 15 Oct 2010 14:14:08 +0000 (14:14 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1142 74ccb610-7750-0410-82ae-013aeee3265d

15 files changed:
bp_bin/max_vals
bp_bin/median_vals
bp_bin/min_vals
bp_test/in/max_vals.in [new file with mode: 0644]
bp_test/in/median_vals.in [new file with mode: 0644]
bp_test/in/min_vals.in [new file with mode: 0644]
bp_test/out/max_vals.out.1 [new file with mode: 0644]
bp_test/out/max_vals.out.2 [new file with mode: 0644]
bp_test/out/median_vals.out.1 [new file with mode: 0644]
bp_test/out/median_vals.out.2 [new file with mode: 0644]
bp_test/out/min_vals.out.1 [new file with mode: 0644]
bp_test/out/min_vals.out.2 [new file with mode: 0644]
bp_test/test/test_max_vals [new file with mode: 0755]
bp_test/test/test_median_vals [new file with mode: 0755]
bp_test/test/test_min_vals [new file with mode: 0755]

index d25bee4d4c9ec6fe9ed3587fc8cf5a73885fbd2f..52ede7c4fd16f18c5e817d37f0c9e17602dc398e 100755 (executable)
@@ -35,7 +35,7 @@ use Maasha::Calc;
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
-my ( $options, $in, $out, $record, $key, $fh, %max_hash, $max_record );
+my ( $options, $in, $out, $record, $key, $fh, %max_hash, $new_record );
 
 $options = Maasha::Biopieces::parse_options(
     [
@@ -74,20 +74,24 @@ 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" } } )
-{
-    $max_record->{ $key . "_MAX" } = $max_hash{ $key };
+foreach $key ( @{ $options->{ "keys" } } ) {
+    $new_record->{ $key . "_MAX" } = $max_hash{ $key };
 }
 
-Maasha::Biopieces::put_record( $max_record, $fh );
+if ( $options->{ "keys" } and $new_record )
+{
+    $new_record->{ 'REC_TYPE' } = "MIN";
+
+    Maasha::Biopieces::put_record( $new_record, $fh );
+}
 
 close $fh;
 
-Maasha::Biopieces::close_stream( $in );
-Maasha::Biopieces::close_stream( $out );
-
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
index b999665e57d23b216dc813b77acc22272f783846..e32415ca05094bb872cf4d193c70fbae1e378a52 100755 (executable)
@@ -78,10 +78,10 @@ foreach $key ( @{ $options->{ "keys" } } )
         $median = "N/A";
     }
 
-    $new_record->{ $key . "_MEDIAN" } = $mean
+    $new_record->{ $key . "_MEDIAN" } = $median;
 }
 
-if ( $options->{ "keys" } )
+if ( $options->{ "keys" } and $new_record )
 {
     $new_record->{ 'REC_TYPE' } = "MEDIAN";
 
index 1f73ed0fd46bbbfa80501c583dfbb7f609b7bab1..11410e3f68d7f726351544c04981e2996f8d7157 100755 (executable)
@@ -35,7 +35,7 @@ use Maasha::Calc;
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
-my ( $options, $in, $out, $record, $key, $fh, %min_hash, $min_record );
+my ( $options, $in, $out, $record, $new_record, $key, $fh, %min_hash );
 
 $options = Maasha::Biopieces::parse_options(
     [
@@ -73,20 +73,24 @@ 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" } } )
-{
-    $min_record->{ $key . "_MIN" } = $min_hash{ $key };
+foreach $key ( @{ $options->{ "keys" } } ) {
+    $new_record->{ $key . "_MIN" } = $min_hash{ $key };
 }
 
-Maasha::Biopieces::put_record( $min_record, $fh );
+if ( $options->{ "keys" } and $new_record )
+{
+    $new_record->{ 'REC_TYPE' } = "MIN";
+
+    Maasha::Biopieces::put_record( $new_record, $fh );
+}
 
 close $fh;
 
-Maasha::Biopieces::close_stream( $in );
-Maasha::Biopieces::close_stream( $out );
-
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
diff --git a/bp_test/in/max_vals.in b/bp_test/in/max_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/in/median_vals.in b/bp_test/in/median_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/in/min_vals.in b/bp_test/in/min_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/max_vals.out.1 b/bp_test/out/max_vals.out.1
new file mode 100644 (file)
index 0000000..299dbbf
--- /dev/null
@@ -0,0 +1,4 @@
+V2_MAX: 81
+V1_MAX: 123
+REC_TYPE: MIN
+---
diff --git a/bp_test/out/max_vals.out.2 b/bp_test/out/max_vals.out.2
new file mode 100644 (file)
index 0000000..e096065
--- /dev/null
@@ -0,0 +1,18 @@
+V3_MAX: 5.00
+V3: 0;1;2;3;4;5
+V0: Human
+V2: 78
+V1: 123
+---
+V3_MAX: 8.00
+V3: 6;7;8
+V0: Dog
+V2: 81
+V1: 45
+---
+V3_MAX: 9.00
+V3: 9
+V0: Mouse
+V2: 5
+V1: 6
+---
diff --git a/bp_test/out/median_vals.out.1 b/bp_test/out/median_vals.out.1
new file mode 100644 (file)
index 0000000..a08fdbf
--- /dev/null
@@ -0,0 +1,4 @@
+V1_MEDIAN: 45
+REC_TYPE: MEDIAN
+V2_MEDIAN: 78
+---
diff --git a/bp_test/out/median_vals.out.2 b/bp_test/out/median_vals.out.2
new file mode 100644 (file)
index 0000000..0b4b6be
--- /dev/null
@@ -0,0 +1,18 @@
+V3_MEDIAN: 3.50
+V3: 0;1;2;3;4;5
+V0: Human
+V2: 78
+V1: 123
+---
+V3_MEDIAN: 7.00
+V3: 6;7;8
+V0: Dog
+V2: 81
+V1: 45
+---
+V3_MEDIAN: 9.00
+V3: 9
+V0: Mouse
+V2: 5
+V1: 6
+---
diff --git a/bp_test/out/min_vals.out.1 b/bp_test/out/min_vals.out.1
new file mode 100644 (file)
index 0000000..0564b7e
--- /dev/null
@@ -0,0 +1,4 @@
+REC_TYPE: MIN
+V1_MIN: 6
+V2_MIN: 5
+---
diff --git a/bp_test/out/min_vals.out.2 b/bp_test/out/min_vals.out.2
new file mode 100644 (file)
index 0000000..52953e9
--- /dev/null
@@ -0,0 +1,18 @@
+V3: 0;1;2;3;4;5
+V0: Human
+V2: 78
+V1: 123
+V3_MIN: 0.00
+---
+V3: 6;7;8
+V0: Dog
+V2: 81
+V1: 45
+V3_MIN: 6.00
+---
+V3: 9
+V0: Mouse
+V2: 5
+V1: 6
+V3_MIN: 9.00
+---
diff --git a/bp_test/test/test_max_vals b/bp_test/test/test_max_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
diff --git a/bp_test/test/test_median_vals b/bp_test/test/test_median_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
diff --git a/bp_test/test/test_min_vals b/bp_test/test/test_min_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