Ontoma Interface¶
main interface class
-
class
ontoma.interface.
OnToma
[source]¶ Open Targets ontology mapping wrapper
The output should always be a EFO/OpenTargets ontology URI.
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_354'
>>> t.zooma_lookup('asthma') 'http://www.ebi.ac.uk/efo/EFO_0000270'
Searching the ICD9 code for ‘other dermatoses’ returns EFO’s skin disease:
>>> t.icd9_lookup('696') 'EFO:0000676'
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_to_name
¶
-
find_term
(query, code=None)[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
TODO suggestions and fuzzy search should be returned. A specific exception should be crafted and handled.
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.
Returns: A valid OT ontology URI. None if no EFO code was found
-
get_efo_label
(efocode)[source]¶ Given an EFO short form code, returns the label as taken from the OBO
-
hp_to_name
¶
-
logger
= None¶ Initialize API clients
-
name_to_efo
¶
-
name_to_hp
¶
-
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: - other_ontology_id – the code that should be mapped to EFO
- input_source – an ontology code. Defaults to ‘ICD9CM’. Available ontologies are listed at https://www.ebi.ac.uk/spot/oxo/api/datasources?fields=preferredPrefix
Returns: the EFO code
Return type: str
-
-
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