Class: Bio::Sim4::Report::SegmentPair

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

Overview

Sequence segment pair of the sim4 result. Similar to Bio::Blast::Report::HSP but lacks many methods. For mRNA-genome mapping programs, unlike other homology search programs, the class is used not only for exons but also for introns. (Note that intron data would not be available according to run-time options of the program.)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(seq1, seq2, midline = nil, percent_identity = nil, direction = nil) ⇒ SegmentPair

Creates a new SegmentPair object. It is designed to be called internally from Bio::Sim4::Report::Hit object. Users shall not use it directly.



139
140
141
142
143
144
145
146
# File 'lib/bio/appl/sim4/report.rb', line 139

def initialize(seq1, seq2, midline = nil,
               percent_identity = nil, direction = nil)
  @seq1 = seq1
  @seq2 = seq2
  @midline = midline
  @percent_identity = percent_identity
  @direction = direction
end

Instance Attribute Details

#directionObject (readonly)

Returns directions of mapping. Maybe one of “->”, “<-”, “==” or “” or nil. This would be a Bio::Sim4 specific method.



166
167
168
# File 'lib/bio/appl/sim4/report.rb', line 166

def direction
  @direction
end

#midlineObject (readonly)

Returns the “midline” of the segment pair. Returns nil if no alignment data are available.



158
159
160
# File 'lib/bio/appl/sim4/report.rb', line 158

def midline
  @midline
end

#percent_identityObject (readonly)

Returns percent identity of the segment pair.



161
162
163
# File 'lib/bio/appl/sim4/report.rb', line 161

def percent_identity
  @percent_identity
end

#seq1Object (readonly)

Returns segment informations of ‘seq1’. Returns a Bio::Sim4::Report::Segment object. These would be Bio::Sim4 specific methods.



150
151
152
# File 'lib/bio/appl/sim4/report.rb', line 150

def seq1
  @seq1
end

#seq2Object (readonly)

Returns segment informations of ‘seq2’. Returns a Bio::Sim4::Report::Segment object. These would be Bio::Sim4 specific methods.



154
155
156
# File 'lib/bio/appl/sim4/report.rb', line 154

def seq2
  @seq2
end

Class Method Details

.both_intron(prev_e, e, aln) ⇒ Object

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



206
207
208
209
210
# File 'lib/bio/appl/sim4/report.rb', line 206

def self.both_intron(prev_e, e, aln)
  self.new(Segment.new(prev_e.seq1.to+1, e.seq1.from-1, aln[0]),
           Segment.new(prev_e.seq2.to+1, e.seq2.from-1, aln[2]),
           aln[1])
end

.parse(str, aln) ⇒ Object

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



172
173
174
175
176
177
# File 'lib/bio/appl/sim4/report.rb', line 172

def self.parse(str, aln)
  /^(\d+)\-(\d+)\s*\((\d+)\-(\d+)\)\s*([\d\.]+)\%\s*([\-\<\>\=]*)/ =~ str
  self.new(Segment.new($1, $2, aln[0]),
           Segment.new($3, $4, aln[2]),
           aln[1], $5, $6)
end

.seq1_intron(prev_e, e, aln) ⇒ Object

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



184
185
186
187
188
# File 'lib/bio/appl/sim4/report.rb', line 184

def self.seq1_intron(prev_e, e, aln)
  self.new(Segment.new(prev_e.seq1.to+1, e.seq1.from-1, aln[0]),
           Segment.new(nil, nil, aln[2]),
           aln[1])
end

.seq2_intron(prev_e, e, aln) ⇒ Object

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



195
196
197
198
199
# File 'lib/bio/appl/sim4/report.rb', line 195

def self.seq2_intron(prev_e, e, aln)
  self.new(Segment.new(nil, nil, aln[0]),
           Segment.new(prev_e.seq2.to+1, e.seq2.from-1, aln[2]),
           aln[1])
end

Instance Method Details

#align_lenObject

Returns alignment length of the segment pair. Returns nil if no alignment data are available.



238
239
240
# File 'lib/bio/appl/sim4/report.rb', line 238

def align_len
  (@midline and @seq1.seq and @seq2.seq) ? @midline.length : nil
end

#hit_fromObject

start position of the hit(target) (the first position is 1)



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

def hit_from;   @seq2.from; end

#hit_toObject

end position of the hit(target) (including its position)



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

def hit_to;     @seq2.to;   end

#hseqObject

hit(target) sequence (with gaps) of the alignment of the segment pair.



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

def hseq;       @seq2.seq;  end

#qseqObject

query sequence (with gaps) of the alignment of the segment pair.



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

def qseq;       @seq1.seq;  end

#query_fromObject

start position of the query (the first position is 1)



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

def query_from; @seq1.from; end

#query_toObject

end position of the query (including its position)



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

def query_to;   @seq1.to;   end