lib/lederhosen/tasks/cluster.rb in lederhosen-0.5.7 vs lib/lederhosen/tasks/cluster.rb in lederhosen-1.0.0

- old
+ new

@@ -1,58 +1,46 @@ -## -# FINALLY, CLUSTER! -# - module Lederhosen + class CLI - desc "cluster", - "cluster a fasta file using UCLUST" + desc 'cluster', 'reference-based clustering using usearch' - method_option :input, :type => :string, :required => true - method_option :output, :type => :string, :required => true - method_option :identity, :type => :numeric, :required => true - method_option :stepwords, :type => :numeric, :default => 8 - method_option :wordlen, :type => :numeric, :default => 8 - method_option :maxaccepts, :type => :numeric, :default => 1 - method_option :maxrejects, :type => :numeric, :default => 8 - method_option :lib, :type => :string - method_option :libonly, :type => :boolean, :default => false + method_option :input, :type => :string, :required => true + method_option :database, :type => :string, :required => true + method_option :threads, :type => :numeric, :default => 0 + method_option :identity, :type => :numeric, :required => true + method_option :output, :type => :string, :required => true + method_option :strand, :type => :string, :default => 'plus' def cluster - identity = options[:identity] - output = options[:output] - input = options[:input] - stepwords = options[:stepwords] - maxaccepts = options[:maxaccepts] - maxrejects = options[:maxrejects] - wordlen = options[:wordlen] - lib = options[:lib] - libonly = options[:libonly] + input = options[:input] + database = options[:database] + threads = options[:threads] + identity = options[:identity] + output = options[:output] + strand = options[:strand] - ohai "clustering #{input}, saving to #{output}" + ohai "clustering #{input} to #{database} and saving to #{output}" options.each_pair do |key, value| ohai "#{key} = #{value}" end - cmd = [ - 'uclust', - "--input #{input}", - "--uc #{output}", + cmd = ['usearch', + "--usearch_local #{input}", "--id #{identity}", - "--stepwords #{stepwords}", - "--maxaccepts #{maxaccepts}", - "--maxrejects #{maxrejects}", - "--w #{wordlen}" + "--uc #{output}", + "--db #{database}", + "--strand #{strand}" ] - cmd << "--lib #{lib}" unless lib.nil? - cmd << "--libonly" if libonly == true + # threads = 0 : use all threads (default) + if threads != 0 + cmd << "--threads #{threads}" + end cmd = cmd.join(' ') - @shell.mute { run cmd } + run cmd end - end end