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.



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

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.



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

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.



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

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.



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

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.



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

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

#lengthObject

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



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

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

#moltypeObject

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



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

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.



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

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.



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

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