mgbam's picture
Update genesis/api_clients/chembl_api.py
792fe00 verified
raw
history blame
1.09 kB
# genesis/api_clients/chembl_api.py
import requests
BASE_URL = "https://www.ebi.ac.uk/chembl/api/data"
def search_molecule(query: str):
"""Search ChEMBL molecules by name or ChEMBL ID."""
url = f"{BASE_URL}/molecule/search.json?q={query}"
response = requests.get(url)
response.raise_for_status()
return response.json()
def get_molecule_details(chembl_id: str):
"""Get details of a molecule by ChEMBL ID."""
url = f"{BASE_URL}/molecule/{chembl_id}.json"
response = requests.get(url)
response.raise_for_status()
return response.json()
def get_assays_for_molecule(chembl_id: str):
"""Get bioassays related to a molecule."""
url = f"{BASE_URL}/assay.json?molecule_chembl_id={chembl_id}"
response = requests.get(url)
response.raise_for_status()
return response.json()
def get_targets_for_molecule(chembl_id: str):
"""Get protein targets related to a molecule."""
url = f"{BASE_URL}/target.json?molecule_chembl_id={chembl_id}"
response = requests.get(url)
response.raise_for_status()
return response.json()