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, line 48 def initialize(str) str = str.sub(/\A\s+/, '') str.sub!(/\n(T?BLAST.*)/m, "\n") # remove trailing entries for sure @entry_overrun = $1 @entry = str data = str.split(/(?:^[ \t]*\n)+/) format0_split_headers(data) @iterations = format0_split_search(data) format0_split_stat_params(data) end
Opens file by using Bio::FlatFile.open.
# File lib/bio/appl/blast/format0.rb, line 43 def self.open(filename, *mode) Bio::FlatFile.open(self, filename, *mode) end
Private Class Methods
Defines attributes which delegate to @f0dbstat objects.
# File lib/bio/appl/blast/format0.rb, line 72 def self.delegate_to_f0dbstat(*names) names.each do |x| module_eval("def #{x}; @f0dbstat.#{x}; end") end 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, line 203 def converged? @iterations.last.converged? end
Returns the name (filename or title) of the database.
# File lib/bio/appl/blast/format0.rb, line 227 def db unless defined?(@db) if /Database *\: *(.*)/m =~ @f0database then a = $1.split(/^/) a.pop if a.size > 1 @db = a.collect { |x| x.sub(/\s+\z/, '') }.join(' ') end end #unless @db 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, line 178 def each_hit @iterations.last.each do |x| yield x end 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, line 168 def each_iteration @iterations.each do |x| yield x end end
Same as iterations.last.entropy
.
# File lib/bio/appl/blast/format0.rb, line 128 def entropy; @iterations.last.entropy; end
Same as iterations.last.gapped_entropy
.
# File lib/bio/appl/blast/format0.rb, line 135 def gapped_entropy; @iterations.last.gapped_entropy; end
Same as iterations.last.gapped_kappa
.
# File lib/bio/appl/blast/format0.rb, line 131 def gapped_kappa; @iterations.last.gapped_kappa; end
Same as iterations.last.gapped_lambda
.
# File lib/bio/appl/blast/format0.rb, line 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, line 189 def hits @iterations.last.hits end
Same as iterations.last.kappa
.
# File lib/bio/appl/blast/format0.rb, line 124 def kappa; @iterations.last.kappa; end
Same as iterations.last.lambda
.
# File lib/bio/appl/blast/format0.rb, line 126 def lambda; @iterations.last.lambda; end
(PSI-BLAST) Same as iterations.last.message
.
# File lib/bio/appl/blast/format0.rb, line 195 def message @iterations.last.message end
(PHI-BLAST) Same as iterations.first.pattern
. Note that it
returns the FIRST iteration's value.
# File lib/bio/appl/blast/format0.rb, line 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, line 160 def pattern_positions @iterations.first.pattern_positions end
Returns program name.
# File lib/bio/appl/blast/format0.rb, line 138 def program; format0_parse_header; @program; end
Returns definition of the query.
# File lib/bio/appl/blast/format0.rb, line 150 def query_def; format0_parse_query; @query_def; end
Returns length of the query.
# File lib/bio/appl/blast/format0.rb, line 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, line 211 def reference references[0] end
Returns the bibliography references of the BLAST software. Returns an array of strings.
# File lib/bio/appl/blast/format0.rb, line 217 def references unless defined?(@references) @references = @f0references.collect do |x| x.to_s.gsub(/\s+/, ' ').strip end end #unless @references end
Returns whole entry as a string.
# File lib/bio/appl/blast/format0.rb, line 69 def to_s; @entry; end
Returns version of the program.
# File lib/bio/appl/blast/format0.rb, line 140 def version; format0_parse_header; @version; end
Returns released date of the program.
# File lib/bio/appl/blast/format0.rb, line 144 def version_date; format0_parse_header; @version_date; end
Returns version number string of the program.
# File lib/bio/appl/blast/format0.rb, line 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, line 257 def format0_parse_header unless defined?(@program) if /([\-\w]+) +([\w\-\.\d]+) *\[ *([\-\.\w]+) *\] *(\[.+\])?/ =~ @f0header.to_s @program = $1 @version = "#{$1} #{$2} [#{$3}]" @version_number = $2 @version_date = $3 end end end
Parses the query lines (begins with “Query = ”).
# File lib/bio/appl/blast/format0.rb, line 240 def format0_parse_query unless defined?(@query_def) sc = StringScanner.new(@f0query) sc.skip(/\s*/) if sc.skip_until(/Query\= */) then q = [] begin q << sc.scan(/.*/) sc.skip(/\s*^ ?/) end until !sc.rest or r = sc.skip(/ *\( *([\,\d]+) *letters *\)\s*\z/) @query_len = sc[1].delete(',').to_i if r @query_def = q.join(' ') end end end
Splits headers into the first line, reference, query line and database line.
# File lib/bio/appl/blast/format0.rb, line 270 def format0_split_headers(data) @f0header = data.shift @f0references = [] while data[0] and /\AQuery\=/ !~ data[0] @f0references.push data.shift end @f0query = data.shift # In special case, a void line is inserted after query name. if data[0] and /\A +\( *([\,\d]+) *letters *\)\s*\z/ =~ data[0] then @f0query.concat "\n" @f0query.concat data.shift end @f0database = data.shift # In special case, a void line is inserted after database name. if data[0] and /\A +[\d\,]+ +sequences\; +[\d\,]+ total +letters\s*\z/ =~ data[0] then @f0database.concat "\n" @f0database.concat data.shift end end
Splits the search results.
# File lib/bio/appl/blast/format0.rb, line 309 def format0_split_search(data) iterations = [] while r = data[0] and /^Searching/ =~ r iterations << Iteration.new(data) end iterations end
Splits the statistical parameters.
# File lib/bio/appl/blast/format0.rb, line 291 def format0_split_stat_params(data) dbs = [] while r = data.first and /^ *Database\:/ =~ r dbs << data.shift end @f0dbstat = self.class::F0dbstat.new(dbs) i = -1 while r = data[0] and /^Lambda/ =~ r #i -= 1 unless /^Gapped/ =~ r if itr = @iterations[i] then x = data.shift; itr.instance_eval { @f0stat << x } x = @f0dbstat; itr.instance_eval { @f0dbstat = x } end end @f0dbstat.f0params = data end