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.
Merge pull request #145 from BIH-CEI/144-hpo
144 hpo
- Loading branch information
Showing
4 changed files
with
39 additions
and
1 deletion.
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
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 | ||
) |
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
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,7 @@ | ||
from phenopacket_mapper.api_requests.hpo_api_request import HPOAPIRequest | ||
from phenopacket_mapper.data_standards import Coding, HPO | ||
|
||
|
||
def test_hpo_api_request(): | ||
hp = HPOAPIRequest() | ||
assert hp.get("0000098") == Coding(system=HPO, code="0000098", display="Tall stature") |