Skip to content

API Reference

A class to connect to the local web server of the QSAR Toolbox. It requires the QSAR Toolbox to be installed and running in the local computer. The user need to find the address and the port of the local server and provide it to the class. Note: The port number can also be found automatically by running the following code:

import requests
from requests.exceptions import RequestException
import psutil
from tqdm import tqdm

def find_open_port(endpoint="/about/toolbox/version"):
    # Get a list of all open ports on localhost with status LISTEN
    open_ports = [conn.laddr.port for conn in psutil.net_connections() if conn.status == "LISTEN" and conn.laddr.ip == "127.0.0.1"]

    for port in tqdm(open_ports):
        url = f"http://127.0.0.1:{port}/api/v6{endpoint}"
        try:
            response = requests.get(url, timeout=1)
            if response.status_code == 200:
                return port
        except RequestException:
            continue
    return None

# Example usage
port = find_open_port()
if port:
    print(f"Server found on port {port}")
else:
    print("Server not found within the specified port range")

all_profile_chemicals(chem_id)

All Profilers for the specified chemical.

applicability_domain_qsar_chemical(chem_id, qsar_model_guid)

Get the applicability domain for a QSAR model and a chemical. returns a string that specifies whether the chemical is in the domain or not.

apply_qsar_chemical(chem_id, qsar_model_guid)

apply the specified QSAR model to a chemical.

call_metabolism_simulator(simulator_guid, chem_id, timeout=None)

Call a metabolism simulator for a chemical.

call_metabolism_simulator_on_SMILES(simulator_guid, smiles, timeout=None)

Call a metabolism simulator for a chemical.

call_qsar_model(chem_id, model_name='EPI Suite', end_point='VP')

Call a QSAR model for a chemical. Returns a Dictionary.

canonize_smiles(smiles)

Canonize a SMILES string. Returns a string.

extract_experimental_data(chem_id, end_point='VP')

Extract end point data for a chemical. Returns a Dictionary.

get_CASRN_from_SMILES(smiles)

Get the CASRN from a SMILES string. Returns a string.

get_all_endpoint_data(chem_id, includeMetadata=False)

Get all the endpoint data for a chemid. It can take a long time to return the data. Consider increasing the timeout.

get_available_calculators(timeout=None)

Get all the available calculators in the QSAR Toolbox [ { "Caption": "string", "Guid": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "Units": "string", "Is3D": true, "IsExperimental": true, "Description": "string" } ]

get_databases()

returns a list of the available databases in the QSAR Toolbox

get_databases_for_endpoint(position, endpoint, timeout=None)

Get the databases for an endpoint

get_endpoint_data(chem_id, position, endpoint, includeMetadata=False, timeout=120)

Get the endpoint data for a chemid. Retrieves data for the specified endpoint at the given position for the selected chemical Example: qs = QSARToolbox(port=52675)

get_endpoint_units_from_tree(position, endpoint, timeout=None)

Get the units for an endpoint from the endpoint tree

get_endpoints_from_tree(position, timeout=None)

Get the available endpoints at the given position. Returns a dictionary of the available endpoint depending on your installation of the QSAR Toolbox. position is a string that represents the position in the endpoint tree. For example, "Physical Chemical Properties#Vapour pressure" Example qs = QSARToolbox(port=52675) qs.get_endpoint_from_tree("Physical Chemical Properties#Vapour pressure")

get_endpoints_tree(timeout=None)

Get the endpoint tree. Returns a dictionary of the available endpoint calculation methods depending on your installation of the QSAR Toolbox.

get_metabolism_simulators()

Get all available metabolism simulators.

get_metadata_hierarchy(timeout=None)

Get the metadata hierarchy. Returns a dictionary of the available metadata hierarchy depending on your installation of the QSAR Toolbox.

get_object_info(object_guid)

Get the information of an object by its GUID Example: qs = QSARToolbox(port=52675) qs.get_object_info("6bfe3c72-dff2-4e37-b5a1-ffa9a1a111d1") The output is a JSON object.

get_object_info_html(object_guid)

Get the information of an object by its GUID in HTML format Example: qs = QSARToolbox(port=52675) qs.get_object_info_html("6bfe3c72-dff2-4e37-b5a1-ffa9a1a111d1") The output is in html format.

get_profilers()

Get all available profilers.

get_profiling_categories(profiler_guid)

Get the categories for a profiler.

get_qsar_models(position)

Get the QSAR models for a position in the endpoint tree.

get_workflows()

Get the workflows. Returns a dictionary of the available workflows depending on your installation of the QSAR Toolbox.

profile_chemical(profiler_guid, chem_id, simulator_guid)

Profile a chemical using a profiler.

run_all_calculators(chem_id, timeout=120)

Get all the calculations for a chemical; parameter chem_id comes from the results of one of the search_ functions.

run_calculator(calculation_guid, chem_id, timeout=None)

Get the result of a calculation for a chemical; parameter chem_id comes from the results of one of the search_ functions. the calculation_guid comes from the get_calculations() function.

search_CAS(casrn, ignoreStereo=True)

Search for a chemical by CASRN; casrn is an integer without dashes. Returns a JSON object. Example output: [ { "SubstanceType": "Unknown", "ChemId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "Cas": 0, "ECNumber": "string", "Smiles": "string", "Names": [ "string" ], "CasSmilesRelation": "string" } ]

search_chemid(chemid)

Search for a chemical by ChemId. Returns a JSON object. Example output: { "SubstanceType": "Unknown", "ChemId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "Cas": 0, "ECNumber": "string", "Smiles": "string", "Names": [ "string" ], "CasSmilesRelation": "string" }

search_name(name, options='ExactMatch', ignoreStereo=True)

Search for a chemical by name. Returns a JSON object. options can be: "ExactMatch", "StartWith", "Contains" Example output: [ { "SubstanceType": "Unknown", "ChemId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "Cas": 0, "ECNumber": "string", "Smiles": "string", "Names": [ "string" ], "CasSmilesRelation": "string" } ]

search_smiles(smiles, registerUnknown=True, ignoreStereo=True)

search for a chemical by SMILES. Returns a JSON object. Example output: [ { "SubstanceType": "Unknown", "ChemId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "Cas": 0, "ECNumber": "string", "Smiles": "string", "Names": [ "string" ], "CasSmilesRelation": "string" } ]

toolbox_version(timeout=None)

Get the version of the QSAR Toolbox If timeout is not provided, it will use the timeout provided in the class initialization. Example: qs = QSARToolbox(port=52675) qs.toolbox_version()

webapi_version(timeout=None)

Get the version of the API Example: qs = QSARToolbox(port=52675) qs.api_version()

workflow_on_chemical(workflow_guid, chem_id, timeout=None)

Run a workflow on a chemical.