]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/uclust_seq
committing major ruby overhaul
[biopieces.git] / bp_bin / uclust_seq
index 76c56683b66a82d37ff39625412840f8049fc7b1..4523ab05b09bf69a6919b9ac9009bed60bbd0bc1 100755 (executable)
@@ -142,34 +142,34 @@ casts << {:long=>'comp',     :short=>'c', :type=>'flag',   :mandatory=>false, :d
 casts << {:long=>'identity', :short=>'i', :type=>'float',  :mandatory=>true,  :default=>0.9,      :allowed=>nil,        :disallowed=>nil}
 casts << {:long=>'e_val',    :short=>'e', :type=>'float',  :mandatory=>false, :default=>nil,      :allowed=>nil,        :disallowed=>nil}
 
-bp = Biopieces.new
+options = Biopieces.options_parse(ARGV, casts)
 
-options = bp.parse(ARGV, casts)
+tmpdir  = Biopieces.mktmpdir
+infile  = File.join(tmpdir, "in.fna")
+outfile = File.join(tmpdir, "out.uc")
 
-tmpdir  = bp.mktmpdir
-infile  = "#{tmpdir}/in.fna"
-outfile = "#{tmpdir}/out.uc"
-
-Fasta.open(infile, mode="w") do |fasta_io|
-  bp.each_record do |record|
-    bp.puts record
-    fasta_io.puts record
+Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
+  Fasta.open(infile, mode="w") do |fasta_io|
+    input.each_record do |record|
+      output.puts record
+      fasta_io.puts record
+    end
   end
-end
 
-uclust = Uclust.new(infile, outfile, options)
-uclust.sort unless options[:no_sort]
+  uclust = Uclust.new(infile, outfile, options)
+  uclust.sort unless options[:no_sort]
 
-case options[:method].to_s
-when "ublast"         then uclust.ublast
-when "usearch"        then uclust.usearch
-when "uclust"         then uclust.uclust
-when "usearch_uclust" then uclust.usearch_uclust
-else raise "Unknown method: #{options[:method]}"
-end
+  case options[:method].to_s
+  when "ublast"         then uclust.ublast
+  when "usearch"        then uclust.usearch
+  when "uclust"         then uclust.uclust
+  when "usearch_uclust" then uclust.usearch_uclust
+  else raise "Unknown method: #{options[:method]}"
+  end
 
-uclust.each do |record|
-  bp.puts record
+  uclust.each do |record|
+    output.puts record
+  end
 end