class Bio::Registry

Attributes

databases[R]

List of databases (Array of Bio::Registry::DB)

spec_version[R]

Version string of the first configulation file

Public Class Methods

new(file = nil) click to toggle source
# File lib/bio/io/registry.rb, line 99
def initialize(file = nil)
  @spec_version = nil
  @databases = Array.new
  read_local(file) if file
  env_path = ENV['OBDA_SEARCH_PATH']
  if env_path and env_path.size > 0
    read_env(env_path)
  else
    read_local("#{ENV['HOME']}/.bioinformatics/seqdatabase.ini")
    read_local("/etc/bioinformatics/seqdatabase.ini")
    if @databases.empty?
      read_remote("http://www.open-bio.org/registry/seqdatabase.ini")
    end
  end
end

Public Instance Methods

db(dbname)
Alias for: get_database
get_database(dbname) click to toggle source

Returns a dababase handle (Bio::SQL, Bio::Fetch etc.) or nil if not found (case insensitive). The handles should have get_by_id method.

# File lib/bio/io/registry.rb, line 124
def get_database(dbname)
  @databases.each do |db|
    if db.database == dbname.downcase
      case db.protocol
      when 'biofetch'
        return serv_biofetch(db)
      when 'biosql'
        return serv_biosql(db)
      when 'flat', 'index-flat', 'index-berkeleydb'
        return serv_flat(db)
      when 'bsane-corba', 'biocorba'
        raise NotImplementedError
      when 'xembl'
        raise NotImplementedError
      end
    end
  end
  return nil
end
Also aliased as: db
query(dbname) click to toggle source

Returns a Registry::DB object corresponding to the first dbname entry in the registry records (case insensitive).

# File lib/bio/io/registry.rb, line 147
def query(dbname)
  @databases.each do |db|
    return db if db.database == dbname.downcase
  end
end