class Bio::Sim4::Report::Hit

Hit object of the sim4 result. Similar to Bio::Blast::Report::Hit but lacks many methods.

Attributes

seq1[R]

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

seq2[R]

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

Public Class Methods

new(str) click to toggle source

Parses part of sim4 result text and creates a new Hit object. It is designed to be called internally from Bio::Sim4::Report class. Users shall not use it directly.

    # File lib/bio/appl/sim4/report.rb
273 def initialize(str)
274   @data = str.split(/\n(?:\r?\n)+/)
275   parse_seqdesc
276 end

Public Instance Methods

align() click to toggle source

Returns alignments. Returns an Array of arrays. Each array contains sequence of seq1, midline, sequence of seq2, respectively. This would be a Bio::Sim4 specific method.

    # File lib/bio/appl/sim4/report.rb
432 def align
433   unless defined?(@align); parse_align; end
434   @align
435 end
complement?() click to toggle source

Returns true if the hit reports '-'(complemental) strand search result. Otherwise, return false or nil. This would be a Bio::Sim4 specific method.

    # File lib/bio/appl/sim4/report.rb
313 def complement?
314   @complement
315 end
definition()
Alias for: target_def
each() { |segmentpair| ... } click to toggle source

Iterates over each exon of the hit. Yields a Bio::Sim4::Report::SegmentPair object.

    # File lib/bio/appl/sim4/report.rb
470 def each(&x) #:yields: segmentpair
471   exons.each(&x)
472 end
exons() click to toggle source

Returns exons of the hit. Each exon is a Bio::Sim4::Report::SegmentPair object.

    # File lib/bio/appl/sim4/report.rb
402 def exons
403   unless defined?(@exons); parse_segmentpairs; end
404   @exons
405 end
Also aliased as: hsps
hit_id()
Alias for: target_id
hsps()
Alias for: exons
introns() click to toggle source

Returns introns of the hit. Some of them would contain untranscribed regions. Returns an array of Bio::Sim4::Report::SegmentPair objects. (Note that intron data is not always available according to run-time options of the program.)

    # File lib/bio/appl/sim4/report.rb
422 def introns
423   unless defined?(@introns); parse_segmentpairs; end
424   @introns
425 end
len()
Alias for: target_len
query_def() click to toggle source

Definition of the query sequence Same as Bio::Sim4::Report#query_def.

    # File lib/bio/appl/sim4/report.rb
451 def query_def;  seq1.definition; end
query_id() click to toggle source

Identifier of the query sequence. Same as Bio::Sim4::Report#query_id.

    # File lib/bio/appl/sim4/report.rb
447 def query_id;   seq1.entry_id;   end
query_len() click to toggle source

Length of the query sequence. Same as Bio::Sim4::Report#query_len.

    # File lib/bio/appl/sim4/report.rb
443 def query_len;  seq1.len;        end
segmentpairs() click to toggle source

Returns segment pairs (exons and introns) of the hit. Each segment pair is a Bio::Sim4::Report::SegmentPair object. Returns an array of Bio::Sim4::Report::SegmentPair objects. (Note that intron data is not always available according to run-time options of the program.)

    # File lib/bio/appl/sim4/report.rb
412 def segmentpairs
413   unless defined?(@segmentpairs); parse_segmentpairs; end
414   @segmentpairs
415 end
target_def() click to toggle source

Definition of the hit(target) sequence

    # File lib/bio/appl/sim4/report.rb
460 def target_def; seq2.definition; end
Also aliased as: definition
target_id() click to toggle source

Identifier of the hit(target) sequence

    # File lib/bio/appl/sim4/report.rb
457 def target_id;  seq2.entry_id;   end
Also aliased as: hit_id
target_len() click to toggle source

length of the hit(target) sequence

    # File lib/bio/appl/sim4/report.rb
454 def target_len; seq2.len;        end
Also aliased as: len

Private Instance Methods

parse_align() click to toggle source

Parses alignment.

    # File lib/bio/appl/sim4/report.rb
352 def parse_align
353   s1 = []; ml = []; s2 = []
354   blocks = []
355   blocks.push [ s1, ml, s2 ]
356   dat = @data[1..-1]
357   return unless dat
358   dat.each do |str|
359     a = str.split(/\r?\n/)
360     ruler = a.shift
361     # First line, for example,
362     # "     50     .    :    .    :    .    :    .    :    .    :"
363     # When the number is 0, forced to be a separated block
364     if /^\s*(\d+)/ =~ ruler and $1.to_i == 0 and !ml.empty? then
365       s1 = []; ml = []; s2 = []
366       blocks.push [ s1, ml, s2 ]
367     end
368     # For example,
369     # "    190 GAGTCATGCATGATACAA          CTTATATATGTACTTAGCGGCA"
370     # "        ||||||||||||||||||<<<...<<<-||-|||||||||||||||||||"
371     # "    400 GAGTCATGCATGATACAACTT...AGCGCT ATATATGTACTTAGCGGCA"
372     if /^(\s*\d+\s)(.+)$/ =~ a[0] then
373       range = ($1.length)..($1.length + $2.chomp.length - 1)
374       a.collect! { |x| x[range] }
375       s1 << a.shift
376       ml << a.shift
377       s2 << a.shift
378     end
379   end #each
380   alx_all = []
381   blocks.each do |ary|
382     s1, ml, s2 = ary
383     alx  = ml.join('').split(/([\<\>]+\.+[\<\>]+)/)
384     seq1 = s1.join(''); seq2 = s2.join('')
385     i = 0
386     alx.collect! do |x|
387       len = x.length
388       y = [ seq1[i, len], x, seq2[i, len] ]
389       i += len
390       y
391     end
392     # adds virtual intron information if necessary
393     alx_all.push([ '', '', '' ]) unless alx_all.empty?
394     alx_all.concat alx
395   end
396   @align = alx_all
397 end
parse_segmentpairs() click to toggle source

Parses segment pair.

    # File lib/bio/appl/sim4/report.rb
318 def parse_segmentpairs
319   aln = (self.align ? self.align.dup : [])
320   exo = [] #exons
321   itr = [] #introns
322   sgp = [] #segmentpairs
323   prev_e = nil
324   return unless @data[0]
325   @data[0].split(/\r?\n/).each do |str|
326     ai = (prev_e ? aln.shift : nil)
327     a = (aln.shift or [])
328     e = SegmentPair.parse(str, a)
329     exo << e
330     if ai then
331       # intron data in alignment
332       if ai[1].strip.empty? then
333         i = SegmentPair.both_intron(prev_e, e, ai)
334       elsif ai[2].strip.empty? then
335         i = SegmentPair.seq1_intron(prev_e, e, ai)
336       else
337         i = SegmentPair.seq2_intron(prev_e, e, ai)
338       end
339       itr << i
340       sgp << i
341     end
342     sgp << e
343     prev_e = e
344   end
345   @exons        = exo
346   @introns      = itr
347   @segmentpairs = sgp
348 end
parse_seqdesc() click to toggle source

Parses sequence descriptions.

    # File lib/bio/appl/sim4/report.rb
279 def parse_seqdesc
280   # seq1: query, seq2: target(hit)
281   a0 = @data.shift.split(/\r?\n/)
282   if @data[0].to_s =~ /^\>/ then
283     a1 = @data.shift.split(/\r?\n/)
284   else
285     a1 = []
286   end
287   @seq1 = SeqDesc.parse(a0[0], a1[0])
288   @seq2 = SeqDesc.parse(a0[1], a1[1])
289   
290   if @data[0].to_s.sub!(/\A\(complement\)\s*$/, '') then
291     @complement = true
292     @data.shift if @data[0].strip.empty?
293   else
294     @complement = nil
295   end
296 end