tooluniverse.chem_tool 模块

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[源代码]

基类: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)[源代码]
_build_url(args)[源代码]

Build URL from endpoint template and arguments

_build_params(args)[源代码]

Build query parameters for ChEMBL API

_extract_parent_chembl_id(mol)[源代码]

Extract the parent ChEMBL ID from a molecule record.

_lookup_chembl_id_by_name(drug_name)[源代码]

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)[源代码]

Execute the ChEMBL API call

class tooluniverse.chem_tool.ChEMBLTool[源代码]

基类:BaseTool

使用 ChEMBL Web Services API,根据给定的化合物名称或 SMILES 搜索相似分子的工具。

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')[源代码]
run(arguments)[源代码]

执行该工具。

默认的 BaseTool 实现接受一个可选的参数映射,以符合大多数具体工具实现所期望的输入字典。

参数:
  • arguments (dict, optional) – 工具专用参数

  • stream_callback (callable, optional) – 用于流式响应的回调

  • use_cache (bool, optional) – 是否启用了结果缓存

  • validate (bool, optional) – 是否已执行参数验证

备注

这些附加参数(stream_callback、use_cache、validate)从 run_one_function() 传递,用于提供有关执行的上下文。工具可以利用这些参数进行优化或特殊处理。

为了向后兼容,不接受这些参数的工具仍然可以正常运行——它们只会接收到 arguments 参数。

get_chembl_id_by_name(compound_name)[源代码]

通过名称在 ChEMBL 中搜索化合物,并返回第一个匹配项的 ChEMBL ID。

get_smiles_pref_name_by_chembl_id(query)[源代码]

给定一个 ChEMBL ID,返回包含规范 SMILES 和首选名称的字典。

get_chembl_smiles_pref_name_id_by_name(compound_name)[源代码]

通过名称在 ChEMBL 中搜索化合物,并返回前五个匹配项的字典列表,包含 ChEMBL ID、规范 SMILES 及首选名称。

_search_similar_molecules(query, similarity_threshold, max_results)[源代码]