Class: Bio::Blat::Report::SegmentPair

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

Overview

Sequence segment pair of BLAT result. Similar to Bio::Blast::Report::Hsp but lacks many methods.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query_len, target_len, strand, blksize, qstart, tstart, qseq, tseq, protein_flag) ⇒ SegmentPair

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



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/bio/appl/blat/report.rb', line 199

def initialize(query_len, target_len, strand,
               blksize, qstart, tstart, qseq, tseq,
               protein_flag)
  @blocksize  = blksize
  @qseq       = qseq
  @hseq       = hseq
  @hit_strand   = 'plus'
  w = (protein_flag ? 3 : 1) # 3 means query=protein target=dna
  case strand
  when '-'
    # query is minus strand
    @query_strand = 'minus'
    # convert positions
    @query_from = query_len - qstart
    @query_to   = query_len - qstart - blksize + 1
    # To keep compatibility, with other homology search programs,
    # we add 1 to each position number.
    @hit_from   = tstart + 1
    @hit_to     = tstart + blksize * w # - 1 + 1
  when '+-'
    # hit is minus strand
    @query_strand = 'plus'
    @hit_strand = 'minus'
    # To keep compatibility, with other homology search programs,
    # we add 1 to each position number.
    @query_from   = qstart + 1
    @query_to     = qstart + blksize # - 1 + 1
    # convert positions
    @hit_from     = target_len - tstart
    @hit_to       = target_len - tstart - blksize * w + 1
  else #when '+', '++'
    @query_strand = 'plus'
    # To keep compatibility with other homology search programs,
    # we add 1 to each position number.
    @query_from = qstart + 1
    @query_to   = qstart + blksize # - 1 + 1
    @hit_from   = tstart + 1
    @hit_to     = tstart + blksize * w # - 1 + 1
  end
end

Instance Attribute Details

#blocksizeObject (readonly)

Returns block size (length) of the segment pair. This would be a Bio::Blat specific method.



277
278
279
# File 'lib/bio/appl/blat/report.rb', line 277

def blocksize
  @blocksize
end

#hit_fromObject (readonly)

Returns target (subject, hit) start position. CAUTION: In Blat’s raw result(psl format), first position is 0. To keep compatibility, the parser add 1 to the position.



260
261
262
# File 'lib/bio/appl/blat/report.rb', line 260

def hit_from
  @hit_from
end

#hit_strandObject (readonly)

Returns strand information of the target (subject, hit). Returns ‘plus’ or ‘minus’.



273
274
275
# File 'lib/bio/appl/blat/report.rb', line 273

def hit_strand
  @hit_strand
end

#hit_toObject (readonly)

Returns target (subject, hit) end position. CAUTION: In Blat’s raw result(psl format), first position is 0. To keep compatibility, the parser add 1 to the position.



265
266
267
# File 'lib/bio/appl/blat/report.rb', line 265

def hit_to
  @hit_to
end

#hseqObject (readonly)

Returns the target (subject, hit) sequence. If sequence data is not available, returns nil.



269
270
271
# File 'lib/bio/appl/blat/report.rb', line 269

def hseq
  @hseq
end

#qseqObject (readonly)

Returns query sequence. If sequence data is not available, returns nil.



251
252
253
# File 'lib/bio/appl/blat/report.rb', line 251

def qseq
  @qseq
end

#query_fromObject (readonly)

Returns query start position. CAUTION: In Blat’s raw result(psl format), first position is 0. To keep compatibility, the parser add 1 to the position.



242
243
244
# File 'lib/bio/appl/blat/report.rb', line 242

def query_from
  @query_from
end

#query_strandObject (readonly)

Returns strand information of the query. Returns ‘plus’ or ‘minus’.



255
256
257
# File 'lib/bio/appl/blat/report.rb', line 255

def query_strand
  @query_strand
end

#query_toObject (readonly)

Returns query end position. CAUTION: In Blat’s raw result(psl format), first position is 0. To keep compatibility, the parser add 1 to the position.



247
248
249
# File 'lib/bio/appl/blat/report.rb', line 247

def query_to
  @query_to
end

Instance Method Details

#align_lenObject

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



281
282
283
# File 'lib/bio/appl/blat/report.rb', line 281

def align_len
  @qseq ? @qseq.size : nil
end