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

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

Direct Known Subclasses

Target

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Query

Returns a new instance of Query.



333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/bio/appl/fasta/format10.rb', line 333

def initialize(data)
  @definition, *data = data.split(/\n/)
  @data = {}
  @sequence = ''

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

  data.each do |x|
    if pat.match(x)
      @data[$1] = $2
    else
      @sequence += x
    end
  end
end

Instance Attribute Details

#dataObject (readonly)

Returns a Hash containing ‘sq_len’, ‘sq_offset’, ‘sq_type’, ‘al_start’, ‘al_stop’, and ‘al_display_start’ values. You can access most of these values by Report::Hit#query_* methods.



356
357
358
# File 'lib/bio/appl/fasta/format10.rb', line 356

def data
  @data
end

#definitionObject (readonly)

Returns the definition of the entry as a String. You can access this value by Report::Hit#query_def method.



351
352
353
# File 'lib/bio/appl/fasta/format10.rb', line 351

def definition
  @definition
end

#sequenceObject (readonly)

Returns the sequence (with gaps) as a String. You can access this value by the Report::Hit#query_seq method.



360
361
362
# File 'lib/bio/appl/fasta/format10.rb', line 360

def sequence
  @sequence
end

Instance Method Details

#entry_idObject

Returns the first word in the definition as a String. You can get this value by Report::Hit#query_id method.



364
365
366
# File 'lib/bio/appl/fasta/format10.rb', line 364

def entry_id
  @definition[/\S+/]
end

#lengthObject

Returns the sequence length. You can access this value by the Report::Hit#query_len method.



370
371
372
# File 'lib/bio/appl/fasta/format10.rb', line 370

def length
  @data['sq_len'].to_i
end

#moltypeObject

Returns ‘p’ for protein sequence, ‘D’ for nucleotide sequence.



375
376
377
# File 'lib/bio/appl/fasta/format10.rb', line 375

def moltype
  @data['sq_type']
end

#startObject

Returns alignment start position. You can also access this value by Report::Hit#query_start method for shortcut.



381
382
383
# File 'lib/bio/appl/fasta/format10.rb', line 381

def start
  @data['al_start'].to_i
end

#stopObject

Returns alignment end position. You can access this value by Report::Hit#query_end method for shortcut.



387
388
389
# File 'lib/bio/appl/fasta/format10.rb', line 387

def stop
  @data['al_stop'].to_i
end