class Bio::Spidey::Report::Hit

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

Public Class Methods

new(data, d0) click to toggle source

Creates a new Hit object. It is designed to be called internally from Bio::Spidey::Report::* classes. Users shall not call it directly.

    # File lib/bio/appl/spidey/report.rb
290 def initialize(data, d0)
291   @data = data
292   @d0 = d0
293 end

Public Instance Methods

align() click to toggle source

Returns alignments. Returns an Array of arrays. This would be a Bio::Spidey specific method.

    # File lib/bio/appl/spidey/report.rb
465 def align
466   unless defined?(@align); parse_align; end
467   @align
468 end
complement?() click to toggle source

Returns true if the result reports 'Reverse complement'. Otherwise, return false or nil. This would be a Bio::Spidey specific method.

    # File lib/bio/appl/spidey/report.rb
330 def complement?
331   unless defined?(@complement); parse_strand; end
332   @complement
333 end
definition()
Alias for: target_def
each() { |segmentpair| ... } click to toggle source

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

    # File lib/bio/appl/spidey/report.rb
555 def each(&x) #:yields: segmentpair
556   exons.each(&x)
557 end
exons() click to toggle source

Returns exons of the hit. Returns an array of Bio::Spidey::Report::SegmentPair object.

    # File lib/bio/appl/spidey/report.rb
437 def exons
438   unless defined?(@exons); parse_segmentpairs; end
439   @exons
440 end
Also aliased as: hsps
genomic() click to toggle source

Returns sequence informations of the 'Genomic'. Returns a Bio::Spidey::Report::SeqDesc object. This would be a Bio::Spidey specific method.

    # File lib/bio/appl/spidey/report.rb
373 def genomic
374   unless defined?(@genomic)
375     @genomic = SeqDesc.parse(@d0.find { |x| /^Genomic\:/ =~ x })
376   end
377   @genomic
378 end
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::Spidey::Report::SegmentPair objects. (Note that intron data is not always available according to run-time options of the program.)

    # File lib/bio/appl/spidey/report.rb
447 def introns
448   unless defined?(@introns); parse_segmentpairs; end
449   @introns
450 end
len()
Alias for: target_len
missing_mrna_ends() click to toggle source

Returns missing mRNA ends of the hit.

    # File lib/bio/appl/spidey/report.rb
363 def missing_mrna_ends
364   unless defined?(@missing_mrna_ends)
365     @missing_mrna_ends = field_fetch('Missing mRNA ends', @d0)
366   end
367   @missing_mrna_ends
368 end
mrna() click to toggle source

Returns sequence informations of the mRNA. Returns a Bio::Spidey::Report::SeqDesc object. This would be a Bio::Spidey specific method.

    # File lib/bio/appl/spidey/report.rb
383 def mrna
384   unless defined?(@mrna)
385     @mrna = SeqDesc.parse(@d0.find { |x| /^mRNA\:/ =~ x })
386   end
387   @mrna
388 end
number_of_exons() click to toggle source

Returns number of exons in the hit.

    # File lib/bio/appl/spidey/report.rb
336 def number_of_exons
337   unless defined?(@number_of_exons)
338     @number_of_exons = field_fetch('Number of exons', @d0).to_i
339   end
340   @number_of_exons
341 end
number_of_splice_sites() click to toggle source

Returns number of splice sites of the hit.

    # File lib/bio/appl/spidey/report.rb
344 def number_of_splice_sites
345   unless defined?(@number_of_splice_sites)
346     @number_of_splice_sites = 
347       field_fetch('Number of splice sites', @d0).to_i
348   end
349   @number_of_splice_sites
350 end
percent_identity() click to toggle source

Returns overall percent identity of the hit.

    # File lib/bio/appl/spidey/report.rb
353 def percent_identity
354   unless defined?(@percent_identity)
355     x = field_fetch('overall percent identity', @d0)
356     @percent_identity = 
357       (/([\d\.]+)\s*\%/ =~ x.to_s) ? $1 : nil
358   end
359   @percent_identity
360 end
query_def() click to toggle source

Definition of the mRNA (query). Same as Bio::Spidey::Report#query_def.

    # File lib/bio/appl/spidey/report.rb
536 def query_def;  mrna.definition; end
query_id() click to toggle source

Identifier of the mRNA (query). Same as Bio::Spidey::Report#query_id.

    # File lib/bio/appl/spidey/report.rb
532 def query_id;   mrna.entry_id;   end
query_len() click to toggle source

Length of the mRNA (query) sequence. Same as Bio::Spidey::Report#query_len.

    # File lib/bio/appl/spidey/report.rb
528 def query_len;  mrna.len;        end
segmentpairs() click to toggle source

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

    # File lib/bio/appl/spidey/report.rb
457 def segmentpairs
458   unless defined?(@segmentparis); parse_segmentpairs; end
459   @segmentpairs
460 end
strand() click to toggle source

Returns strand information of the hit. Returns 'plus', 'minus', or nil. This would be a Bio::Spidey specific method.

    # File lib/bio/appl/spidey/report.rb
322 def strand
323   unless defined?(@strand); parse_strand; end
324   @strand
325 end
target_def() click to toggle source

Definition of the genomic (target) sequence.

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

Identifier of the genomic (target) sequence.

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

The genomic (target) sequence length.

    # File lib/bio/appl/spidey/report.rb
539 def target_len; genomic.len;        end
Also aliased as: len

Private Instance Methods

field_fetch(t, ary) click to toggle source

Fetches fields.

    # File lib/bio/appl/spidey/report.rb
296 def field_fetch(t, ary)
297   reg = Regexp.new(/^#{Regexp.escape(t)}\:\s*(.+)\s*$/)
298   if ary.find { |x| reg =~ x }
299     $1.strip
300   else
301     nil
302   end
303 end
parse_align() click to toggle source

Parses alignments.

    # File lib/bio/appl/spidey/report.rb
508 def parse_align
509   r = []
510   data = @data
511   while !data.empty?
512     a = []
513     while x = data.shift and !(x =~ /^(Genomic|Exon\s*\d+)\:/)
514       a.push x
515     end
516     r.push parse_align_lines(a) unless a.empty?
517   end
518   @align = r
519 end
parse_align_lines(data) click to toggle source

Parses alignment lines.

    # File lib/bio/appl/spidey/report.rb
471 def parse_align_lines(data)
472   misc = [ [], [], [], [] ]
473   data.each do |x|
474     a = x.split(/\r?\n/)
475     if g = a.shift then
476       misc[0] << g
477       (1..3).each do |i|
478         if y = a.shift then
479           if y.length < g.length
480             y << ' ' * (g.length - y.length)
481           end
482           misc[i] << y
483         else
484           misc[i] << ' ' * g.length
485         end
486       end
487     end
488   end
489   misc.collect! { |x| x.join('') }
490   left = []
491   if /\A +/ =~ misc[2] then
492     len = $&.size
493     left = misc.collect { |x| x[0, len] }
494     misc.each { |x| x[0, len] = '' }
495   end
496   right = []
497   if / +\z/ =~ misc[2] then
498     len = $&.size
499     right = misc.collect { |x| x[(-len)..-1] }
500     misc.each { |x| x[(-len)..-1] = '' }
501   end
502   body = misc
503   [ left, body, right ]
504 end
parse_segmentpairs() click to toggle source

Parses segment pairs.

    # File lib/bio/appl/spidey/report.rb
391 def parse_segmentpairs
392   aln = self.align.dup
393   ex = []
394   itr = []
395   segpairs = []
396   cflag  = self.complement?
397   strand = self.strand
398   if strand == 'minus' then
399     d_to = 1;  d_from = -1
400   else
401     d_to = -1; d_from = 1
402   end
403   @d0.each do |x|
404     #p x
405     if x =~ /^Exon\s*\d+(\(.*\))?\:/ then
406       if a = aln.shift then
407         y = SegmentPair.parse(x, strand, cflag, a[1])
408         ex << y
409         if a[0][0].to_s.length > 0 then
410           to = y.genomic.from + d_to
411           i0 = SegmentPair.new_intron(nil, to, strand, a[0])
412           itr << i0
413           segpairs << i0
414         end
415         segpairs << y
416         if a[2][0].to_s.length > 0 then
417           from = y.genomic.to + d_from
418           i2 = SegmentPair.new_intron(from, nil, strand, a[2])
419           itr << i2
420           segpairs << i2
421         end
422       else
423         y = SegmentPair.parse(x, strand, cflag, [])
424         ex << y
425         segpairs << y
426       end
427     end
428   end
429   @exons = ex
430   @introns = itr
431   @segmentpairs = segpairs
432 end
parse_strand() click to toggle source

Parses information about strand.

    # File lib/bio/appl/spidey/report.rb
307 def parse_strand
308   x = field_fetch('Strand', @d0)
309   if x =~ /^(.+)Reverse +complement\s*$/ then
310     @strand = $1.strip
311     @complement = true
312   else
313     @strand = x
314     @complement = nil
315   end
316 end