Class: Bio::Blast::Default::Report::Iteration

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/appl/blast/format0.rb

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Iteration

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.



479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
# File 'lib/bio/appl/blast/format0.rb', line 479

def initialize(data)
  @f0stat = []
  @f0dbstat = AlwaysNil.instance
  @f0hitlist = []
  @hits = []
  @num = 1
  r = data.shift
  @f0message = [ r ]
  r.gsub!(/^Results from round (\d+).*\z/) { |x|
    @num = $1.to_i
    @f0message << x
    ''
  }
  r = data.shift
  while /^Number of occurrences of pattern in the database is +(\d+)/ =~ r
    # PHI-BLAST
    @pattern_in_database = $1.to_i
    @f0message << r
    r = data.shift
  end
  if /^Results from round (\d+)/ =~ r then
    @num = $1.to_i
    @f0message << r
    r = data.shift
  end
  if r and !(/\*{5} No hits found \*{5}/ =~ r) then
    @f0hitlist << r
    begin
      @f0hitlist << data.shift
    end until r = data[0] and /^\>/ =~ r
    if r and /^CONVERGED\!/ =~ r then
      r.sub!(/(.*\n)*^CONVERGED\!.*\n/) { |x| @f0hitlist << x; '' }
    end
    if defined?(@pattern_in_database) and r = data.first then
      #PHI-BLAST
      while /^\>/ =~ r
        @hits << Hit.new(data)
        r = data.first
        break unless r
        if /^Significant alignments for pattern/ =~ r
          data.shift
          r = data.first
        end
      end
    else
      #not PHI-BLAST
      while r = data[0] and /^\>/ =~ r
        @hits << Hit.new(data)
      end
    end
  end
  if /^CONVERGED\!\s*$/ =~ @f0hitlist[-1].to_s then
    @message = 'CONVERGED!'
    @flag_converged = true
  end
end

Instance Attribute Details

#databaseObject (readonly)

name (title or filename) of the database



757
758
759
# File 'lib/bio/appl/blast/format0.rb', line 757

def database
  @database
end

#db_lenObject (readonly)

number of sequences in database



767
768
769
# File 'lib/bio/appl/blast/format0.rb', line 767

def db_len
  @db_len
end

#db_numObject (readonly)

number of letters in database



764
765
766
# File 'lib/bio/appl/blast/format0.rb', line 764

def db_num
  @db_num
end

#eff_spaceObject (readonly)

effective length of the database



770
771
772
# File 'lib/bio/appl/blast/format0.rb', line 770

def eff_space
  @eff_space
end

#entropyObject (readonly)

entropy of the database



735
736
737
# File 'lib/bio/appl/blast/format0.rb', line 735

def entropy
  @entropy
end

#expectObject (readonly)

e-value threshold specified when BLAST was executed



774
775
776
# File 'lib/bio/appl/blast/format0.rb', line 774

def expect
  @expect
end

#gapped_entropyObject (readonly)

gapped entropy of the database



745
746
747
# File 'lib/bio/appl/blast/format0.rb', line 745

def gapped_entropy
  @gapped_entropy
end

#gapped_kappaObject (readonly)

gapped kappa of the database



742
743
744
# File 'lib/bio/appl/blast/format0.rb', line 742

def gapped_kappa
  @gapped_kappa
end

#gapped_lambdaObject (readonly)

gapped lambda of the database



739
740
741
# File 'lib/bio/appl/blast/format0.rb', line 739

def gapped_lambda
  @gapped_lambda
end

#kappaObject (readonly)

kappa of the database



732
733
734
# File 'lib/bio/appl/blast/format0.rb', line 732

def kappa
  @kappa
end

#lambdaObject (readonly)

lambda of the database



729
730
731
# File 'lib/bio/appl/blast/format0.rb', line 729

def lambda
  @lambda
end

#messageObject (readonly)

(PSI-BLAST) Messages of the iteration.



539
540
541
# File 'lib/bio/appl/blast/format0.rb', line 539

def message
  @message
end

#numObject (readonly)

(PSI-BLAST) Iteration round number.



537
538
539
# File 'lib/bio/appl/blast/format0.rb', line 537

def num
  @num
end

#pattern_in_databaseObject (readonly)

(PHI-BLAST) Number of occurrences of pattern in the database.



541
542
543
# File 'lib/bio/appl/blast/format0.rb', line 541

def pattern_in_database
  @pattern_in_database
end

#posted_dateObject (readonly)

posted date of the database



760
761
762
# File 'lib/bio/appl/blast/format0.rb', line 760

def posted_date
  @posted_date
end

Instance Method Details

#converged?Boolean

(PSI-BLAST) Returns true if the iteration is converged. Otherwise, returns false.

Returns:

  • (Boolean)


560
561
562
# File 'lib/bio/appl/blast/format0.rb', line 560

def converged?
  @flag_converged
end

#eachObject

Iterates over each hit of the iteration. Yields a Bio::Blast::Default::Report::Hit object.



552
553
554
555
556
# File 'lib/bio/appl/blast/format0.rb', line 552

def each
  hits.each do |x|
    yield x
  end
end

#hitsObject

Returns the hits of the iteration. It returns an array of Bio::Blast::Default::Report::Hit objects.



545
546
547
548
# File 'lib/bio/appl/blast/format0.rb', line 545

def hits
  parse_hitlist
  @hits
end

#hits_for_patternObject

(PHI-BLAST) Returns hits for pattern. ????



608
609
610
611
# File 'lib/bio/appl/blast/format0.rb', line 608

def hits_for_pattern
  parse_hitlist
  @hits_for_pattern
end

#hits_found_againObject

(PSI-BLAST) Returns hits which have been found again in the iteration. It returns an array of Bio::Blast::Default::Report::Hit objects.



594
595
596
597
# File 'lib/bio/appl/blast/format0.rb', line 594

def hits_found_again
  parse_hitlist
  @hits_found_again
end

#hits_newly_foundObject

(PSI-BLAST) Returns hits which have been newly found in the iteration. It returns an array of Bio::Blast::Default::Report::Hit objects.



602
603
604
605
# File 'lib/bio/appl/blast/format0.rb', line 602

def hits_newly_found
  parse_hitlist
  @hits_newly_found
end

#patternObject

(PHI-BLAST) Returns pattern string. Returns nil if it is not a PHI-BLAST result.



566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
# File 'lib/bio/appl/blast/format0.rb', line 566

def pattern
  #PHI-BLAST
  if !defined?(@pattern) and defined?(@pattern_in_database) then
    @pattern = nil
    @pattern_positions = []
    @f0message.each do |r|
      sc = StringScanner.new(r)
      if sc.skip_until(/^ *pattern +(.+)$/) then
        @pattern = sc[1] unless @pattern
        sc.skip_until(/^ at position +(\d+)/)
        @pattern_positions << sc[1].to_i
      end
    end
  end
  @pattern
end

#pattern_positionsObject

(PHI-BLAST) Returns pattern positions. Returns nil if it is not a PHI-BLAST result.



585
586
587
588
589
# File 'lib/bio/appl/blast/format0.rb', line 585

def pattern_positions
  #PHI-BLAST
  pattern
  @pattern_positions
end