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

Direct Known Subclasses

Report_tab

Defined Under Namespace

Classes: BlastXmlSplitter, Hit, Hsp, Iteration

Constant Summary

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

- (Report) initialize(data, parser = nil)

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



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/bio/appl/blast/report.rb', line 85

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

- (Object) db (readonly)

database name or title (String)



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

def db
  @db
end

- (Object) iterations (readonly)

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



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

def iterations
  @iterations
end

- (Object) parameters (readonly)

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



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

def parameters
  @parameters
end

- (Object) program (readonly)

program name (e.g. “blastp”) (String)



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

def program
  @program
end

- (Object) query_def (readonly)

query definition line (String)



132
133
134
# File 'lib/bio/appl/blast/report.rb', line 132

def query_def
  @query_def
end

- (Object) query_id (readonly)

query ID (String)



129
130
131
# File 'lib/bio/appl/blast/report.rb', line 129

def query_id
  @query_id
end

- (Object) query_len (readonly)

query length (Integer)



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

def query_len
  @query_len
end

- (Object) reference (readonly)

reference (String)



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

def reference
  @reference
end

- (Object) reports (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.



383
384
385
# File 'lib/bio/appl/blast/report.rb', line 383

def reports
  @reports
end

- (Object) version (readonly)

BLAST version (e.g. “blastp 2.2.18 [Mar-02-2008]”) (String)



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

def version
  @version
end

Class Method Details

+ (Object) rexml(data)

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



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

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

+ (Object) tab(data)

Specify to use tab delimited output parser.



64
65
66
# File 'lib/bio/appl/blast/report.rb', line 64

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

+ (Object) xmlparser(data)

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



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

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

Instance Method Details

- (Object) db_len

Length of BLAST db



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

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

- (Object) db_num

Number of sequences in BLAST db



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

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

- (Object) each_hit 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)



167
168
169
170
171
# File 'lib/bio/appl/blast/report.rb', line 167

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

- (Object) each_iteration

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



159
160
161
162
163
# File 'lib/bio/appl/blast/report.rb', line 159

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

- (Object) eff_space

Effective search space



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

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

- (Object) entrez_query

Limit of request to Entrez : shortcuts for @parameters



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

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

- (Object) entropy

Karlin-Altschul parameter H



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

def entropy;   statistics['entropy'];   end

- (Object) expect

Expectation threshold (-e) : shortcuts for @parameters



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

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

- (Object) filter

Filtering options (-F) : shortcuts for @parameters



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

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

- (Object) gap_extend

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



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

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

- (Object) gap_open

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



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

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

- (Object) hits

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



176
177
178
# File 'lib/bio/appl/blast/report.rb', line 176

def hits
  @iterations.last.hits
end

- (Object) hsp_len

Effective HSP length



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

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

- (Object) inclusion

Inclusion threshold (-h) : shortcuts for @parameters



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

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

- (Object) kappa

Karlin-Altschul parameter K



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

def kappa;     statistics['kappa'];     end

- (Object) lambda

Karlin-Altschul parameter Lamba



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

def lambda;    statistics['lambda'];    end

- (Object) matrix

Matrix used (-M) : shortcuts for @parameters



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

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

- (Object) message

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



206
207
208
# File 'lib/bio/appl/blast/report.rb', line 206

def message
  @iterations.last.message
end

- (Object) pattern

PHI-BLAST pattern : shortcuts for @parameters



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

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

- (Object) sc_match

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



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

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

- (Object) sc_mismatch

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



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

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

- (Object) statistics

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.



184
185
186
# File 'lib/bio/appl/blast/report.rb', line 184

def statistics
  @iterations.last.statistics
end