class Mspire::Obo::Group

An Mspire::Obo::Group is a distinct collection of Mspire::Obo objects, but all lookup hashes are merged across the various ontologies. This means that a user can make a group and query across all the ontologies in a single, simple call. The interface mimics that of the hash providing Mspire::Obo object.

group = Mspire::Obo::Group.new([Mspire::Obo[:ms], Mspire::Obo[:uo]])
hash = group.id_to_name
# can access any ids from the various Mspire::Obo objects
hash["MS:1000001"] # -> 'sample number'
group

Attributes

obos[RW]

the array of Mspire::Obo objects

Public Class Methods

new(obos=[]) click to toggle source
# File lib/mspire/obo/group.rb, line 24
def initialize(obos=[])
  @obos = obos
end

Public Instance Methods

make_id_to_cast() click to toggle source
# File lib/mspire/obo/group.rb, line 33
def make_id_to_cast
  merge_hashes(__method__)
end
make_id_to_name() click to toggle source

returns an id to name Hash

# File lib/mspire/obo/group.rb, line 29
def make_id_to_name
  merge_hashes(__method__)
end
make_id_to_stanza() click to toggle source

returns an id_to_stanza hash

# File lib/mspire/obo/group.rb, line 38
def make_id_to_stanza
  merge_hashes(__method__)
end
make_name_to_id() click to toggle source

returns a name_to_id Hash

# File lib/mspire/obo/group.rb, line 43
def make_name_to_id
  merge_hashes(__method__)
end
merge_hashes(symbol) click to toggle source

merges the hashes retrieved with that symbol

# File lib/mspire/obo/group.rb, line 48
def merge_hashes(symbol)
  obos.map(&symbol).reduce({}, :merge)
end
name_to_id(name=nil, namespace=nil) click to toggle source

with no arguments, merely returns the @name_to_id merged hash (if made). With one argument, looks up the id given the name. With a namespace, the id will be returned without collision.

# File lib/mspire/obo/group.rb, line 61
def name_to_id(name=nil, namespace=nil)
  if namespace
    @name_to_id_by_namespace ||= name_to_id_by_namespace
    @name_to_id_by_namespace[namespace][name]
  elsif name
    @name_to_id[name]
  else
    @name_to_id
  end
end
name_to_id_by_namespace() click to toggle source

creates a hash keyed by namespace string that yields the name_to_id hash.

# File lib/mspire/obo/group.rb, line 54
def name_to_id_by_namespace
  Hash[ obos.map(&:namespace).zip(obos.map(&:make_name_to_id)) ]
end