Class: Bio::Blast::Report

Inherits:
Object show all
Defined in:
lib/bio/appl/blast/report.rb,
lib/bio/appl/blast/rexml.rb,
lib/bio/appl/blast/format8.rb,
lib/bio/appl/blast/xmlparser.rb

Overview

Bio::Blast::Report

Parsed results of the blast execution for Tab-delimited and XML output format. Tab-delimited reports are consists of

Query id,
Subject id,
percent of identity,
alignment length,
number of mismatches (not including gaps),
number of gap openings,
start of alignment in query,
end of alignment in query,
start of alignment in subject,
end of alignment in subject,
expected value,
bit score.

according to the MEGABLAST document (README.mbl). As for XML output, see the following DTDs.

* http://www.ncbi.nlm.nih.gov/dtd/NCBI_BlastOutput.dtd
* http://www.ncbi.nlm.nih.gov/dtd/NCBI_BlastOutput.mod
* http://www.ncbi.nlm.nih.gov/dtd/NCBI_Entity.mod

Defined Under Namespace

Classes: Hit, Hsp, Iteration

Constant Summary collapse

DELIMITER =

for Bio::FlatFile support (only for XML data)

RS = "</BlastOutput>\n"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, parser = nil) ⇒ Report

Passing a BLAST output from ‘blastall -m 7’ or ‘-m 8’ as a String. Formats are auto detected.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/bio/appl/blast/report.rb', line 78

def initialize(data, parser = nil)
  @iterations = []
  @parameters = {}
  case parser
  when :xmlparser		# format 7
    xmlparser_parse(data)
  when :rexml		# format 7
    rexml_parse(data)
  when :tab		# format 8
    tab_parse(data)
  else
    auto_parse(data)
  end
end

Instance Attribute Details

#dbObject (readonly)

Shortcut for BlastOutput values.



102
103
104
# File 'lib/bio/appl/blast/report.rb', line 102

def db
  @db
end

#iterationsObject (readonly)

Returns an Array of Bio::Blast::Report::Iteration objects.



94
95
96
# File 'lib/bio/appl/blast/report.rb', line 94

def iterations
  @iterations
end

#parametersObject (readonly)

Returns a Hash containing execution parameters. Valid keys are: ‘matrix’, ‘expect’, ‘include’, ‘sc-match’, ‘sc-mismatch’, ‘gap-open’, ‘gap-extend’, ‘filter’



99
100
101
# File 'lib/bio/appl/blast/report.rb', line 99

def parameters
  @parameters
end

#programObject (readonly)

Shortcut for BlastOutput values.



102
103
104
# File 'lib/bio/appl/blast/report.rb', line 102

def program
  @program
end

#query_defObject (readonly)

Shortcut for BlastOutput values.



102
103
104
# File 'lib/bio/appl/blast/report.rb', line 102

def query_def
  @query_def
end

#query_idObject (readonly)

Shortcut for BlastOutput values.



102
103
104
# File 'lib/bio/appl/blast/report.rb', line 102

def query_id
  @query_id
end

#query_lenObject (readonly)

Shortcut for BlastOutput values.



102
103
104
# File 'lib/bio/appl/blast/report.rb', line 102

def query_len
  @query_len
end

#referenceObject (readonly)

Shortcut for BlastOutput values.



102
103
104
# File 'lib/bio/appl/blast/report.rb', line 102

def reference
  @reference
end

#versionObject (readonly)

Shortcut for BlastOutput values.



102
103
104
# File 'lib/bio/appl/blast/report.rb', line 102

def version
  @version
end

Class Method Details

.rexml(data) ⇒ Object

Specify to use REXML to parse XML (-m 7) output.



54
55
56
# File 'lib/bio/appl/blast/report.rb', line 54

def self.rexml(data)
  self.new(data, :rexml)
end

.tab(data) ⇒ Object

Specify to use tab delimited output parser.



59
60
61
# File 'lib/bio/appl/blast/report.rb', line 59

def self.tab(data)
  self.new(data, :tab)
end

.xmlparser(data) ⇒ Object

Specify to use XMLParser to parse XML (-m 7) output.



49
50
51
# File 'lib/bio/appl/blast/report.rb', line 49

def self.xmlparser(data)
  self.new(data, :xmlparser)
end

Instance Method Details

#db_lenObject

Length of BLAST db



158
# File 'lib/bio/appl/blast/report.rb', line 158

def db_len;    statistics['db-len'];    end

#db_numObject

Number of sequences in BLAST db



156
# File 'lib/bio/appl/blast/report.rb', line 156

def db_num;    statistics['db-num'];    end

#each_hitObject Also known as: each

Iterates on each Bio::Blast::Report::Hit object of the the last Iteration. Shortcut for the last iteration’s hits (for blastall)



134
135
136
137
138
# File 'lib/bio/appl/blast/report.rb', line 134

def each_hit
  @iterations.last.each do |x|
    yield x
  end
end

#each_iterationObject

Iterates on each Bio::Blast::Report::Iteration object. (for blastpgp)



126
127
128
129
130
# File 'lib/bio/appl/blast/report.rb', line 126

def each_iteration
  @iterations.each do |x|
    yield x
  end
end

#eff_spaceObject

Effective search space



162
# File 'lib/bio/appl/blast/report.rb', line 162

def eff_space; statistics['eff-space']; end

#entrez_queryObject

Limit of request to Entrez : shortcuts for @parameters



123
# File 'lib/bio/appl/blast/report.rb', line 123

def entrez_query; @parameters['entrez-query'];     end

#entropyObject

Karlin-Altschul parameter H



168
# File 'lib/bio/appl/blast/report.rb', line 168

def entropy;   statistics['entropy'];   end

#expectObject

Expectation threshold (-e) : shortcuts for @parameters



107
# File 'lib/bio/appl/blast/report.rb', line 107

def expect;       @parameters['expect'].to_i;      end

#filterObject

Filtering options (-F) : shortcuts for @parameters



119
# File 'lib/bio/appl/blast/report.rb', line 119

def filter;       @parameters['filter'];           end

#gap_extendObject

Gap extension cost (-E) : shortcuts for @parameters



117
# File 'lib/bio/appl/blast/report.rb', line 117

def gap_extend;   @parameters['gap-extend'].to_i;  end

#gap_openObject

Gap opening cost (-G) : shortcuts for @parameters



115
# File 'lib/bio/appl/blast/report.rb', line 115

def gap_open;     @parameters['gap-open'].to_i;    end

#hitsObject

Returns a Array of Bio::Blast::Report::Hits of the last iteration. Shortcut for the last iteration’s hits



143
144
145
# File 'lib/bio/appl/blast/report.rb', line 143

def hits
  @iterations.last.hits
end

#hsp_lenObject

Effective HSP length



160
# File 'lib/bio/appl/blast/report.rb', line 160

def hsp_len;   statistics['hsp-len'];   end

#inclusionObject

Inclusion threshold (-h) : shortcuts for @parameters



109
# File 'lib/bio/appl/blast/report.rb', line 109

def inclusion;    @parameters['include'].to_i;     end

#kappaObject

Karlin-Altschul parameter K



164
# File 'lib/bio/appl/blast/report.rb', line 164

def kappa;     statistics['kappa'];     end

#lambdaObject

Karlin-Altschul parameter Lamba



166
# File 'lib/bio/appl/blast/report.rb', line 166

def lambda;    statistics['lambda'];    end

#matrixObject

Matrix used (-M) : shortcuts for @parameters



105
# File 'lib/bio/appl/blast/report.rb', line 105

def matrix;       @parameters['matrix'];           end

#messageObject

Returns a String (or nil) containing execution message of the last iteration (typically “CONVERGED”). Shortcut for the last iteration’s message (for checking ‘CONVERGED’)



173
174
175
# File 'lib/bio/appl/blast/report.rb', line 173

def message
  @iterations.last.message
end

#patternObject

PHI-BLAST pattern : shortcuts for @parameters



121
# File 'lib/bio/appl/blast/report.rb', line 121

def pattern;      @parameters['pattern'];          end

#sc_matchObject

Match score for NT (-r) : shortcuts for @parameters



111
# File 'lib/bio/appl/blast/report.rb', line 111

def sc_match;     @parameters['sc-match'].to_i;    end

#sc_mismatchObject

Mismatch score for NT (-q) : shortcuts for @parameters



113
# File 'lib/bio/appl/blast/report.rb', line 113

def sc_mismatch;  @parameters['sc-mismatch'].to_i; end

#statisticsObject

Returns a Hash containing execution statistics of the last iteration. Valid keys are: ‘db-num’, ‘db-len’, ‘hsp-len’, ‘eff-space’, ‘kappa’, ‘lambda’, ‘entropy’ Shortcut for the last iteration’s statistics.



151
152
153
# File 'lib/bio/appl/blast/report.rb', line 151

def statistics
  @iterations.last.statistics
end