]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/find_mids
fixed alignment descriptors in sam.rb
[biopieces.git] / bp_bin / find_mids
index 81015f6667565e44188d13b1065fd91a484ffb1b..52da69ed77e9558b37b671c5ff099aea1f72386c 100755 (executable)
@@ -30,7 +30,6 @@
 
 
 require 'maasha/biopieces'
-require 'pp'
 
 MID_LEN = 10
 
@@ -80,34 +79,35 @@ end
 casts = []
 casts << {:long=>'pos', :short=>'p', :type=>'uint', :mandatory=>false, :default=>0, :allowed=>nil, :disallowed=>nil}
 
-bp = Biopieces.new
-
-options = bp.parse(ARGV, casts)
+options = Biopieces.options_parse(ARGV, casts)
 
 pos = options[:pos]
 
-bp.each_record do |record|
-  if record.has_key? :SEQ
-    tag = record[:SEQ][pos ... pos + MID_LEN].upcase
+Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
+  input.each_record do |record|
+    if record.has_key? :SEQ
+      tag = record[:SEQ][pos ... pos + MID_LEN].upcase
 
-    if mid_hash.has_key? tag
-      count_hash[tag] += 1
+      if mid_hash.has_key? tag
+        count_hash[tag] += 1
+      end
     end
+    output.puts record
   end
-  bp.puts record
-end
 
-mids.each_with_index do |mid, i|
-  if count_hash[mid] > 0
-    record = {}
-    record[:REC_TYPE]  = "MID"
-    record[:MID_NUM]   = i + 1
-    record[:MID_COUNT] = count_hash[mid]
-    record[:MID_SEQ]   = mid
-    bp.puts record
+  mids.each_with_index do |mid, i|
+    if count_hash[mid] > 0
+      record = {}
+      record[:REC_TYPE]  = "MID"
+      record[:MID_NUM]   = i + 1
+      record[:MID_COUNT] = count_hash[mid]
+      record[:MID_SEQ]   = mid
+      output.puts record
+    end
   end
 end
 
+
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<