Class: BioDSL::Usearch

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/BioDSL/usearch.rb

Overview

Class with methods to execute Usearch and parse the results.

Defined Under Namespace

Classes: IO

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Usearch

Constructor for Usearch class.

Parameters:

  • options (Hash)

    Options Hash

Options Hash (options):



136
137
138
139
140
141
142
143
# File 'lib/BioDSL/usearch.rb', line 136

def initialize(options)
  @options = options
  @stderr  = nil

  return self unless File.size(@options[:input]) == 0

  fail UsearchError, %(Empty input file -> "#{@options[:input]}")
end

Class Method Details

.cluster_otus(options) ⇒ Object

Execute cluster_otus.

Parameters:

  • options (Hash)

    Options Hash

Options Hash (options):



62
63
64
65
# File 'lib/BioDSL/usearch.rb', line 62

def self.cluster_otus(options)
  usearch = new(options)
  usearch.cluster_otus
end

.cluster_smallmem(options) ⇒ Object

Execute cluster_smallmem.

Parameters:

  • options (Hash)

    Options Hash

Options Hash (options):



48
49
50
51
# File 'lib/BioDSL/usearch.rb', line 48

def self.cluster_smallmem(options)
  usearch = new(options)
  usearch.cluster_smallmem
end

.open(*args) {|IO| ... } ⇒ IO

Open a Usearch file.

Parameters:

  • List (Array)

    of open arguments.

Yields:

  • (IO)

    stream.

Returns:

  • (IO)

    stream.



115
116
117
118
119
120
121
122
123
# File 'lib/BioDSL/usearch.rb', line 115

def self.open(*args)
  ios = IO.open(*args)

  if block_given?
    yield ios
  else
    return ios
  end
end

.uchime_ref(options) ⇒ Object

Execute uchime_ref.

Parameters:

  • options (Hash)

    Options Hash

Options Hash (options):



76
77
78
79
# File 'lib/BioDSL/usearch.rb', line 76

def self.uchime_ref(options)
  usearch = new(options)
  usearch.uchime_ref
end

.usearch_global(options) ⇒ Object

Execute usearch_local.

Parameters:

  • options (Hash)

    Options Hash

Options Hash (options):



90
91
92
93
# File 'lib/BioDSL/usearch.rb', line 90

def self.usearch_global(options)
  usearch = new(options)
  usearch.usearch_global
end

.usearch_local(options) ⇒ Object

Execute usearch_local.

Parameters:

  • options (Hash)

    Options Hash

Options Hash (options):



104
105
106
107
# File 'lib/BioDSL/usearch.rb', line 104

def self.usearch_local(options)
  usearch = new(options)
  usearch.usearch_local
end

Instance Method Details

#cluster_otusself

Combose a command list and execute cluster_otus with this.

Returns:

  • (self)


170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/BioDSL/usearch.rb', line 170

def cluster_otus
  command = []
  command << 'usearch'
  command << "-cluster_otus #{@options[:input]}"
  command << "-otus #{@options[:output]}"
  command << "-id #{@options[:identity]}"
  command << "-threads #{@options[:cpus]}" if @options[:cpus]

  execute(command)

  self
end

#cluster_smallmemself

Combose a command list and execute cluster_smallmem with this.

Returns:

  • (self)


148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/BioDSL/usearch.rb', line 148

def cluster_smallmem
  command = []
  command << 'usearch'
  command << "-cluster_smallmem #{@options[:input]}"
  command << "-id #{@options[:identity]}"
  command << "-threads #{@options[:cpus]}" if @options[:cpus]
  command << "-strand #{@options[:strand]}"

  if @options[:align]
    command << "-msaout #{@options[:output]}"
  else
    command << "-uc #{@options[:output]}"
  end

  execute(command)

  self
end

#uchime_refself

Combose a command list and execute uchime_ref with this.

Returns:

  • (self)


186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/BioDSL/usearch.rb', line 186

def uchime_ref
  command = []
  command << 'usearch'
  command << "-uchime_ref #{@options[:input]}"
  command << "-db #{@options[:database]}"
  command << "-strand #{@options[:strand]}"
  command << "-threads #{@options[:cpus]}" if @options[:cpus]
  command << "-nonchimeras #{@options[:output]}"

  execute(command)

  self
end

#usearch_globalself

Combose a command list and execute usearch_global with this.

Returns:

  • (self)


203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/BioDSL/usearch.rb', line 203

def usearch_global
  command = []
  command << 'usearch'
  command << '-notrunclabels'
  command << "-usearch_global #{@options[:input]}"
  command << "-db #{@options[:database]}"
  command << "-strand #{@options[:strand]}" if @options[:strand]
  command << "-threads #{@options[:cpus]}"  if @options[:cpus]
  command << "-id #{@options[:identity]}"
  command << "-uc #{@options[:output]}"

  execute(command)

  self
end

#usearch_localself

Combose a command list and execute usearch_local with this.

Returns:

  • (self)


222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/BioDSL/usearch.rb', line 222

def usearch_local
  command = []
  command << 'usearch'
  command << '-notrunclabels'
  command << "-usearch_local #{@options[:input]}"
  command << "-db #{@options[:database]}"
  command << "-strand #{@options[:strand]}" if @options[:strand]
  command << "-threads #{@options[:cpus]}"  if @options[:cpus]
  command << "-id #{@options[:identity]}"
  command << "-uc #{@options[:output]}"

  execute(command)

  self
end