]> git.donarmstrong.com Git - biopieces.git/commitdiff
added -o and -x to analyze_vals
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 25 Oct 2013 09:42:48 +0000 (09:42 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 25 Oct 2013 09:42:48 +0000 (09:42 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@2250 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/analyze_vals
bp_test/out/analyze_vals.out.1
bp_test/out/analyze_vals.out.2
bp_test/out/analyze_vals.out.3
bp_test/out/analyze_vals.out.4 [new file with mode: 0644]
bp_test/out/analyze_vals.out.5 [new file with mode: 0644]
bp_test/test/test_analyze_vals
code_ruby/lib/maasha/seq/backtrack.rb

index e7e8249a8faf73c53bce080d333e56a73a2b7aa1..951f321f808e7b4e907d11d791e29c37cb1d64c2 100755 (executable)
 require 'maasha/biopieces'
 
 casts = []
-casts << {long: 'keys',    short: 'k', type: 'list', mandatory: false, default: nil, allowed: nil, disallowed: nil}
-casts << {long: 'no_keys', short: 'K', type: 'list', mandatory: false, default: nil, allowed: nil, disallowed: nil}
+casts << {long: 'keys',      short: 'k', type: 'list', mandatory: false, default: nil, allowed: nil, disallowed: nil}
+casts << {long: 'no_keys',   short: 'K', type: 'list', mandatory: false, default: nil, allowed: nil, disallowed: nil}
+casts << {long: 'no_stream', short: 'x', type: 'flag', mandatory: false, default: nil, allowed: nil, disallowed: nil}
+casts << {long: 'data_out',  short: 'o', type: 'file', mandatory: false, default: nil, allowed: nil, disallowed: nil}
 
 options = Biopieces.options_parse(ARGV, casts)
 
@@ -91,6 +93,12 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
 
       stats[key][:count] += 1
     end
+
+    output.puts record unless options[:no_stream]
+  end
+
+  if options[:data_out]
+    data_out = File.open(options[:data_out], 'w')
   end
 
   stats.each do |key, value|
@@ -104,7 +112,11 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
       :MEAN  => "%0.2f" % (value[:sum] / value[:count].to_f)
     }
 
-    output.puts stat_record
+    if options[:data_out]
+      data_out.puts stat_record
+    else
+      output.puts stat_record
+    end
   end
 end
 
index 6afc4dffce518044a0b0d983a71ea66332117074..29aaf12a9063c143006ef3b9530357257e5cc720 100644 (file)
@@ -1,3 +1,12 @@
+V0: Human
+V1: 123
+---
+V0: Dog
+V1: 45
+---
+V0: Mouse
+V1: 6
+---
 KEY: V0
 TYPE: Alphabetic
 COUNT: 3
index e1d6bb53d440000fae31937937ad1552f15b5c92..6afc4dffce518044a0b0d983a71ea66332117074 100644 (file)
@@ -6,3 +6,11 @@ MAX: 5
 SUM: 13
 MEAN: 4.33
 ---
+KEY: V1
+TYPE: Numeric
+COUNT: 3
+MIN: 6
+MAX: 123
+SUM: 174
+MEAN: 58.00
+---
index 6d628d00993493ce395ea71aab595e9f99d32f7e..9ce53d709dd3b8570e3c7f2492fde3e3217d0f61 100644 (file)
@@ -1,8 +1,17 @@
-KEY: V1
-TYPE: Numeric
+V0: Human
+V1: 123
+---
+V0: Dog
+V1: 45
+---
+V0: Mouse
+V1: 6
+---
+KEY: V0
+TYPE: Alphabetic
 COUNT: 3
-MIN: 6
-MAX: 123
-SUM: 174
-MEAN: 58.00
+MIN: 3
+MAX: 5
+SUM: 13
+MEAN: 4.33
 ---
diff --git a/bp_test/out/analyze_vals.out.4 b/bp_test/out/analyze_vals.out.4
new file mode 100644 (file)
index 0000000..48f9086
--- /dev/null
@@ -0,0 +1,17 @@
+V0: Human
+V1: 123
+---
+V0: Dog
+V1: 45
+---
+V0: Mouse
+V1: 6
+---
+KEY: V1
+TYPE: Numeric
+COUNT: 3
+MIN: 6
+MAX: 123
+SUM: 174
+MEAN: 58.00
+---
diff --git a/bp_test/out/analyze_vals.out.5 b/bp_test/out/analyze_vals.out.5
new file mode 100644 (file)
index 0000000..6afc4df
--- /dev/null
@@ -0,0 +1,16 @@
+KEY: V0
+TYPE: Alphabetic
+COUNT: 3
+MIN: 3
+MAX: 5
+SUM: 13
+MEAN: 4.33
+---
+KEY: V1
+TYPE: Numeric
+COUNT: 3
+MIN: 6
+MAX: 123
+SUM: 174
+MEAN: 58.00
+---
index 918b3fc546a95efc54b7ef0529757b83d7203426..f81f2b640688807fa794382ccf1f74233bfa7b93 100755 (executable)
@@ -6,10 +6,18 @@ run "$bp -I $in -O $tmp"
 assert_no_diff $tmp $out.1
 clean
 
-run "$bp -I $in -k V0 -O $tmp"
+run "$bp -I $in -O $tmp -x"
 assert_no_diff $tmp $out.2
 clean
 
-run "$bp -I $in -K V0 -O $tmp"
+run "$bp -I $in -k V0 -O $tmp"
 assert_no_diff $tmp $out.3
 clean
+
+run "$bp -I $in -K V0 -O $tmp"
+assert_no_diff $tmp $out.4
+clean
+
+run "$bp -I $in -o $tmp -x"
+assert_no_diff $tmp $out.5
+clean
index 782252465d974c7491a2efa9a9185d9422a316e0..3e9a781d7bcad706877ccf77cb6b108d4686c47f 100644 (file)
@@ -146,7 +146,7 @@ module BackTrack
       options[:start] = result.first + 1
     end
 
-    return matches.empty? ? nil : matches unless block_given?
+    return matches unless block_given?
   end
 
   private