Module: EnsemblRest::Ontologies

Defined in:
lib/bio-ensembl-rest/ontologies.rb

Class Method Summary collapse

Class Method Details

._ontology_id_generic(id, type, opts = {}) ⇒ Object

:nodoc:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/bio-ensembl-rest/ontologies.rb', line 28

def self._ontology_id_generic(id, type, opts = {}) # :nodoc:
  opts = EnsemblRest.parse_options opts
  case type 
  when 'ancestors_plain'
    url = "/ontology/ancestors/#{id}"
  when 'ancestors_chart'
    url = "/ontology/ancestors/chart/#{id}"
  when 'descendents'
    url = "/ontology/descendents/#{id}"
  when 'plain'
    url = "/ontology/id/#{id}"
  end
  path = EnsemblRest.build_path url, opts

  if opts['content-type'] == 'ruby'
    plain_opts = opts.clone
    plain_opts['content-type'] = 'application/json'
    return JSON.parse _ontology_id_generic id, type, plain_opts
  end

  return EnsemblRest.fetch_data path, opts, 'ontologies'
end

.ontology_ancestor(id, opts = {}) ⇒ Object

Find all ancestors, all terms above, belonging to a given term



6
7
8
# File 'lib/bio-ensembl-rest/ontologies.rb', line 6

def self.ontology_ancestor(id, opts = {})
  return _ontology_id_generic id, 'ancestors_plain', opts
end

.ontology_ancestor_chart(id, opts = {}) ⇒ Object

Reconstruct the entire ancestory of a term from is_a and part_of relationships.



12
13
14
# File 'lib/bio-ensembl-rest/ontologies.rb', line 12

def self.ontology_ancestor_chart(id, opts = {})
  return _ontology_id_generic id, 'ancestors_chart', opts
end

.ontology_descendents(id, opts = {}) ⇒ Object

Find all descendents, all terms below, belonging to a given term.



18
19
20
# File 'lib/bio-ensembl-rest/ontologies.rb', line 18

def self.ontology_descendents(id, opts = {})
  return _ontology_id_generic id, 'descendents', opts
end

.ontology_id(id, opts = {}) ⇒ Object

Search for an ontological term by its namespaced identifier



24
25
26
# File 'lib/bio-ensembl-rest/ontologies.rb', line 24

def self.ontology_id(id, opts = {})
  return _ontology_id_generic id, 'plain', opts
end

.ontology_name(name, opts = {}) ⇒ Object

Search for a list of ontological terms by their name and an optional ontology



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/bio-ensembl-rest/ontologies.rb', line 54

def self.ontology_name(name, opts = {})
  opts = EnsemblRest.parse_options opts
  path = EnsemblRest.build_path "/ontology/name/#{name}", opts
  
  if opts['content-type'] == 'ruby'
    plain_opts = opts.clone
    plain_opts['content-type'] = 'application/json'
    return JSON.parse ontology_name name, plain_opts
  end

  return EnsemblRest.fetch_data path, opts, 'ontologies'
end