class Bio::Sim4::Report::Hit
Hit object of the sim4 result. Similar to Bio::Blast::Report::Hit but lacks many methods.
Attributes
Returns sequence informations of 'seq1'. Returns a Bio::Sim4::Report::SeqDesc object. This would be Bio::Sim4 specific method.
Returns sequence informations of 'seq2'. Returns a Bio::Sim4::Report::SeqDesc object. This would be Bio::Sim4 specific method.
Public Class Methods
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, line 273 def initialize(str) @data = str.split(/\n(?:\r?\n)+/) parse_seqdesc end
Public Instance Methods
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, line 432 def align unless defined?(@align); parse_align; end @align end
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, line 313 def complement? @complement end
Iterates over each exon of the hit. Yields a Bio::Sim4::Report::SegmentPair object.
# File lib/bio/appl/sim4/report.rb, line 470 def each(&x) #:yields: segmentpair exons.each(&x) end
Returns exons of the hit. Each exon is a Bio::Sim4::Report::SegmentPair object.
# File lib/bio/appl/sim4/report.rb, line 402 def exons unless defined?(@exons); parse_segmentpairs; end @exons end
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, line 422 def introns unless defined?(@introns); parse_segmentpairs; end @introns end
Definition of the query sequence Same as Bio::Sim4::Report#query_def.
# File lib/bio/appl/sim4/report.rb, line 451 def query_def; seq1.definition; end
Identifier of the query sequence. Same as Bio::Sim4::Report#query_id.
# File lib/bio/appl/sim4/report.rb, line 447 def query_id; seq1.entry_id; end
Length of the query sequence. Same as Bio::Sim4::Report#query_len.
# File lib/bio/appl/sim4/report.rb, line 443 def query_len; seq1.len; end
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, line 412 def segmentpairs unless defined?(@segmentpairs); parse_segmentpairs; end @segmentpairs end
Definition of the hit(target) sequence
# File lib/bio/appl/sim4/report.rb, line 460 def target_def; seq2.definition; end
Identifier of the hit(target) sequence
# File lib/bio/appl/sim4/report.rb, line 457 def target_id; seq2.entry_id; end
length of the hit(target) sequence
# File lib/bio/appl/sim4/report.rb, line 454 def target_len; seq2.len; end
Private Instance Methods
Parses alignment.
# File lib/bio/appl/sim4/report.rb, line 352 def parse_align s1 = []; ml = []; s2 = [] blocks = [] blocks.push [ s1, ml, s2 ] dat = @data[1..-1] return unless dat dat.each do |str| a = str.split(/\r?\n/) ruler = a.shift # First line, for example, # " 50 . : . : . : . : . :" # When the number is 0, forced to be a separated block if /^\s*(\d+)/ =~ ruler and $1.to_i == 0 and !ml.empty? then s1 = []; ml = []; s2 = [] blocks.push [ s1, ml, s2 ] end # For example, # " 190 GAGTCATGCATGATACAA CTTATATATGTACTTAGCGGCA" # " ||||||||||||||||||<<<...<<<-||-|||||||||||||||||||" # " 400 GAGTCATGCATGATACAACTT...AGCGCT ATATATGTACTTAGCGGCA" if /^(\s*\d+\s)(.+)$/ =~ a[0] then range = ($1.length)..($1.length + $2.chomp.length - 1) a.collect! { |x| x[range] } s1 << a.shift ml << a.shift s2 << a.shift end end #each alx_all = [] blocks.each do |ary| s1, ml, s2 = ary alx = ml.join('').split(/([\<\>]+\.+[\<\>]+)/) seq1 = s1.join(''); seq2 = s2.join('') i = 0 alx.collect! do |x| len = x.length y = [ seq1[i, len], x, seq2[i, len] ] i += len y end # adds virtual intron information if necessary alx_all.push([ '', '', '' ]) unless alx_all.empty? alx_all.concat alx end @align = alx_all end
Parses segment pair.
# File lib/bio/appl/sim4/report.rb, line 318 def parse_segmentpairs aln = (self.align ? self.align.dup : []) exo = [] #exons itr = [] #introns sgp = [] #segmentpairs prev_e = nil return unless @data[0] @data[0].split(/\r?\n/).each do |str| ai = (prev_e ? aln.shift : nil) a = (aln.shift or []) e = SegmentPair.parse(str, a) exo << e if ai then # intron data in alignment if ai[1].strip.empty? then i = SegmentPair.both_intron(prev_e, e, ai) elsif ai[2].strip.empty? then i = SegmentPair.seq1_intron(prev_e, e, ai) else i = SegmentPair.seq2_intron(prev_e, e, ai) end itr << i sgp << i end sgp << e prev_e = e end @exons = exo @introns = itr @segmentpairs = sgp end
Parses sequence descriptions.
# File lib/bio/appl/sim4/report.rb, line 279 def parse_seqdesc # seq1: query, seq2: target(hit) a0 = @data.shift.split(/\r?\n/) if @data[0].to_s =~ /^\>/ then a1 = @data.shift.split(/\r?\n/) else a1 = [] end @seq1 = SeqDesc.parse(a0[0], a1[0]) @seq2 = SeqDesc.parse(a0[1], a1[1]) if @data[0].to_s.sub!(/\A\(complement\)\s*$/, '') then @complement = true @data.shift if @data[0].strip.empty? else @complement = nil end end