Class: Bio::DB

Inherits:
Object show all
Defined in:
lib/bio/db.rb

Direct Known Subclasses

ClustalW::Report, EMBLDB, FANTOM::MaXML, FastaFormat, NBRF, NCBIDB

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) open(filename, *mode, &block)



156
157
158
# File 'lib/bio/db.rb', line 156

def self.open(filename, *mode, &block)
  Bio::FlatFile.open(self, filename, *mode, &block)
end

Instance Method Details

- (Object) entry_id

Returns an entry identifier as a String. This method must be implemented in every database classes by overriding this method.

Raises:

  • (NotImplementedError)


162
163
164
# File 'lib/bio/db.rb', line 162

def entry_id
  raise NotImplementedError
end

- (Boolean) exists?(tag)

Returns true or false - wether the entry contains the field of the given tag name.

Returns:

  • (Boolean)


173
174
175
# File 'lib/bio/db.rb', line 173

def exists?(tag)
  @orig.include?(tag)
end

- (Object) fetch(tag, skip = 0)

Similar to the get method, however, fetch returns the content of the field without its tag and any extra white spaces stripped.



184
185
186
187
# File 'lib/bio/db.rb', line 184

def fetch(tag, skip = 0)
  field = @orig[tag].split(/\n/, skip + 1).last.to_s
  truncate(field.gsub(/^.{0,#{@tagsize}}/,''))
end

- (Object) get(tag)

Returns an intact field of the tag as a String.



178
179
180
# File 'lib/bio/db.rb', line 178

def get(tag)
  @orig[tag]
end

- (Object) tags

Returns a list of the top level tags of the entry as an Array of String.



167
168
169
# File 'lib/bio/db.rb', line 167

def tags
  @orig.keys
end