class Bio::Blast::Default::Report::Iteration
Bio::Blast::Default::Report::Iteration
stores information about a iteration. It may contain some Bio::Blast::Default::Report::Hit
objects. Note that a PSI-BLAST (blastpgp command) result usually contain multiple iterations in it, and a normal BLAST (blastall command) result usually contain one iteration in it.
Attributes
name (title or filename) of the database
number of sequences in database
number of letters in database
effective length of the database
entropy of the database
e-value threshold specified when BLAST was executed
gapped entropy of the database
gapped kappa of the database
gapped lambda of the database
kappa of the database
lambda of the database
(PSI-BLAST) Messages of the iteration.
(PSI-BLAST) Iteration
round number.
(PHI-BLAST) Number of occurrences of pattern in the database.
posted date of the database
Public Class Methods
Creates a new Iteration
object. It is designed to be called only internally from the Bio::Blast::Default::Report
class. Users shall not use the method directly.
# File lib/bio/appl/blast/format0.rb 492 def initialize(data) 493 @f0stat = [] 494 @f0dbstat = AlwaysNil.instance 495 @f0hitlist = [] 496 @hits = [] 497 @num = 1 498 r = data.shift 499 @f0message = [ r ] 500 r.gsub!(/^Results from round (\d+).*\z/) { |x| 501 @num = $1.to_i 502 @f0message << x 503 '' 504 } 505 r = data.shift 506 while /^Number of occurrences of pattern in the database is +(\d+)/ =~ r 507 # PHI-BLAST 508 @pattern_in_database = $1.to_i 509 @f0message << r 510 r = data.shift 511 end 512 if /^Results from round (\d+)/ =~ r then 513 @num = $1.to_i 514 @f0message << r 515 r = data.shift 516 end 517 if r and !(/\*{5} No hits found \*{5}/ =~ r) then 518 @f0hitlist << r 519 begin 520 @f0hitlist << data.shift 521 end until r = data[0] and /^\>/ =~ r 522 if r and /^CONVERGED\!/ =~ r then 523 r.sub!(/(.*\n)*^CONVERGED\!.*\n/) { |x| @f0hitlist << x; '' } 524 end 525 if defined?(@pattern_in_database) and r = data.first then 526 #PHI-BLAST 527 while /^\>/ =~ r 528 @hits << Hit.new(data) 529 r = data.first 530 break unless r 531 while /^Significant alignments for pattern/ =~ r 532 data.shift 533 r = data.first 534 end 535 end 536 else 537 #not PHI-BLAST 538 while r = data[0] and /^\>/ =~ r 539 @hits << Hit.new(data) 540 end 541 end 542 end 543 if /^CONVERGED\!\s*$/ =~ @f0hitlist[-1].to_s then 544 @message = 'CONVERGED!' 545 @flag_converged = true 546 end 547 end
Private Class Methods
Defines attributes which delegate to @f0dbstat objects.
# File lib/bio/appl/blast/format0.rb 766 def self.delegate_to_f0dbstat(*names) 767 names.each do |x| 768 module_eval("def #{x}; @f0dbstat.#{x}; end") 769 end 770 end
Defines attributes which call parse_stat
before accessing.
# File lib/bio/appl/blast/format0.rb 738 def self.method_after_parse_stat(*names) 739 names.each do |x| 740 module_eval("def #{x}; parse_stat; @#{x}; end") 741 end 742 end
Public Instance Methods
(PSI-BLAST) Returns true if the iteration is converged. Otherwise, returns false.
# File lib/bio/appl/blast/format0.rb 573 def converged? 574 @flag_converged 575 end
Iterates over each hit of the iteration. Yields a Bio::Blast::Default::Report::Hit
object.
# File lib/bio/appl/blast/format0.rb 565 def each 566 hits.each do |x| 567 yield x 568 end 569 end
Returns the hits of the iteration. It returns an array of Bio::Blast::Default::Report::Hit
objects.
# File lib/bio/appl/blast/format0.rb 558 def hits 559 parse_hitlist 560 @hits 561 end
(PHI-BLAST) Returns hits for pattern. ????
# File lib/bio/appl/blast/format0.rb 625 def hits_for_pattern 626 parse_hitlist 627 @hits_for_pattern 628 end
(PSI-BLAST) Returns hits which have been found again in the iteration. It returns an array of Bio::Blast::Default::Report::Hit
objects.
# File lib/bio/appl/blast/format0.rb 611 def hits_found_again 612 parse_hitlist 613 @hits_found_again 614 end
(PSI-BLAST) Returns hits which have been newly found in the iteration. It returns an array of Bio::Blast::Default::Report::Hit
objects.
# File lib/bio/appl/blast/format0.rb 619 def hits_newly_found 620 parse_hitlist 621 @hits_newly_found 622 end
(PHI-BLAST) Returns pattern string. Returns nil if it is not a PHI-BLAST result.
# File lib/bio/appl/blast/format0.rb 579 def pattern 580 #PHI-BLAST 581 if defined? @pattern 582 @pattern 583 elsif defined? @pattern_in_database then 584 @pattern = nil 585 @pattern_positions = [] 586 @f0message.each do |r| 587 sc = StringScanner.new(r) 588 if sc.skip_until(/^ *pattern +([^\s]+)/) then 589 @pattern = sc[1] unless @pattern 590 sc.skip_until(/(?:^ *| +)at position +(\d+) +of +query +sequence/) 591 @pattern_positions << sc[1].to_i 592 end 593 end 594 @pattern 595 else 596 nil 597 end 598 end
(PHI-BLAST) Returns pattern positions. Returns nil if it is not a PHI-BLAST result.
# File lib/bio/appl/blast/format0.rb 602 def pattern_positions 603 #PHI-BLAST 604 pattern 605 @pattern_positions 606 end
Private Instance Methods
Parses list of hits.
# File lib/bio/appl/blast/format0.rb 631 def parse_hitlist 632 unless defined?(@parse_hitlist) 633 @hits_found_again = [] 634 @hits_newly_found = [] 635 @hits_unknown_state = [] 636 i = 0 637 a = @hits_newly_found 638 flag = true 639 @f0hitlist.each do |x| 640 sc = StringScanner.new(x) 641 if flag then 642 if sc.skip_until(/^Sequences used in model and found again\:\s*$/) 643 a = @hits_found_again 644 end 645 flag = nil 646 next 647 end 648 next if sc.skip(/^CONVERGED\!$/) 649 if sc.skip(/^Sequences not found previously or not previously below threshold\:\s*$/) then 650 a = @hits_newly_found 651 next 652 elsif sc.skip(/^Sequences.+\:\s*$/) then 653 #possibly a bug or unknown format? 654 a = @hits_unknown_state 655 next 656 elsif sc.skip(/^Significant (matches|alignments) for pattern/) then 657 # PHI-BLAST 658 # do nothing when 'alignments' 659 if sc[1] == 'matches' then 660 unless defined?(@hits_for_pattern) 661 @hits_for_pattern = [] 662 end 663 a = [] 664 @hits_for_pattern << a 665 end 666 next 667 end 668 b = x.split(/^/) 669 b.collect! { |y| y.empty? ? nil : y } 670 b.compact! 671 if i + b.size > @hits.size then 672 ((@hits.size - i)...(b.size)).each do |j| 673 y = b[j]; y.strip! 674 y.reverse! 675 z = y.split(/\s+/, 3) 676 z.each { |yy| yy.reverse! } 677 h = Hit.new([ z.pop.to_s.sub(/\.+\z/, '') ]) 678 bs = z.pop.to_s 679 bs = '1' + bs if bs[0] == ?e 680 bs = (bs.empty? ? nil : bs.to_f) 681 ev = z.pop.to_s 682 ev = '1' + ev if ev[0] == ?e 683 ev = (ev.empty? ? (1.0/0.0) : ev.to_f) 684 h.instance_eval { @bit_score = bs; @evalue = ev } 685 @hits << h 686 end 687 end 688 a.concat(@hits[i, b.size]) 689 i += b.size 690 end #each 691 @hits_found_again.each do |x| 692 x.instance_eval { @again = true } 693 end 694 @parse_hitlist = true 695 end #unless 696 end
Parses statistics for the iteration.
# File lib/bio/appl/blast/format0.rb 700 def parse_stat 701 unless defined?(@parse_stat) 702 @f0stat.each do |x| 703 gapped = nil 704 sc = StringScanner.new(x) 705 sc.skip(/\s*/) 706 if sc.skip(/Gapped\s*/) then 707 gapped = true 708 end 709 s0 = [] 710 h = {} 711 while r = sc.scan(/\w+/) 712 #p r 713 s0 << r 714 sc.skip(/ */) 715 end 716 sc.skip(/\s*/) 717 while r = sc.scan(/[e\+\-\.\d]+/) 718 #p r 719 h[s0.shift] = r 720 sc.skip(/ */) 721 end 722 if gapped then 723 @gapped_lambda = (v = h['Lambda']) ? v.to_f : nil 724 @gapped_kappa = (v = h['K']) ? v.to_f : nil 725 @gapped_entropy = (v = h['H']) ? v.to_f : nil 726 else 727 @lambda = (v = h['Lambda']) ? v.to_f : nil 728 @kappa = (v = h['K']) ? v.to_f : nil 729 @entropy = (v = h['H']) ? v.to_f : nil 730 end 731 end #each 732 @parse_stat = true 733 end #unless 734 end