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.



243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/bio/appl/fasta/format10.rb', line 243

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.



266
267
268
# File 'lib/bio/appl/fasta/format10.rb', line 266

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.



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

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.



270
271
272
# File 'lib/bio/appl/fasta/format10.rb', line 270

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.



274
275
276
# File 'lib/bio/appl/fasta/format10.rb', line 274

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

#lengthObject

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



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

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

#moltypeObject

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



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

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.



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

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.



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

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