Class: BioDSL::UsearchGlobal

Inherits:
Object
  • Object
show all
Includes:
AuxHelper
Defined in:
lib/BioDSL/commands/usearch_global.rb

Overview

Run usearch_global on sequences in the stream.

This is a wrapper for the usearch tool to run the program usearch_global. Basically sequence type records are searched against a reference database and records with hit information are output.

Please refer to the manual:

drive5.com/usearch/manual/usearch_global.html

Usearch 7.0 must be installed for usearch to work. Read more here:

www.drive5.com/usearch/

Usage

usearch_global(<database: <file>, <identity: float>,
               <strand: "plus|both">[, cpus: <uint>])

Options

  • database: <file> - Database to search (in FASTA format).

  • identity: <float> - Similarity for matching in percent between 0.0 and

    1.0.
    
  • strand: <string> - For nucleotide search report hits from plus or both

    strands.
    
  • cpus: <uint> - Number of CPU cores to use (default=1).

Examples

Constant Summary collapse

STATS =
%i(records_in records_out sequences_in hits_out)

Instance Method Summary collapse

Methods included from AuxHelper

#aux_exist

Constructor Details

#initialize(options) ⇒ UsearchGlobal

Constructor for UsearchGlobal.

Parameters:

  • options (Hash)

    Options hash.

Options Hash (options):

  • :database (String)
  • :identity (Float)
  • :strand (String, Symbol)
  • :cpus (Integer)


75
76
77
78
79
80
81
# File 'lib/BioDSL/commands/usearch_global.rb', line 75

def initialize(options)
  @options        = options
  @options[:cpus] ||= 1

  aux_exist('usearch')
  check_options
end

Instance Method Details

#lmbProc

Return command lambda for usearch_global.

Returns:

  • (Proc)

    Command lambda.



86
87
88
89
90
91
92
93
94
95
96
# File 'lib/BioDSL/commands/usearch_global.rb', line 86

def lmb
  lambda do |input, output, status|
    status_init(status, STATS)

    TmpDir.create('in', 'out') do |tmp_in, tmp_out|
      process_input(input, output, tmp_in)
      run_usearch_global(tmp_in, tmp_out)
      process_output(output, tmp_out)
    end
  end
end