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