generated from frehburg/TemplateForPythonProjects
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from typing import Union | ||
|
||
from phenopacket_mapper.data_standards import CodeSystem | ||
from phenopacket_mapper.api_requests import APIRequestSuperClass | ||
from phenopacket_mapper.api_requests import get as rest_get | ||
from phenopacket_mapper.data_standards import Coding, HPO | ||
|
||
|
||
class HPOAPIRequest(APIRequestSuperClass): | ||
"""A class to request data from the HPO API.""" | ||
|
||
api_base_url = "https://ontology.jax.org/api/hp/terms/HP:" | ||
|
||
def __init__(self, hpo_code_system: CodeSystem = HPO) -> None: | ||
self.hpo_code_system = hpo_code_system | ||
|
||
def get(self, concept_id: Union[str, int]) -> Coding: | ||
"""Get details about a concept from the Orphanet API.""" | ||
json = rest_get(self.api_base_url + str(concept_id), json=True) | ||
|
||
name = json['name'] | ||
|
||
return Coding( | ||
system=self.hpo_code_system, | ||
code=str(concept_id), | ||
display=name | ||
) |