class Bio::Blast::Default::Report
Bio::Blast::Default::Report
parses NCBI
BLAST default output and stores information in the data. It may store some Bio::Blast::Default::Report::Iteration
objects.
Constants
- DELIMITER
Delimiter of each entry.
Bio::FlatFile
uses it.- DELIMITER_OVERRUN
(Integer) excess read size included in
DELIMITER
.
Attributes
number of letters in database
number of sequences in database
effective length of the database
piece of next entry. Bio::FlatFile
uses it.
e-value threshold specified when BLAST was executed
gap extend penalty
gap open penalty
(PSI-BLAST) Returns iterations. It returns an array of Bio::Blast::Default::Report::Iteration
class. Note that normal blastall result usually contains one iteration.
name of the matrix
number of hits. Note that this may differ from hits.size
.
posted date of the database
match score of the matrix
mismatch score of the matrix
Public Class Methods
Creates a new Report
object from BLAST result text.
# File lib/bio/appl/blast/format0.rb 48 def initialize(str) 49 str = str.sub(/\A\s+/, '') 50 str.sub!(/\n(T?BLAST.*)/m, "\n") # remove trailing entries for sure 51 @entry_overrun = $1 52 @entry = str 53 data = str.split(/(?:^[ \t]*\n)+/) 54 55 format0_split_headers(data) 56 @iterations = format0_split_search(data) 57 format0_split_stat_params(data) 58 end
Opens file by using Bio::FlatFile.open
.
# File lib/bio/appl/blast/format0.rb 43 def self.open(filename, *mode) 44 Bio::FlatFile.open(self, filename, *mode) 45 end
Private Class Methods
Defines attributes which delegate to @f0dbstat objects.
# File lib/bio/appl/blast/format0.rb 72 def self.delegate_to_f0dbstat(*names) 73 names.each do |x| 74 module_eval("def #{x}; @f0dbstat.#{x}; end") 75 end 76 end
Public Instance Methods
(PSI-BLAST) Same as iterations.last.converged?
. Returns true if the last iteration is converged, otherwise, returns false.
# File lib/bio/appl/blast/format0.rb 203 def converged? 204 @iterations.last.converged? 205 end
Returns the name (filename or title) of the database.
# File lib/bio/appl/blast/format0.rb 227 def db 228 unless defined?(@db) 229 if /Database *\: *(.*)/m =~ @f0database then 230 a = $1.split(/^/) 231 a.pop if a.size > 1 232 @db = a.collect { |x| x.sub(/\s+\z/, '') }.join(' ') 233 end 234 end #unless 235 @db 236 end
Iterates over each hit of the last iteration. Same as iterations.last.each_hit
. Yields a Bio::Blast::Default::Report::Hit
object. This is very useful in most cases, e.g. for blastall results.
# File lib/bio/appl/blast/format0.rb 178 def each_hit 179 @iterations.last.each do |x| 180 yield x 181 end 182 end
(PSI-BLAST) Iterates over each iteration. Same as iterations.each
. Yields a Bio::Blast::Default::Report::Iteration
object.
# File lib/bio/appl/blast/format0.rb 168 def each_iteration 169 @iterations.each do |x| 170 yield x 171 end 172 end
Same as iterations.last.entropy
.
# File lib/bio/appl/blast/format0.rb 128 def entropy; @iterations.last.entropy; end
Same as iterations.last.gapped_entropy
.
# File lib/bio/appl/blast/format0.rb 135 def gapped_entropy; @iterations.last.gapped_entropy; end
Same as iterations.last.gapped_kappa
.
# File lib/bio/appl/blast/format0.rb 131 def gapped_kappa; @iterations.last.gapped_kappa; end
Same as iterations.last.gapped_lambda
.
# File lib/bio/appl/blast/format0.rb 133 def gapped_lambda; @iterations.last.gapped_lambda; end
Same as iterations.last.hits
. Returns the last iteration's hits. Returns an array of Bio::Blast::Default::Report::Hit
object. This is very useful in most cases, e.g. for blastall results.
# File lib/bio/appl/blast/format0.rb 189 def hits 190 @iterations.last.hits 191 end
Same as iterations.last.kappa
.
# File lib/bio/appl/blast/format0.rb 124 def kappa; @iterations.last.kappa; end
Same as iterations.last.lambda
.
# File lib/bio/appl/blast/format0.rb 126 def lambda; @iterations.last.lambda; end
(PSI-BLAST) Same as iterations.last.message
.
# File lib/bio/appl/blast/format0.rb 195 def message 196 @iterations.last.message 197 end
(PHI-BLAST) Same as iterations.first.pattern
. Note that it returns the FIRST iteration's value.
# File lib/bio/appl/blast/format0.rb 155 def pattern; @iterations.first.pattern; end
(PHI-BLAST) Same as iterations.first.pattern_positions
. Note that it returns the FIRST iteration's value.
# File lib/bio/appl/blast/format0.rb 160 def pattern_positions 161 @iterations.first.pattern_positions 162 end
Returns program name.
# File lib/bio/appl/blast/format0.rb 138 def program; format0_parse_header; @program; end
Returns definition of the query.
# File lib/bio/appl/blast/format0.rb 150 def query_def; format0_parse_query; @query_def; end
Returns length of the query.
# File lib/bio/appl/blast/format0.rb 147 def query_len; format0_parse_query; @query_len; end
Returns the bibliography reference of the BLAST software. Note that this method shows only the first reference. When you want to get additional references, you can use references
method.
# File lib/bio/appl/blast/format0.rb 211 def reference 212 references[0] 213 end
Returns the bibliography references of the BLAST software. Returns an array of strings.
# File lib/bio/appl/blast/format0.rb 217 def references 218 unless defined?(@references) 219 @references = @f0references.collect do |x| 220 x.to_s.gsub(/\s+/, ' ').strip 221 end 222 end #unless 223 @references 224 end
Returns whole entry as a string.
# File lib/bio/appl/blast/format0.rb 69 def to_s; @entry; end
Returns version of the program.
# File lib/bio/appl/blast/format0.rb 140 def version; format0_parse_header; @version; end
Returns released date of the program.
# File lib/bio/appl/blast/format0.rb 144 def version_date; format0_parse_header; @version_date; end
Returns version number string of the program.
# File lib/bio/appl/blast/format0.rb 142 def version_number; format0_parse_header; @version_number; end
Private Instance Methods
Parses the first line of the BLAST result.
# File lib/bio/appl/blast/format0.rb 257 def format0_parse_header 258 unless defined?(@program) 259 if /([\-\w]+) +([\w\-\.]+) *\[ *([\-\.\w]+) *\] *(\[.+\])?/ =~ @f0header.to_s 260 @program = $1 261 @version = "#{$1} #{$2} [#{$3}]" 262 @version_number = $2 263 @version_date = $3 264 end 265 end 266 end
Parses the query lines (begins with “Query = ”).
# File lib/bio/appl/blast/format0.rb 240 def format0_parse_query 241 unless defined?(@query_def) 242 sc = StringScanner.new(@f0query) 243 sc.skip(/\s*/) 244 if sc.skip_until(/Query\= */) then 245 q = [] 246 begin 247 q << sc.scan(/.*/) 248 sc.skip(/\s*^ ?/) 249 end until !sc.rest or r = sc.skip(/ *\( *([\,\d]+) *letters *\)\s*\z/) 250 @query_len = sc[1].delete(',').to_i if r 251 @query_def = q.join(' ') 252 end 253 end 254 end
Splits headers into the first line, reference, query line and database line.
# File lib/bio/appl/blast/format0.rb 270 def format0_split_headers(data) 271 @f0header = data.shift 272 @f0references = [] 273 while data[0] and /\AQuery\=/ !~ data[0] 274 @f0references.push data.shift 275 end 276 @f0query = data.shift 277 # In special case, a void line is inserted after query name. 278 if data[0] and /\A +\( *([\,\d]+) *letters *\)\s*\z/ =~ data[0] then 279 @f0query.concat "\n" 280 @f0query.concat data.shift 281 end 282 @f0database = data.shift 283 # In special case, a void line is inserted after database name. 284 if data[0] and /\A +[\d\,]+ +sequences\; +[\d\,]+ total +letters\s*\z/ =~ data[0] then 285 @f0database.concat "\n" 286 @f0database.concat data.shift 287 end 288 end
Splits the search results.
# File lib/bio/appl/blast/format0.rb 309 def format0_split_search(data) 310 iterations = [] 311 while r = data[0] and /^Searching/ =~ r 312 iterations << Iteration.new(data) 313 end 314 iterations 315 end
Splits the statistical parameters.
# File lib/bio/appl/blast/format0.rb 291 def format0_split_stat_params(data) 292 dbs = [] 293 while r = data.first and /^ *Database\:/ =~ r 294 dbs << data.shift 295 end 296 @f0dbstat = self.class::F0dbstat.new(dbs) 297 i = -1 298 while r = data[0] and /^Lambda/ =~ r 299 #i -= 1 unless /^Gapped/ =~ r 300 if itr = @iterations[i] then 301 x = data.shift; itr.instance_eval { @f0stat << x } 302 x = @f0dbstat; itr.instance_eval { @f0dbstat = x } 303 end 304 end 305 @f0dbstat.f0params = data 306 end