Class: Bio::Fasta

Inherits:
Object show all
Defined in:
lib/bio/appl/fasta.rb,
lib/bio/appl/fasta/format10.rb

Defined Under Namespace

Classes: Report

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(program, db, opt = [], server = 'local') ⇒ Fasta

Returns a FASTA factory object (Bio::Fasta).



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/bio/appl/fasta.rb', line 23

def initialize(program, db, opt = [], server = 'local')
  @format	= 10

  @program	= program
  @db	= db
  @server	= server

  @ktup	= nil
  @matrix	= nil

  @output	= ''

  begin
    a = opt.to_ary
  rescue NameError #NoMethodError
    # backward compatibility
    a = Shellwords.shellwords(opt)
  end
  @options	= [ '-Q', '-H', '-m', @format.to_s, *a ] # need -a ?
end

Instance Attribute Details

#dbObject

Returns the value of attribute db.



43
44
45
# File 'lib/bio/appl/fasta.rb', line 43

def db
  @db
end

#formatObject

Returns the value of attribute format.



67
68
69
# File 'lib/bio/appl/fasta.rb', line 67

def format
  @format
end

#ktupObject

Returns the value of attribute ktup.



43
44
45
# File 'lib/bio/appl/fasta.rb', line 43

def ktup
  @ktup
end

#matrixObject

Returns the value of attribute matrix.



43
44
45
# File 'lib/bio/appl/fasta.rb', line 43

def matrix
  @matrix
end

#optionsObject

Returns the value of attribute options.



43
44
45
# File 'lib/bio/appl/fasta.rb', line 43

def options
  @options
end

#outputObject (readonly)

Returns a String containing fasta execution output in as is format.



46
47
48
# File 'lib/bio/appl/fasta.rb', line 46

def output
  @output
end

#programObject

Returns the value of attribute program.



43
44
45
# File 'lib/bio/appl/fasta.rb', line 43

def program
  @program
end

#serverObject

Returns the value of attribute server.



43
44
45
# File 'lib/bio/appl/fasta.rb', line 43

def server
  @server
end

Class Method Details

.local(program, db, option = '') ⇒ Object

Returns a FASTA factory object (Bio::Fasta) to run FASTA search on local computer.



81
82
83
# File 'lib/bio/appl/fasta.rb', line 81

def self.local(program, db, option = '')
  self.new(program, db, option, 'local')
end

.parser(parser) ⇒ Object

Select parser to use (‘format6’ and ‘format10’ is acceptable for now)

This method will import Bio::Fasta::Report class by requiring specified parser and will be useful when you already have fasta output files and want to use appropriate Report class for parsing.



75
76
77
# File 'lib/bio/appl/fasta.rb', line 75

def self.parser(parser)
  require "bio/appl/fasta/#{parser}"
end

.remote(program, db, option = '', server = 'genomenet') ⇒ Object

Returns a FASTA factory object (Bio::Fasta) to execute FASTA search on remote server.

For the develpper, you can add server ‘hoge’ by adding exec_hoge(query) method.



91
92
93
# File 'lib/bio/appl/fasta.rb', line 91

def self.remote(program, db, option = '', server = 'genomenet')
  self.new(program, db, option, server)
end

Instance Method Details

#optionObject



48
49
50
51
# File 'lib/bio/appl/fasta.rb', line 48

def option
  # backward compatibility
  Bio::Command.make_command_line(@options)
end

#option=(str) ⇒ Object



53
54
55
56
# File 'lib/bio/appl/fasta.rb', line 53

def option=(str)
  # backward compatibility
  @options = Shellwords.shellwords(str)
end

#query(query) ⇒ Object

Execute FASTA search and returns Report object (Bio::Fasta::Report).



96
97
98
# File 'lib/bio/appl/fasta.rb', line 96

def query(query)
  return self.send("exec_#{@server}", query.to_s)
end