Class: Bio::HMMER

Inherits:
Object show all
Defined in:
lib/bio/appl/hmmer.rb,
lib/bio/appl/hmmer/report.rb

Overview

Description

A wapper for HMMER programs (hmmsearch or hmmpfam).

Examples

require 'bio'
program = 'hmmsearch' # or 'hmmpfam'
hmmfile = 'test.hmm'
seqfile = 'test.faa'

factory = Bio::HMMER.new(program, hmmfile, seqfile)
report = factory.query
report.class # => Bio::HMMER::Report

References

Defined Under Namespace

Classes: Report

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(program, hmmfile, seqfile, options = []) ⇒ HMMER

Sets a program name, a profile hmm file name, a query sequence file name and options in string.

Program names: hmmsearch, hmmpfam


60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/bio/appl/hmmer.rb', line 60

def initialize(program, hmmfile, seqfile, options = [])
  @program = program
  @hmmfile = hmmfile
  @seqfile = seqfile
  @output  = ''
  
  begin
    @options = options.to_ary
  rescue NameError #NoMethodError
    # backward compatibility
    @options = Shellwords.shellwords(options)
  end
end

Instance Attribute Details

#hmmfileObject

Name of hmmfile.


44
45
46
# File 'lib/bio/appl/hmmer.rb', line 44

def hmmfile
  @hmmfile
end

#optionsObject

Command line options.


50
51
52
# File 'lib/bio/appl/hmmer.rb', line 50

def options
  @options
end

#outputObject (readonly)

Shows the raw output from the hmmer search.


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

def output
  @output
end

#programObject

Prgrams name. (hmmsearch or hmmpfam).


41
42
43
# File 'lib/bio/appl/hmmer.rb', line 41

def program
  @program
end

#seqfileObject

Name of seqfile.


47
48
49
# File 'lib/bio/appl/hmmer.rb', line 47

def seqfile
  @seqfile
end

Class Method Details

.reports(multiple_report_text) ⇒ Object

A reader interface for multiple reports text into a report (Bio::HMMER::Report).

Examples

# Iterator
Bio::HMMER.reports(reports_text) do |report|
  report
end

# Array
reports = Bio::HMMER.reports(reports_text)

62
63
64
65
66
67
68
69
70
71
72
# File 'lib/bio/appl/hmmer/report.rb', line 62

def self.reports(multiple_report_text)
  ary = []
  multiple_report_text.each_line("\n//\n") do |report|
    if block_given?
      yield Report.new(report)
    else
      ary << Report.new(report)
    end
  end
  return ary
end

Instance Method Details

#optionObject

Gets options by String. backward compatibility.


77
78
79
# File 'lib/bio/appl/hmmer.rb', line 77

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

#option=(str) ⇒ Object

Sets options by String. backward compatibility.


84
85
86
# File 'lib/bio/appl/hmmer.rb', line 84

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

#queryObject

Executes the hmmer search and returns the report (Bio::HMMER::Report object).


91
92
93
94
95
96
97
98
99
100
101
# File 'lib/bio/appl/hmmer.rb', line 91

def query
  cmd = [ @program, *@options ]
  cmd.concat([ @hmmfile, @seqfile ])
    
  report = nil
  
  @output = Bio::Command.query_command(cmd, nil)
  report = parse_result(@output)
    
  return report
end