]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/usearch_seq
fixing usearch upgrade
[biopieces.git] / bp_bin / usearch_seq
index c390708a46fc8535a43b1b7f2b76d538334a01b8..d139957f1929fdd40ff46b038d924580260df0c8 100755 (executable)
@@ -33,13 +33,22 @@ require 'maasha/fasta'
 require 'maasha/usearch'
 
 casts = []
-casts << {:long=>'database', :short=>'d', :type=>'file!', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
-casts << {:long=>'identity', :short=>'i', :type=>'float', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
-casts << {:long=>'e_val',    :short=>'e', :type=>'float', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
+casts << {long: 'program',    short: 'p', type: 'string', mandatory: false, default: 'global', allowed: "local,global", disallowed: nil}
+casts << {long: 'database',   short: 'd', type: 'file!',  mandatory: true,  default: nil,      allowed: nil,            disallowed: nil}
+casts << {long: 'identity',   short: 'i', type: 'float',  mandatory: false, default: nil,      allowed: nil,            disallowed: nil}
+casts << {long: 'e_val',      short: 'e', type: 'float',  mandatory: false, default: nil,      allowed: nil,            disallowed: nil}
+casts << {long: 'cpus',       short: 'c', type: 'uint',   mandatory: false, default: 1,        allowed: nil,            disallowed: "0"}
+casts << {long: 'maxaccepts', short: 'm', type: 'uint',   mandatory: false, default: 0,        allowed: nil,            disallowed: nil}
 
 options = Biopieces.options_parse(ARGV, casts)
 
-raise ArgumentError, "--identity or --e_val must be specified" unless options[:identity] or options[:e_val]
+if options[:program] == 'global'
+  raise ArgumentError, "--identity be specified for global search" unless options[:identity]
+  raise ArgumentError, "--e_val is invalid for global search" if options[:e_val]
+else
+  raise ArgumentError, "--identity or --e_val must be specified" unless options[:identity] or options[:e_val]
+end
+
 
 tmpdir  = Biopieces.mktmpdir
 infile  = File.join(tmpdir, "in.fna")
@@ -58,7 +67,11 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
 
   us = Usearch.new(infile, outfile, options)
 
-  us.usearch
+  case options[:program]
+  when "local"  then us.usearch_local
+  when "global" then us.usearch_global
+  else raise "no such program #{options[:program]}"
+  end
 
   us.each_hit do |record|
     output.puts record