Class: Bio::Fasta::Report::Hit

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/appl/fasta/format10.rb

Defined Under Namespace

Classes: Query, Target

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Hit

Returns a new instance of Hit.



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/bio/appl/fasta/format10.rb', line 202

def initialize(data)
  score, query, target = data.split(/\n>/)

  @definition, *score = score.split(/\n/)
  @score = {}

  pat = /;\s+([^:]+):\s+(.*)/

  score.each do |x|
    if pat.match(x)
      @score[$1] = $2
    end
  end

  @query = Query.new(query)
  @target = Target.new(target)
end

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition.



219
220
221
# File 'lib/bio/appl/fasta/format10.rb', line 219

def definition
  @definition
end

#queryObject (readonly)

Returns the value of attribute query.



219
220
221
# File 'lib/bio/appl/fasta/format10.rb', line 219

def query
  @query
end

#scoreObject (readonly)

Returns the value of attribute score.



219
220
221
# File 'lib/bio/appl/fasta/format10.rb', line 219

def score
  @score
end

#targetObject (readonly)

Returns the value of attribute target.



219
220
221
# File 'lib/bio/appl/fasta/format10.rb', line 219

def target
  @target
end

Instance Method Details

#bit_scoreObject

Bit score



235
236
237
238
239
240
241
242
243
244
245
# File 'lib/bio/appl/fasta/format10.rb', line 235

def bit_score
  if @score['fa_bits']
    @score['fa_bits'].to_f
  elsif @score['sw_bits']
    @score['sw_bits'].to_f
  elsif @score['fx_bits']
    @score['fx_bits'].to_f
  elsif @score['tx_bits']
    @score['tx_bits'].to_f
  end
end

#directionObject



247
248
249
# File 'lib/bio/appl/fasta/format10.rb', line 247

def direction
  @score['fa_frame'] || @score['sw_frame'] || @score['fx_frame'] || @score['tx_frame']
end

#evalueObject

E-value score



222
223
224
225
226
227
228
229
230
231
232
# File 'lib/bio/appl/fasta/format10.rb', line 222

def evalue
  if @score['fa_expect']
    @score['fa_expect'].to_f
  elsif @score['sw_expect']
    @score['sw_expect'].to_f
  elsif @score['fx_expect']
    @score['fx_expect'].to_f
  elsif @score['tx_expect']
    @score['tx_expect'].to_f
  end
end

#identityObject

percent identity



257
258
259
# File 'lib/bio/appl/fasta/format10.rb', line 257

def identity
  @score['sw_ident'].to_f
end

#lap_atObject



328
329
330
# File 'lib/bio/appl/fasta/format10.rb', line 328

def lap_at
  [ query_start, query_end, target_start, target_end ]
end

#overlapObject

overlap length



262
263
264
# File 'lib/bio/appl/fasta/format10.rb', line 262

def overlap
  @score['sw_overlap'].to_i
end

#query_defObject



276
277
278
# File 'lib/bio/appl/fasta/format10.rb', line 276

def query_def
  @query.definition
end

#query_endObject



316
317
318
# File 'lib/bio/appl/fasta/format10.rb', line 316

def query_end
  @query.stop
end

#query_idObject

Shortcuts for the methods of Bio::Fasta::Report::Hit::Query



268
269
270
# File 'lib/bio/appl/fasta/format10.rb', line 268

def query_id
  @query.entry_id
end

#query_lenObject



284
285
286
# File 'lib/bio/appl/fasta/format10.rb', line 284

def query_len
  @query.length
end

#query_seqObject



294
295
296
# File 'lib/bio/appl/fasta/format10.rb', line 294

def query_seq
  @query.sequence
end

#query_startObject

Information on matching region



312
313
314
# File 'lib/bio/appl/fasta/format10.rb', line 312

def query_start
  @query.start
end

#query_typeObject



302
303
304
# File 'lib/bio/appl/fasta/format10.rb', line 302

def query_type
  @query.moltype
end

#swObject

Smith-Waterman score



252
253
254
# File 'lib/bio/appl/fasta/format10.rb', line 252

def sw
  @score['sw_score'].to_i
end

#target_defObject



280
281
282
# File 'lib/bio/appl/fasta/format10.rb', line 280

def target_def
  @target.definition
end

#target_endObject



324
325
326
# File 'lib/bio/appl/fasta/format10.rb', line 324

def target_end
  @target.stop
end

#target_idObject



272
273
274
# File 'lib/bio/appl/fasta/format10.rb', line 272

def target_id
  @target.entry_id
end

#target_lenObject

Shortcuts for the methods of Bio::Fasta::Report::Hit::Target



290
291
292
# File 'lib/bio/appl/fasta/format10.rb', line 290

def target_len
  @target.length
end

#target_seqObject



298
299
300
# File 'lib/bio/appl/fasta/format10.rb', line 298

def target_seq
  @target.sequence
end

#target_startObject



320
321
322
# File 'lib/bio/appl/fasta/format10.rb', line 320

def target_start
  @target.start
end

#target_typeObject



306
307
308
# File 'lib/bio/appl/fasta/format10.rb', line 306

def target_type
  @target.moltype
end