Class: Bio::Sim4::Report

Inherits:
Object show all
Defined in:
lib/bio/appl/sim4/report.rb

Overview

Bio::Sim4::Report is the sim4 report parser class. Its object may contain some Bio::Sim4::Report::Hit objects.

Defined Under Namespace

Classes: Hit, Segment, SegmentPair, SeqDesc

Constant Summary

DELIMITER =

Delimiter of each entry. Bio::FlatFile uses it. In Bio::Sim4::Report, it it nil (1 entry 1 file).

RS = nil

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Report

Creates new Bio::Sim4::Report object from String. You can use Bio::FlatFile to read a file. Currently, format A=0, A=3, and A=4 are supported. (A=1, A=2, A=5 are NOT supported yet.)

Note that 'seq1' in sim4 result is always regarded as 'query', and 'seq2' is always regarded as 'subject'(target, hit).

Note that first 'seq1' informations are used for Bio::Sim4::Report#query_id, #query_def, #query_len, and #seq1 methods.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/bio/appl/sim4/report.rb', line 42

def initialize(text)
  @hits = []
  @all_hits = []
  overrun = ''
  text.each_line("\n\nseq1 = ") do |str|
    str = str.sub(/\A\s+/, '')
    str.sub!(/\n(^seq1 \= .*)/m, "\n") # remove trailing hits for sure
    tmp = $1.to_s
    hit = Hit.new(overrun + str)
    overrun = tmp
    unless hit.instance_eval { @data.empty? } then
      @hits << hit
    end
    @all_hits << hit
  end
  @seq1 = @all_hits[0].seq1
end

Instance Attribute Details

#all_hitsObject (readonly)

Returns all hits of the entry. Unlike Bio::Sim4::Report#hits, it returns results of all trials of pairwise alignment. This would be a Bio::Sim4 specific method. Returns an Array of Bio::Sim4::Report::Hit objects.



71
72
73
# File 'lib/bio/appl/sim4/report.rb', line 71

def all_hits
  @all_hits
end

#hitsObject (readonly)

Returns hits of the entry. Unlike Bio::Sim4::Report#all_hits, it returns hits which have alignments. Returns an Array of Bio::Sim4::Report::Hit objects.



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

def hits
  @hits
end

#seq1Object (readonly)

Returns sequence informations of 'seq1'. Returns a Bio::Sim4::Report::SeqDesc object. This would be a Bio::Sim4 specific method.



76
77
78
# File 'lib/bio/appl/sim4/report.rb', line 76

def seq1
  @seq1
end

Instance Method Details

#each_hit(&x) ⇒ Object Also known as: each

Iterates over each hits of the sim4 result. Same as hits.each. Yields a Bio::Sim4::Report::Hit object.



486
487
488
# File 'lib/bio/appl/sim4/report.rb', line 486

def each_hit(&x) #:yields: hit
  @hits.each(&x)
end

#num_hitsObject

Returns number of hits. Same as hits.size.



481
# File 'lib/bio/appl/sim4/report.rb', line 481

def num_hits;     @hits.size;     end

#query_defObject

Returns the definition of query sequence. The value will be filename or (first word of) sequence definition according to sim4 run-time options.



494
# File 'lib/bio/appl/sim4/report.rb', line 494

def query_def; @seq1.definition; end

#query_idObject

Returns the identifier of query sequence. The value will be filename or (first word of) sequence definition according to sim4 run-time options.



499
# File 'lib/bio/appl/sim4/report.rb', line 499

def query_id;  @seq1.entry_id;   end

#query_lenObject

Returns the length of query sequence.



502
# File 'lib/bio/appl/sim4/report.rb', line 502

def query_len; @seq1.len;        end