Spaces:
Sleeping
Sleeping
File size: 1,086 Bytes
792fe00 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# 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()
|