Skip to content

Commit

Permalink
added method for hpo api request
Browse files Browse the repository at this point in the history
  • Loading branch information
frehburg committed Oct 4, 2024
1 parent 029fbdd commit 28b2a77
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/phenopacket_mapper/api_requests/hpo_api_request.py
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
)

0 comments on commit 28b2a77

Please sign in to comment.