tooluniverse.chem_tool module

ChEMBL API Tools

This module provides tools for accessing the ChEMBL database: - ChEMBLTool: Specialized tool for similarity search - ChEMBLRESTTool: Generic REST API tool for ChEMBL endpoints

class tooluniverse.chem_tool.ChEMBLRESTTool[source]

Bases: BaseTool

Generic ChEMBL REST API tool. Wrapper for ChEMBL API endpoints defined in chembl_tools.json. Supports all ChEMBL data resources: molecules, targets, assays, activities, drugs, etc.

__init__(tool_config)[source]
_build_url(args)[source]

Build URL from endpoint template and arguments

_build_params(args)[source]

Build query parameters for ChEMBL API

_extract_parent_chembl_id(mol)[source]

Extract the parent ChEMBL ID from a molecule record.

_lookup_chembl_id_by_name(drug_name)[source]

Look up a ChEMBL molecule ID by preferred name (case-insensitive).

Feature-79B-001: Uses icontains first (most reliable), then iexact as fallback. The iexact and search endpoints frequently timeout for newer drugs. Returns the ChEMBL ID of the first matching molecule, or None.

run(arguments)[source]

Execute the ChEMBL API call

class tooluniverse.chem_tool.ChEMBLTool[source]

Bases: BaseTool

Tool to search for molecules similar to a given compound name or SMILES using the ChEMBL Web Services API.

Note: This tool is designed for small molecule compounds only. Biologics (antibodies, proteins, oligonucleotides, etc.) do not have SMILES structures and cannot be used for structure-based similarity search. The tool will provide detailed error messages when biologics are queried, explaining the reason and suggesting alternative tools.

__init__(tool_config, base_url='https://www.ebi.ac.uk/chembl/api/data')[source]
run(arguments)[source]

Execute the tool.

The default BaseTool implementation accepts an optional arguments mapping to align with most concrete tool implementations which expect a dictionary of inputs.

Parameters:
  • arguments (dict, optional) – Tool-specific arguments

  • stream_callback (callable, optional) – Callback for streaming responses

  • use_cache (bool, optional) – Whether result caching is enabled

  • validate (bool, optional) – Whether parameter validation was performed

Note

These additional parameters (stream_callback, use_cache, validate) are passed from run_one_function() to provide context about the execution. Tools can use these for optimization or special handling.

For backward compatibility, tools that don’t accept these parameters will still work - they will only receive the arguments parameter.

get_chembl_id_by_name(compound_name)[source]

Search ChEMBL for a compound by name and return the ChEMBL ID of the first match.

get_smiles_pref_name_by_chembl_id(query)[source]

Given a ChEMBL ID, return a dict with canonical SMILES and preferred name.

get_chembl_smiles_pref_name_id_by_name(compound_name)[source]

Search ChEMBL for a compound by name and return a list of dicts with ChEMBL ID, canonical SMILES, and preferred name for the top 5 matches.

_search_similar_molecules(query, similarity_threshold, max_results)[source]