Sha256: a37b60b1970a50daabbea36a93bfaf72b12e9d8af4f51e1a186e301635b7588a

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

module Lederhosen

  class CLI

    desc 'cluster', 'reference-based clustering using usearch'

    method_option :input,    :type  => :string,  :required => true
    method_option :database, :type  => :string,  :required => true
    method_option :threads,  :type  => :numeric, :default  => false
    method_option :identity, :type  => :numeric, :required => true
    method_option :output,   :type  => :string,  :required => true
    method_option :strand,   :type  => :string,  :default  => 'plus'
    method_option :dry_run,  :type  => :boolean, :default  => false
    method_option :query_cov, :type => :numeric, :required => false, :default => 0.95

    def cluster
      input     = File.expand_path(options[:input])
      database  = File.expand_path(options[:database])
      threads   = options[:threads]
      identity  = options[:identity]
      output    = File.expand_path(options[:output])
      strand    = options[:strand]
      dry_run   = options[:dry_run]
      query_cov = options[:query_cov]

      ohai "#{'(dry run)' if dry_run} clustering #{input} to #{database} and saving to #{output}"

      options.each_pair do |key, value|
        ohai "#{key} = #{value}"
      end

      cmd = ['usearch',
        "--usearch_local #{input}",
        "--id #{identity}",
        "--uc #{output}",
        "--db #{database}",
        "--strand #{strand}",
        "--query_cov #{query_cov}"
      ]

      # threads = False : use all threads (default)
      if threads != false
        cmd << "--threads #{threads}"
      end

      cmd = cmd.join(' ')

      unless dry_run
        run cmd
      else
        puts cmd
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lederhosen-3.2.1 lib/lederhosen/tasks/cluster.rb
lederhosen-3.2.0 lib/lederhosen/tasks/cluster.rb
lederhosen-3.1.0 lib/lederhosen/tasks/cluster.rb