CHEESE API
If you are interested in integrating CHEESE into one of your workflows in a programmatic way, we provide you with the CHEESE API. The API consists now of the principal molecular search service.
The CHEESE API URL is the following : https://api.cheese.themama.ai/ and only registered CHEESE users can access it using an API key generated by the CHEESE UI.
How to generate the API key?
- Go to the CHEESE webpage
- Sign in with your account.
-
You should see a button to generate the API key in the top right corner
-
Copy the API key and use it to call the API.
Molecular search
Searching by a single molecule
This is the main CHEESE service where you can supply a query molecule, the number of neighbors to retrieve, the search type and quality, and you'll get a JSON object containing the resulting molecules together with their descriptors, predicted properties and Morgan Tanimoto similarities.
To call the service you can perform a GET request and provide the parameters and your generated API key in the headers.
Request URL : https://api.cheese.themama.ai/molsearch
Parameters :
search_input (str)
: SMILES string of the query moleculesearch_type (str)
: Can be one of the following :'morgan', 'espsim_electrostatic', 'espsim_shape', 'usr_shape'
search_quality (str)
: Can be one of the following :'fast','accurate','very accurate'
n_neighbors (int)
: Number of neighborsdescriptors (bool)
: Whether to get descriptors or notproperties (bool)
: Whether to get properties or notfilter_molecules (bool)
: Whether to apply 'No solvants' filter
Headers :
Authorization
: Enter here your API key underBearer $api_key
This is an example to call the service using the Python requests library :
import requests
# Query molecule in SMILES format
query = "CCCCCC"
# Search type
search_type = "morgan"
# Search quality
search_quality = "fast"
# Number of neighbors
n_neighbors = 10
# Paste your API key here
api_key="XXXXXXX"
# Perform the request
requests.get("https://api.cheese.themama.ai/molsearch",
{"search_input":query,
"search_type":search_type,
"n_neighbors":n_neighbors,
"search_quality":"fast",
"descriptors":True,
"properties":True,
"filter_molecules":True}
,headers={'Authorization': f"Bearer {api_key}"
},
verify=False).json()
An example JSON response looks like this :
{'neighbors': [{'smiles': 'CCCCCC',
'zinc_id': '1532209',
'properties': {'absorption': {'caco2_wang': -3.95,
'lipophilicity_astrazeneca': 1.429,
'solubility_aqsoldb': -4.111,
'bioavailability_ma': 0.942,
'hia_hou': 0.98,
'pgp_broccatelli': 0.0,
'clogp': 2.5866},
'excretion': {'clearance_hepatocyte_az': 90.212,
'clearance_microsome_az': 37.758,
'half_life_obach': 6.712},
'toxicity': {'ld50_zhu': 0.645, 'ames': 0.0, 'dili': 0.121, 'herg': 0.719},
'distribution': {'ppbr_az': 71.032,
'vdss_lombardo': 3.238,
'bbb_martins': 0.999},
'metabolism': {'cyp2c9_veith': 0.0,
'cyp2d6_veith': 0.0,
'cyp3a4_veith': 0.0},
'basics': {'molecular_weight': 86.10955,
'formal_charge': 0.0,
'heavy_atoms': 6.0,
'h_bond_acceptors': 0.0,
'h_bond_donor': 0.0,
'rotatable_bonds': 3.0,
'num_of_rings': 0.0,
'molar_refractivity': 29.816,
'number_of_atoms': 6.0,
'topological_surface_area_mapping': 0.0},
'score': {'Morgan Tanimoto': 1.0}}},
{'smiles': 'CCCCCCC',
'zinc_id': '1691363',
'properties': {'absorption': {'caco2_wang': -3.809,
'lipophilicity_astrazeneca': 1.678,
'solubility_aqsoldb': -4.63,
'bioavailability_ma': 0.947,
'hia_hou': 0.98,
'pgp_broccatelli': 0.0,
'clogp': 2.9767},
'excretion': {'clearance_hepatocyte_az': 90.202,
'clearance_microsome_az': 51.668,
'half_life_obach': 9.892},
'toxicity': {'ld50_zhu': 1.323, 'ames': 0.0, 'dili': 0.131, 'herg': 0.732},
'distribution': {'ppbr_az': 73.982,
'vdss_lombardo': 2.369,
'bbb_martins': 0.996},
'metabolism': {'cyp2c9_veith': 0.0,
'cyp2d6_veith': 0.0,
'cyp3a4_veith': 0.0},
'basics': {'molecular_weight': 100.1252,
'formal_charge': 0.0,
'heavy_atoms': 7.0,
'h_bond_acceptors': 0.0,
'h_bond_donor': 0.0,
'rotatable_bonds': 4.0,
'num_of_rings': 0.0,
'molar_refractivity': 34.433,
'number_of_atoms': 7.0,
'topological_surface_area_mapping': 0.0},
'score': {'Morgan Tanimoto': 0.875}}}],
'query_properties': {'smiles': 'CCCCCC',
'zinc_id': '',
'properties': {'absorption': {'caco2_wang': -3.950169086456299,
'lipophilicity_astrazeneca': 1.429108738899231,
'solubility_aqsoldb': -4.1111674308776855,
'bioavailability_ma': 0.9417303204536438,
'hia_hou': 0.9802113771438599,
'pgp_broccatelli': 2.3020054413791513e-06,
'clogp': 2.5866000000000007},
'excretion': {'clearance_hepatocyte_az': 90.212158203125,
'clearance_microsome_az': 37.758026123046875,
'half_life_obach': 6.711719036102295},
'toxicity': {'ld50_zhu': 0.6453738212585449,
'ames': 4.6125546759867575e-06,
'dili': 0.12116408348083496,
'herg': 0.7191941142082214},
'distribution': {'ppbr_az': 71.03226470947266,
'vdss_lombardo': 3.2378389835357666,
'bbb_martins': 0.9992955923080444},
'metabolism': {'cyp2c9_veith': 7.601168363180477e-06,
'cyp2d6_veith': 0.0003342859272379428,
'cyp3a4_veith': 1.898099981190171e-05},
'basics': {'molecular_weight': 86.109550448,
'formal_charge': 0,
'heavy_atoms': 6,
'h_bond_acceptors': 0,
'h_bond_donor': 0,
'rotatable_bonds': 3,
'num_of_rings': 0,
'molar_refractivity': 29.81599999999998,
'number_of_atoms': 6,
'topological_surface_area_mapping': 0.0}}},
'search_info': {'query_embedding_time': 0.04316449165344238,
'search_time': 0.034208059310913086,
'filter_time': 3.7670135498046875e-05,
'sorting_time': 0.011804342269897461,
'property_prediction_time': 0.050608158111572266,
'total_time': 0.13982272148132324}}
Under neighbors
, a list of neighbors is provided together with their descriptors, properties and Morgan similarities to the query. Under query_properties
key as well as the descriptors and predicted properties of the query molecule. Finally some details about the search time is provided as well.
Searching by a list of molecules
You can search a list of molecules and get a response either in JSON or CSV format.
To call the service you can perform a GET request and provide the parameters as well as your generated API key and the response format in the headers.
Request URL : https://api.cheese.themama.ai/molsearch_array
Parameters :
search_input (List[str])
: List of SMILES strings of the query moleculessearch_type (str)
: Can be one of the following :'morgan', 'espsim_electrostatic', 'espsim_shape', 'usr_shape'
search_quality (str)
: Can be one of the following :'fast','accurate','very accurate'
n_neighbors (int)
: Number of neighborsdescriptors (bool)
: Whether to get descriptors or notproperties (bool)
: Whether to get properties or notfilter_molecules (bool)
: Whether to apply 'No solvants' filter
Headers :
Authorization
: Enter here your API key underBearer $api_key
Accept
: Can either beapplication/json
for a JSON response orapplication/csv
for a CSV response
Imporatnt notes : If you are searching for a large set of molecules, the search speed is significantly affected if you :
- Set the search quality to
very accurate
- Set the search type to
consensus
- Enable the molecule filtering
- The worst speed is when you combine all of the above
This is an example to call the service using the Python requests library :
import requests
# Query molecule in SMILES format
query = ["CCCCCC","CCC=O","CCC"]
# Search type
search_type = "morgan"
# Search quality
search_quality = "fast"
# Number of neighbors
n_neighbors = 3
# Paste your API key here
api_key="XXXXXXX"
# Perform the request
requests.get("https://api.cheese.themama.ai/molsearch_array",
{"search_input":query,
"search_type":search_type,
"n_neighbors":n_neighbors,
"search_quality":"fast",
"descriptors":False,
"properties":True,
"filter_molecules":False}
,headers={'Authorization': f"Bearer {api_key}",
'Accept': "application/csv"
},
verify=False).json()
# Download result file to local storage
result_filename=new_resp.headers["content-disposition"].split()[-1].replace("filename=","")
save_path="./"
with open(save_path+result_filename,'wb') as new_file:
new_file.write(new_resp.content)
query,neighbor,neighbor ZINC ID,Morgan Tanimoto,prop1,prop2,....,desc1,desc2...
where prop
are properties and desc
are descriptors.
The JSON response has a similar format to the API call of the /molsearch
call, the difference is that the keys are SMILES of the molecules together with the search_info
.
Searching by a file molecules
You can search a files of molecules and get a response either in JSON or CSV format. The file formats can either be in .csv, .sdf, .smi, or .txt
formats.
To call the service you can perform a POST request and provide the parameters as well as your generated API key and the response format in the headers.
Request URL : https://api.cheese.themama.ai/molsearch_file
Parameters :
search_type (str)
: Can be one of the following :'morgan', 'espsim_electrostatic', 'espsim_shape', 'usr_shape'
search_quality (str)
: Can be one of the following :'fast','accurate','very accurate'
n_neighbors (int)
: Number of neighborsdescriptors (bool)
: Whether to get descriptors or notproperties (bool)
: Whether to get properties or notfilter_molecules (bool)
: Whether to apply 'No solvants' filter
Files:
search_input (file : _io.BufferedReader)
file of the query molecules. The file must be provided under thesearch_input
parameter of the POST request files (see example below).
You can find some file examples to try the API in the CHEESE web assets folder
Headers :
Authorization
: Enter here your API key underBearer $api_key
Accept
: Can either beapplication/json
for a JSON response orapplication/csv
for a CSV response
This is an example to call the service using the Python requests library :
import requests
# Query file
filename="00_chembl_subset.sdf"
file=open(filename,"rb")
# Paste your API key here
api_key="XXXXXXX"
new_resp=requests.post("http://api.cheese.themama.ai/molsearch_file",
data={
"search_type":"morgan",
"n_neighbors":5,
"search_quality":"very accurate",
"descriptors":False,
"properties":True,
"filter_molecules":False},
files={"search_input":file},
headers={'Authorization': f"Bearer {api_key}",
'Accept': "application/csv"
},
verify=False)
# Download result file to local storage
result_filename=new_resp.headers["content-disposition"].split()[-1].replace("filename=","")
save_path="./"
with open(save_path+result_filename,'wb') as new_file:
new_file.write(new_resp.content)
/molsearch_array
call.
Property prediction
ADMET property prediction is also supported by the API. You have the option to supply molecules and get ADMET properties as well as basic descriptors if needed.
Property prediction for a single molecule
You can perform property prediction and descriptor calculation on a single molecule query and get a JSON object as a response.
To call the service you can perform a GET request and provide the parameters and your generated API key in the headers.
Request URL : https://api.cheese.themama.ai/predict
Parameters :
search_input (str)
: SMILES string of the query moleculedescriptors (bool)
: Whether to get descriptors or notproperties (bool)
: Whether to get properties or not- At least one of the two above parameters needs to be
True
Headers :
Authorization
: Enter here your API key underBearer $api_key
This is an example to call the service using the Python requests library :
import requests
# Query molecule in SMILES format
query = "CCCCCC"
# Paste your API key here
api_key="XXXXXXX"
# Perform the request
requests.get("https://api.cheese.themama.ai/predict",
{"search_input":query,
"descriptors":True,
"properties":True
}
,headers={'Authorization': f"Bearer {api_key}"
},
verify=False).json()
An example JSON response looks like this :
{
"descriptors": {
"CCCCCC": {
"molecular_weight": 86.109550448,
"formal_charge": 0,
"clogp": 2.5866000000000007,
"heavy_atoms": 6,
"h_bond_acceptors": 0,
"h_bond_donor": 0,
"rotatable_bonds": 3,
"num_of_rings": 0,
"molar_refractivity": 29.81599999999998,
"number_of_atoms": 6,
"topological_surface_area_mapping": 0
}
},
"properties": {
"CCCCCC": {
"caco2_wang": -3.950169086456299,
"clearance_hepatocyte_az": 90.212158203125,
"clearance_microsome_az": 37.758026123046875,
"half_life_obach": 6.711719036102295,
"ld50_zhu": 0.6453738212585449,
"lipophilicity_astrazeneca": 1.429108738899231,
"ppbr_az": 71.03226470947266,
"solubility_aqsoldb": -4.1111674308776855,
"vdss_lombardo": 3.2378389835357666,
"ames": 0.0000046125546759867575,
"bbb_martins": 0.9992955923080444,
"bioavailability_ma": 0.9417303204536438,
"cyp2c9_substrate_carbonmangels": 0.30764755606651306,
"cyp2c9_veith": 0.000007601168363180477,
"cyp2d6_substrate_carbonmangels": 0.10820775479078293,
"cyp2d6_veith": 0.0003342859272379428,
"cyp3a4_substrate_carbonmangels": 0.004517389927059412,
"cyp3a4_veith": 0.00001898099981190171,
"dili": 0.12116408348083496,
"herg": 0.7191941142082214,
"hia_hou": 0.9802113771438599,
"pgp_broccatelli": 0.0000023020054413791513
}
}
}
Property prediction for a list of molecules
You can perform property prediction and descriptor calculation on a list of molecules and get a JSON object or a CSV file as a response.
To call the service you can perform a GET request and provide the parameters and your generated API key in the headers.
Request URL : https://api.cheese.themama.ai/predict_array
Parameters :
search_input (List[str])
: list of SMILES string of the query moleculesdescriptors (bool)
: Whether to get descriptors or notproperties (bool)
: Whether to get properties or not- At least one of the two above parameters needs to be
True
Headers :
Authorization
: Enter here your API key underBearer $api_key
Accept
: Can either beapplication/json
for a JSON response orapplication/csv
for a CSV response
This is an example to call the service using the Python requests library :
import requests
# Query molecule in SMILES format
queries = ["CCCCCC","CCC","CCC=O"]
# Paste your API key here
api_key="XXXXXXX"
# Perform the request
requests.get("https://api.cheese.themama.ai/predict_array",
{"search_input":query,
"descriptors":True,
"properties":True
},
headers={
"Accept":"application/csv",
'Authorization': f"Bearer {api_key}"
},
verify=False).json()
# Download result file to local storage
result_filename=new_resp.headers["content-disposition"].split()[-1].replace("filename=","")
save_path="./"
with open(save_path+result_filename,'wb') as new_file:
new_file.write(new_resp.content)
query,prop1,prop2,....,desc1,desc2...
where prop
are properties and desc
are descriptors.
The JSON response has a similar format to the /predict
API call, the difference is that the keys of descriptors
and properties
subdirectories are SMILES of the molecules together.
Property prediction for a file molecules
You can predict properties for a file of molecules and get a response either in JSON or CSV format. The file formats can either be in .csv, .sdf, .smi, or .txt
formats.
To call the service you can perform a POST request and provide the parameters as well as your generated API key and the response format in the headers.
Request URL : https://api.cheese.themama.ai/predict_file
Parameters :
descriptors (bool)
: Whether to get descriptors or notproperties (bool)
: Whether to get properties or not
Files:
search_input (file : _io.BufferedReader)
file of the query molecules. The file must be provided under thesearch_input
parameter of the POST request files (see example below).
You can find some file examples to try the API in the CHEESE web assets folder
Headers :
Authorization
: Enter here your API key underBearer $api_key
Accept
: Can either beapplication/json
for a JSON response orapplication/csv
for a CSV response
This is an example to call the service using the Python requests library :
import requests
# Query file
filename="00_chembl_subset.sdf"
file=open(filename,"rb")
# Paste your API key here
api_key="XXXXXXX"
new_resp=requests.post("http://api.cheese.themama.ai/predict_file",
data={
"descriptors":False,
"properties":True,
},
files={"search_input":file},
headers={'Authorization': f"Bearer {api_key}",
'Accept': "application/csv"
},
verify=False)
# Download result file to local storage
result_filename=new_resp.headers["content-disposition"].split()[-1].replace("filename=","")
save_path="./"
with open(save_path+result_filename,'wb') as new_file:
new_file.write(new_resp.content)
/predict_array
call.