class Bio::EMBLDB

Stores an EMBL style (EMBL, TrEMBL, Swiss-Prot etc.) entry.

Public Class Methods

new(entry, tagsize) click to toggle source

The entire entry is passed as a String. The length of the tag field is passed as an Integer. Parses the entry roughly by the entry2hash method and returns a database object.

# File lib/bio/db.rb, line 306
def initialize(entry, tagsize)
  @tagsize = tagsize
  @orig = entry2hash(entry.strip)     # Hash of the original entry
  @data = {}                  # Hash of the parsed entry
end

Private Instance Methods

entry2hash(entry) click to toggle source

Returns the contents of the entry as a Hash.

# File lib/bio/db.rb, line 315
def entry2hash(entry)
  hash = Hash.new { |h,k| h[k] = '' }
  entry.each_line do |line|
    tag = tag_get(line)
    next if tag == 'XX'
    tag = 'R' if tag =~ /^R./ # Reference lines
    hash[tag].concat line
  end
  return hash
end