Class: Bio::Alignment::FactoryTemplate::Simple

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/alignment.rb

Overview

Template class for alignment application factory. The program acts: input: stdin or file, format = fasta format output: stdout (parser should be specified by DEFAULT_PARSER)

Direct Known Subclasses

FileInFileOut, FileInStdoutOut, StdinInFileOut

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(program = self.class::DEFAULT_PROGRAM, options = []) ⇒ Simple

Creates a new alignment factory



2215
2216
2217
2218
2219
2220
2221
2222
2223
# File 'lib/bio/alignment.rb', line 2215

def initialize(program = self.class::DEFAULT_PROGRAM, options = [])
  @program = program
  @options = options
  @command = nil
  @output = nil
  @report = nil
  @exit_status = nil
  @data_stdout = nil
end

Instance Attribute Details

#commandObject (readonly)

Last command-line string. Returns nil or an array of String. Note that filenames described in the command-line may already be removed because these files may be temporary files.



2234
2235
2236
# File 'lib/bio/alignment.rb', line 2234

def command
  @command
end

#data_stdoutObject

Last output to the stdout.



2247
2248
2249
# File 'lib/bio/alignment.rb', line 2247

def data_stdout
  @data_stdout
end

#exit_statusObject (readonly)

Last exit status



2244
2245
2246
# File 'lib/bio/alignment.rb', line 2244

def exit_status
  @exit_status
end

#optionsObject

options



2229
2230
2231
# File 'lib/bio/alignment.rb', line 2229

def options
  @options
end

#outputObject (readonly)

Last raw result of the program. Return a string (or nil).



2238
2239
2240
# File 'lib/bio/alignment.rb', line 2238

def output
  @output
end

#programObject

program name



2226
2227
2228
# File 'lib/bio/alignment.rb', line 2226

def program
  @program
end

#reportObject (readonly)

Last result object performed by the factory.



2241
2242
2243
# File 'lib/bio/alignment.rb', line 2241

def report
  @report
end

Instance Method Details

#query(seqs) ⇒ Object

Executes the program. If seqs is not nil, perform alignment for seqs. If seqs is nil, simply executes the program.

Compatibility note: When seqs is nil, returns true if the program exits normally, and returns false if the program exits abnormally.



2265
2266
2267
2268
2269
2270
2271
2272
# File 'lib/bio/alignment.rb', line 2265

def query(seqs)
  if seqs then
    query_alignment(seqs)
  else
    exec_local(@options)
    @exit_status.exitstatus == 0 ? true : false
  end
end

#query_align(seqs) ⇒ Object

alias of query_alignment.

Compatibility Note: query_align will renamed to query_alignment.



2286
2287
2288
2289
# File 'lib/bio/alignment.rb', line 2286

def query_align(seqs)
  #warn 'query_align is renamed to query_alignment.'
  query_alignment(seqs)
end

#query_alignment(seqs) ⇒ Object

Performs alignment for seqs. seqs should be Bio::Alignment or Array of sequences or nil.



2276
2277
2278
2279
2280
2281
# File 'lib/bio/alignment.rb', line 2276

def query_alignment(seqs)
  unless seqs.respond_to?(:output_fasta) then
    seqs = Bio::Alignment.new(seqs)
  end
  query_string(seqs.output_fasta(:width => 70))
end

#query_by_filename(filename_in) ⇒ Object

Performs alignment of sequences in the file named fn.



2299
2300
2301
2302
# File 'lib/bio/alignment.rb', line 2299

def query_by_filename(filename_in)
  _query_local(filename_in, @options)
  @report
end

#query_string(str) ⇒ Object

Performs alignment for str. The str should be a string that can be recognized by the program.



2293
2294
2295
2296
# File 'lib/bio/alignment.rb', line 2293

def query_string(str)
  _query_string(str, @options)
  @report
end

#resetObject

Clear the internal data and status, except program and options.



2250
2251
2252
2253
2254
2255
2256
# File 'lib/bio/alignment.rb', line 2250

def reset
  @command = nil
  @output = nil
  @report = nil
  @exit_status = nil
  @data_stdout = nil
end