Ontoma Interface

main interface class

class ontoma.interface.OnToma(exclude=[])[source]

Open Targets ontology mapping wrapper

Parameters:exclude (str or [str]) – Excludes ‘zooma’,’ols_hp’ or ‘ols_ordo’ API calls from the search, to speed things up.

Example

Initialize the class (which will download EFO,OBO and others):

>>> t=OnToma()

We can now lookup “asthma” and get:

>>> t.efo_lookup('asthma')
'http://www.ebi.ac.uk/efo/EFO_0000270'

Notice we always tend to return a full IRI

Search by synonyms coming from the OBO file is also supported

>>> t.efo_lookup('Asthma unspecified')
'http://www.ebi.ac.uk/efo/EFO_0000270'

Reverse lookups uses the get_efo_label() method

>>> t.get_efo_label('EFO_0000270')
'asthma'
>>> t.get_efo_label('EFO:0000270')
'asthma'
>>> t.get_efo_label('http://www.ebi.ac.uk/efo/EFO_0000270')
'asthma'

Similarly, we can now lookup “Phenotypic abnormality” on HP OBO:

>>> t.hp_lookup('Phenotypic abnormality')
'http://purl.obolibrary.org/obo/HP_0000118'
>>> t.hp_lookup('Narrow nasal tip')
'http://purl.obolibrary.org/obo/HP_0011832'

OMIM code lookup

>>> t.omim_lookup('230650')
'http://www.orpha.net/ORDO/Orphanet_79257'
>>> t.zooma_lookup('asthma')
'http://www.ebi.ac.uk/efo/EFO_0000270'

MONDO lookup >>> t.mondo_lookup(‘asthma’) ‘http://purl.obolibrary.org/obo/MONDO_0004979

There is also a semi-intelligent wrapper, which tries to guess the best matching strategy:

>>> t.find_term('asthma')
'http://www.ebi.ac.uk/efo/EFO_0000270'
>>> t.find_term('615877',code='OMIM')
'http://www.orpha.net/ORDO/Orphanet_202948'

It returns None if it cannot find an EFO id:

>>> t.find_term('notadisease') is None
True
efo_lookup(name)[source]

Searches the EFO OBO file for a direct match

efo_to_name
exclude = None

Initialize API clients

find_term(query, code=None, suggest=False, verbose=False)[source]

Finds the most likely EFO code for a given string or ontology code.

If the code argument is passed, it will attempt to perform an exact match amongst the mappings available.

If only a string is passed, it will attempt to match it against mappings, but will try using the EBI SPOT APIs if no match is found, until a likely code is identified.

Operations roughly ordered from least expensive to most expensive and also from most authorative to least authorative

  1. EFO OBO lookup
  2. Zooma mappings lookup
  3. Zooma API high confidence lookup

4. OLS API EFO lookup - exact match — below this line we might not have a term in the platform — 5. HP OBO lookup 6. OLS API HP lookup - exact match 7. OLS API ORDO lookup - exact match 8. OLS API EFO lookup - not exact 9. OLS API HP+ORDO lookup - not exact

Parameters:
  • query (str) – the disease/phenotype to be matched to an EFO code
  • code – accepts one of “ICD9CM”, “OMIM” TODO expand to more ontologies If a code is passed, it will attempt to find the code in one of our curated mapping datasources. Defaults to None.
  • suggest (boolean) – if True the OLS API will be queried for any match in HP, ORDO and EFO, whether or not these terms are already included in the Open Targets platform ontology.
  • verbose (bool) – if True returns a dictionary containing {term, label, source, quality, action}
Returns:

A valid OT ontology URI. None if no EFO code was found

get_efo_from_xref(efocode)[source]

Given an short disease id, returns the id and label of equivalent term(s) in EFO as defined by xrefs

get_efo_label(efocode)[source]

Given an EFO short form code, returns the label as taken from the OBO

get_hp_label(hpcode)[source]

Given an HP short form code, returns the label as taken from the OBO

get_mondo_label(mondocode)[source]

Given an MONDO short form code, returns the label as taken from the OBO

hp_lookup(name)[source]

Searches the HP OBO file for a direct match

hp_to_name
icd9_lookup(icd9code)[source]

Searches the ICD9CM <=> EFO mappings returned from the OXO API #FIXME Results don’t seem to be deterministic, some mappings appear and disappear between calls, e.g. t.icd9_lookup(‘696’)

mondo_lookup(name)[source]

Searches the mondo OBO file for a direct match

mondo_to_name
name_to_efo
name_to_hp
name_to_mondo
omim_lookup(omimcode)[source]

Searches our own curated OMIM <=> EFO mappings #FIXME assumes the first is the best hit. is this ok?

otzooma_map_lookup(name)[source]

Searches against the curated OpenTargets mapping we submitted to zooma.

These mappings are usually stored on github. NOTE: this is not a lookup to zooma API

oxo_lookup(other_ontology_id, input_source='ICD9CM')[source]

Searches in the mappings returned from the EBI OXO API.

The function should return an EFO code for any given xref, if one exists.

Parameters:
Returns:

the EFO code

Return type:

str

xref_to_efo
zooma_lookup(name)[source]

Searches against the EBI Zooma service for an high confidence mapping

ontoma.interface.make_uri(ontology_short_form)[source]

Transform a short form ontology code in a full URI. Currently works for EFO, HPO, ORDO and MP.

Parameters:ontology_short_form – An ontology code in the short format, like ‘EFO:0000270’. The function won’t break if a valid URI is passed.
Returns:A full URI. Raises a ValueError if the short form code was not one of the supported ones.

Example

>>> make_uri('EFO:0000270')
'http://www.ebi.ac.uk/efo/EFO_0000270'
>>> make_uri('HP_0000270')
'http://purl.obolibrary.org/obo/HP_0000270'
>>> make_uri('http://purl.obolibrary.org/obo/HP_0000270')
'http://purl.obolibrary.org/obo/HP_0000270'
>>> make_uri('TEST_0000270')
Traceback (most recent call last):
    ...
ValueError: Could not build an URI. Short form: TEST_0000270 not recognized