]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/read_genbank
removed debug message
[biopieces.git] / bp_bin / read_genbank
index 1ab92e42eae5bb9650ede59838dd9c1d78756840..006cb50f59fe454c7c2d765e774327db3cb983d6 100755 (executable)
@@ -38,37 +38,38 @@ casts << {:long=>'keys',       :short=>'k', :type=>'list',   :mandatory=>false,
 casts << {:long=>'features',   :short=>'f', :type=>'list',   :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
 casts << {:long=>'qualifiers', :short=>'q', :type=>'list',   :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
 
-bp = Biopieces.new
-
-options = bp.parse(ARGV, casts)
+options = Biopieces.options_parse(ARGV, casts)
 
 hash_keys  = options[:keys].inject(Hash.new)       { |h,k| h[k.upcase.to_sym] = true; h } if options[:keys]
 hash_feats = options[:features].inject(Hash.new)   { |h,k| h[k.upcase.to_sym] = true; h } if options[:features]
 hash_quals = options[:qualifiers].inject(Hash.new) { |h,k| h[k.upcase.to_sym] = true; h } if options[:qualifiers]
 
-bp.each_record do |record|
-  bp.puts record
-end
 
-num  = 0
-last = false
+Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
+  input.each_record do |record|
+    output.puts record
+  end
+
+  num  = 0
+  last = false
 
-if options.has_key? :data_in
-  options[:data_in].each do |file|
-    Genbank.open(file, mode='r') do |gb|
-      gb.each(hash_keys, hash_feats, hash_quals) do |entry|
-        bp.puts entry
+  if options[:data_in]
+    options[:data_in].each do |file|
+      Genbank.open(file, 'r') do |gb|
+        gb.each(hash_keys, hash_feats, hash_quals) do |entry|
+          output.puts entry
 
-        num += 1
+          num += 1
 
-        if options.has_key? :num and options[:num] == num
-          last = true
-          break
+          if options[:num] and options[:num] == num
+            last = true
+            break
+          end
         end
       end
-    end
 
-    break if last
+      break if last
+    end
   end
 end