Class: Bio::Blast::Report
- 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
Direct Known Subclasses
Defined Under Namespace
Classes: BlastXmlSplitter, Hit, Hsp, Iteration
Constant Summary collapse
- DELIMITER =
for Bio::FlatFile support (only for XML data)
RS = "</BlastOutput>\n"
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
database name or title (String).
-
#iterations ⇒ Object
readonly
Returns an Array of Bio::Blast::Report::Iteration objects.
-
#parameters ⇒ Object
readonly
Returns a Hash containing execution parameters.
-
#program ⇒ Object
readonly
program name (e.g. “blastp”) (String).
-
#query_def ⇒ Object
readonly
query definition line (String).
-
#query_id ⇒ Object
readonly
query ID (String).
-
#query_len ⇒ Object
readonly
query length (Integer).
-
#reference ⇒ Object
readonly
reference (String).
-
#reports ⇒ Object
readonly
When the report contains results for multiple query sequences, returns an array of Bio::Blast::Report objects corresponding to the multiple queries.
-
#version ⇒ Object
readonly
BLAST version (e.g. “blastp 2.2.18 [Mar-02-2008]”) (String).
Class Method Summary collapse
-
.rexml(data) ⇒ Object
Specify to use REXML to parse XML (-m 7) output.
-
.tab(data) ⇒ Object
Specify to use tab delimited output parser.
-
.xmlparser(data) ⇒ Object
Specify to use XMLParser to parse XML (-m 7) output.
Instance Method Summary collapse
-
#db_len ⇒ Object
Length of BLAST db.
-
#db_num ⇒ Object
Number of sequences in BLAST db.
-
#each_hit ⇒ Object
(also: #each)
Iterates on each Bio::Blast::Report::Hit object of the the last Iteration.
-
#each_iteration ⇒ Object
Iterates on each Bio::Blast::Report::Iteration object.
-
#eff_space ⇒ Object
Effective search space.
-
#entrez_query ⇒ Object
Limit of request to Entrez : shortcuts for @parameters.
-
#entropy ⇒ Object
Karlin-Altschul parameter H.
-
#expect ⇒ Object
Expectation threshold (-e) : shortcuts for @parameters.
-
#filter ⇒ Object
Filtering options (-F) : shortcuts for @parameters.
-
#gap_extend ⇒ Object
Gap extension cost (-E) : shortcuts for @parameters.
-
#gap_open ⇒ Object
Gap opening cost (-G) : shortcuts for @parameters.
-
#hits ⇒ Object
Returns a Array of Bio::Blast::Report::Hits of the last iteration.
-
#hsp_len ⇒ Object
Effective HSP length.
-
#inclusion ⇒ Object
Inclusion threshold (-h) : shortcuts for @parameters.
-
#initialize(data, parser = nil) ⇒ Report
constructor
Passing a BLAST output from ‘blastall -m 7’ or ‘-m 8’ as a String.
-
#kappa ⇒ Object
Karlin-Altschul parameter K.
-
#lambda ⇒ Object
Karlin-Altschul parameter Lamba.
-
#matrix ⇒ Object
Matrix used (-M) : shortcuts for @parameters.
-
#message ⇒ Object
Returns a String (or nil) containing execution message of the last iteration (typically “CONVERGED”).
-
#pattern ⇒ Object
PHI-BLAST pattern : shortcuts for @parameters.
-
#sc_match ⇒ Object
Match score for NT (-r) : shortcuts for @parameters.
-
#sc_mismatch ⇒ Object
Mismatch score for NT (-q) : shortcuts for @parameters.
-
#statistics ⇒ Object
Returns a Hash containing execution statistics of the last iteration.
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.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/bio/appl/blast/report.rb', line 81 def initialize(data, parser = nil) @iterations = [] @parameters = {} case parser when :xmlparser # format 7 xmlparser_parse(data) @reports = blastxml_split_reports when :rexml # format 7 rexml_parse(data) @reports = blastxml_split_reports when :tab # format 8 tab_parse(data) when false # do not parse, creates an empty object else auto_parse(data) end end |
Instance Attribute Details
#db ⇒ Object (readonly)
database name or title (String)
122 123 124 |
# File 'lib/bio/appl/blast/report.rb', line 122 def db @db end |
#iterations ⇒ Object (readonly)
Returns an Array of Bio::Blast::Report::Iteration objects.
101 102 103 |
# File 'lib/bio/appl/blast/report.rb', line 101 def iterations @iterations end |
#parameters ⇒ Object (readonly)
Returns a Hash containing execution parameters. Valid keys are: ‘matrix’, ‘expect’, ‘include’, ‘sc-match’, ‘sc-mismatch’, ‘gap-open’, ‘gap-extend’, ‘filter’
106 107 108 |
# File 'lib/bio/appl/blast/report.rb', line 106 def parameters @parameters end |
#program ⇒ Object (readonly)
program name (e.g. “blastp”) (String)
113 114 115 |
# File 'lib/bio/appl/blast/report.rb', line 113 def program @program end |
#query_def ⇒ Object (readonly)
query definition line (String)
128 129 130 |
# File 'lib/bio/appl/blast/report.rb', line 128 def query_def @query_def end |
#query_id ⇒ Object (readonly)
query ID (String)
125 126 127 |
# File 'lib/bio/appl/blast/report.rb', line 125 def query_id @query_id end |
#query_len ⇒ Object (readonly)
query length (Integer)
131 132 133 |
# File 'lib/bio/appl/blast/report.rb', line 131 def query_len @query_len end |
#reference ⇒ Object (readonly)
reference (String)
119 120 121 |
# File 'lib/bio/appl/blast/report.rb', line 119 def reference @reference end |
#reports ⇒ Object (readonly)
When the report contains results for multiple query sequences, returns an array of Bio::Blast::Report objects corresponding to the multiple queries. Otherwise, returns nil.
Note for “No hits found”: When no hits found for a query sequence, the result for the query is completely void and no information available in the result XML, including query ID and query definition. The only trace is that iteration number is skipped. This means that if the no-hit query is the last query, the query can not be detected, because the result XML is completely the same as the result XML without the query.
379 380 381 |
# File 'lib/bio/appl/blast/report.rb', line 379 def reports @reports end |
#version ⇒ Object (readonly)
BLAST version (e.g. “blastp 2.2.18 [Mar-02-2008]”) (String)
116 117 118 |
# File 'lib/bio/appl/blast/report.rb', line 116 def version @version end |
Class Method Details
.rexml(data) ⇒ Object
Specify to use REXML to parse XML (-m 7) output.
55 56 57 |
# File 'lib/bio/appl/blast/report.rb', line 55 def self.rexml(data) self.new(data, :rexml) end |
.tab(data) ⇒ Object
Specify to use tab delimited output parser.
60 61 62 |
# File 'lib/bio/appl/blast/report.rb', line 60 def self.tab(data) self.new(data, :tab) end |
.xmlparser(data) ⇒ Object
Specify to use XMLParser to parse XML (-m 7) output.
50 51 52 |
# File 'lib/bio/appl/blast/report.rb', line 50 def self.xmlparser(data) self.new(data, :xmlparser) end |
Instance Method Details
#db_len ⇒ Object
Length of BLAST db
187 |
# File 'lib/bio/appl/blast/report.rb', line 187 def db_len; statistics['db-len']; end |
#db_num ⇒ Object
Number of sequences in BLAST db
185 |
# File 'lib/bio/appl/blast/report.rb', line 185 def db_num; statistics['db-num']; end |
#each_hit ⇒ Object 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)
163 164 165 166 167 |
# File 'lib/bio/appl/blast/report.rb', line 163 def each_hit @iterations.last.each do |x| yield x end end |
#each_iteration ⇒ Object
Iterates on each Bio::Blast::Report::Iteration object. (for blastpgp)
155 156 157 158 159 |
# File 'lib/bio/appl/blast/report.rb', line 155 def each_iteration @iterations.each do |x| yield x end end |
#eff_space ⇒ Object
Effective search space
191 |
# File 'lib/bio/appl/blast/report.rb', line 191 def eff_space; statistics['eff-space']; end |
#entrez_query ⇒ Object
Limit of request to Entrez : shortcuts for @parameters
152 |
# File 'lib/bio/appl/blast/report.rb', line 152 def entrez_query; @parameters['entrez-query']; end |
#entropy ⇒ Object
Karlin-Altschul parameter H
197 |
# File 'lib/bio/appl/blast/report.rb', line 197 def entropy; statistics['entropy']; end |
#expect ⇒ Object
Expectation threshold (-e) : shortcuts for @parameters
136 |
# File 'lib/bio/appl/blast/report.rb', line 136 def expect; @parameters['expect']; end |
#filter ⇒ Object
Filtering options (-F) : shortcuts for @parameters
148 |
# File 'lib/bio/appl/blast/report.rb', line 148 def filter; @parameters['filter']; end |
#gap_extend ⇒ Object
Gap extension cost (-E) : shortcuts for @parameters
146 |
# File 'lib/bio/appl/blast/report.rb', line 146 def gap_extend; @parameters['gap-extend']; end |
#gap_open ⇒ Object
Gap opening cost (-G) : shortcuts for @parameters
144 |
# File 'lib/bio/appl/blast/report.rb', line 144 def gap_open; @parameters['gap-open']; end |
#hits ⇒ Object
Returns a Array of Bio::Blast::Report::Hits of the last iteration. Shortcut for the last iteration’s hits
172 173 174 |
# File 'lib/bio/appl/blast/report.rb', line 172 def hits @iterations.last.hits end |
#hsp_len ⇒ Object
Effective HSP length
189 |
# File 'lib/bio/appl/blast/report.rb', line 189 def hsp_len; statistics['hsp-len']; end |
#inclusion ⇒ Object
Inclusion threshold (-h) : shortcuts for @parameters
138 |
# File 'lib/bio/appl/blast/report.rb', line 138 def inclusion; @parameters['include']; end |
#kappa ⇒ Object
Karlin-Altschul parameter K
193 |
# File 'lib/bio/appl/blast/report.rb', line 193 def kappa; statistics['kappa']; end |
#lambda ⇒ Object
Karlin-Altschul parameter Lamba
195 |
# File 'lib/bio/appl/blast/report.rb', line 195 def lambda; statistics['lambda']; end |
#matrix ⇒ Object
Matrix used (-M) : shortcuts for @parameters
134 |
# File 'lib/bio/appl/blast/report.rb', line 134 def matrix; @parameters['matrix']; end |
#message ⇒ Object
Returns a String (or nil) containing execution message of the last iteration (typically “CONVERGED”). Shortcut for the last iteration’s message (for checking ‘CONVERGED’)
202 203 204 |
# File 'lib/bio/appl/blast/report.rb', line 202 def @iterations.last. end |
#pattern ⇒ Object
PHI-BLAST pattern : shortcuts for @parameters
150 |
# File 'lib/bio/appl/blast/report.rb', line 150 def pattern; @parameters['pattern']; end |
#sc_match ⇒ Object
Match score for NT (-r) : shortcuts for @parameters
140 |
# File 'lib/bio/appl/blast/report.rb', line 140 def sc_match; @parameters['sc-match']; end |
#sc_mismatch ⇒ Object
Mismatch score for NT (-q) : shortcuts for @parameters
142 |
# File 'lib/bio/appl/blast/report.rb', line 142 def sc_mismatch; @parameters['sc-mismatch']; end |
#statistics ⇒ Object
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.
180 181 182 |
# File 'lib/bio/appl/blast/report.rb', line 180 def statistics @iterations.last.statistics end |