Skip to content

Commit

Permalink
extract OntologyURI to fix circular imports
Browse files Browse the repository at this point in the history
  • Loading branch information
apriltuesday committed Jan 23, 2024
1 parent 92a3222 commit 005a1ce
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cmat/trait_mapping/ols.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from retry import retry

from cmat.trait_mapping.oxo import OntologyUri
from cmat.trait_mapping.ontology_uri import OntologyUri
from cmat.trait_mapping.utils import json_request, ServerError

OLS_SERVER = 'https://www.ebi.ac.uk/ols4'
Expand Down
20 changes: 20 additions & 0 deletions cmat/trait_mapping/ontology_uri.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

class OntologyUri:
db_to_uri_dict = {
"orphanet": "http://www.orpha.net/ORDO/Orphanet_{}",
"omim": "http://identifiers.org/omim/{}",
"efo": "http://www.ebi.ac.uk/efo/EFO_{}",
"mesh": "http://identifiers.org/mesh/{}",
"medgen": "http://identifiers.org/medgen/{}",
"hp": "http://purl.obolibrary.org/obo/HP_{}",
"doid": "http://purl.obolibrary.org/obo/DOID_{}",
"mondo": "http://purl.obolibrary.org/obo/MONDO_{}",
}

def __init__(self, id_, db):
self.id_ = id_
self.db = db
self.uri = self.db_to_uri_dict[self.db.lower()].format(self.id_)

def __str__(self):
return self.uri
22 changes: 1 addition & 21 deletions cmat/trait_mapping/oxo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,13 @@

from cmat.trait_mapping.ols import get_ontology_label_from_ols, is_in_ontology
from cmat.trait_mapping.ols import is_current_and_in_ontology
from cmat.trait_mapping.ontology_uri import OntologyUri
from cmat.trait_mapping.utils import json_request


logger = logging.getLogger(__package__)


class OntologyUri:
db_to_uri_dict = {
"orphanet": "http://www.orpha.net/ORDO/Orphanet_{}",
"omim": "http://identifiers.org/omim/{}",
"efo": "http://www.ebi.ac.uk/efo/EFO_{}",
"mesh": "http://identifiers.org/mesh/{}",
"medgen": "http://identifiers.org/medgen/{}",
"hp": "http://purl.obolibrary.org/obo/HP_{}",
"doid": "http://purl.obolibrary.org/obo/DOID_{}",
"mondo": "http://purl.obolibrary.org/obo/MONDO_{}",
}

def __init__(self, id_, db):
self.id_ = id_
self.db = db
self.uri = self.db_to_uri_dict[self.db.lower()].format(self.id_)

def __str__(self):
return self.uri


@total_ordering
class OxOMapping:
"""
Expand Down

0 comments on commit 005a1ce

Please sign in to comment.