chembl-database
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseChEMBL Database Query
ChEMBL数据库查询
Prerequisites
前置条件
- : Read the
uvskill and follow its Setup instructions to ensureuvis installed and on PATH.uv - User Notification: If LICENSE_NOTIFICATION.txt does not already exist in this skill directory then (1) prominently notify the user to check the terms at https://chembl.gitbook.io/chembl-interface-documentation/about, then (2) create the file recording the notification text and timestamp.
- :阅读
uv技能并遵循其设置说明,确保uv已安装且在PATH路径中。uv - 用户通知:若此技能目录中不存在LICENSE_NOTIFICATION.txt文件,则(1) 显著通知用户查看https://chembl.gitbook.io/chembl-interface-documentation/about上的条款,然后(2) 创建记录通知文本和时间戳的文件。
Core Rules
核心规则
-
[!IMPORTANT] Use the Utility Scripts: You MUST ALWAYS use the provided utility scriptfor all ChEMBL API interactions, including checking status. NEVER use
scripts/chembl_api.pyor custom Python requests to query the ChEMBL API directly. This ensures rate limit is enfoced and also retries on network errors.curl -
Output to File (Required): Theflag is required for every subcommand. All JSON results are written to the specified file. After running the command, read the output file with jq or your own code to extract the data. List results are typically wrapped in a JSON array keyed by the endpoint name (e.g.,
--output,molecules).activities -
Notification: If this skill is used, ensure this is mentioned in the output.
-
[!IMPORTANT] 使用实用脚本:所有ChEMBL API交互(包括状态检查)必须使用提供的实用脚本。绝不能直接使用
scripts/chembl_api.py或自定义Python请求查询ChEMBL API。这能确保速率限制被执行,并在网络错误时自动重试。curl -
输出到文件(必填):每个子命令都必须使用参数。所有JSON结果都会写入指定文件。运行命令后,可使用jq或自定义代码读取输出文件以提取数据。列表结果通常被包裹在以端点名称为键的JSON数组中(例如
--output、molecules)。activities -
通知说明:若使用此技能,需在输出中提及这一点。
Utility Script
实用脚本
All ChEMBL API queries use one script with subcommands:
bash
uv run scripts/chembl_api.py <subcommand> --output <file> [options]所有ChEMBL API查询都通过一个脚本及子命令完成:
bash
uv run scripts/chembl_api.py <subcommand> --output <file> [options]1. Check API Status
1. 检查API状态
bash
uv run scripts/chembl_api.py status --output /tmp/status.jsonbash
uv run scripts/chembl_api.py status --output /tmp/status.json2. Molecule Queries
2. 分子查询
Fetch by ChEMBL ID:
bash uv run scripts/chembl_api.py molecule --id CHEMBL25 --output /tmp/mol.jsonSearch by name:
bash uv run scripts/chembl_api.py molecule --search "aspirin" --limit 3 --output /tmp/mol_search.jsonBatch fetch:
bash uv run scripts/chembl_api.py molecule --ids "CHEMBL25;CHEMBL1642" --limit 10 --output /tmp/mol_batch.jsonFilter by properties:
bash uv run scripts/chembl_api.py molecule --filter molecule_properties__mw_freebase__lte=500 --limit 5 --output /tmp/mol_filter.jsonFilter by range:
bash uv run scripts/chembl_api.py molecule --filter molecule_properties__mw_freebase__range=150,200 --limit 5 --output /tmp/mol_range.jsonDownload SDF structure file:
bash uv run scripts/chembl_api.py molecule --id CHEMBL25 --dl_format sdf --output /tmp/aspirin.sdfTip: SDF/MOL files can be passed directly to tools like PyMOL or RDKit for 3D visualization and analysis.
按ChEMBL ID获取:
bash uv run scripts/chembl_api.py molecule --id CHEMBL25 --output /tmp/mol.json按名称搜索:
bash uv run scripts/chembl_api.py molecule --search "aspirin" --limit 3 --output /tmp/mol_search.json批量获取:
bash uv run scripts/chembl_api.py molecule --ids "CHEMBL25;CHEMBL1642" --limit 10 --output /tmp/mol_batch.json按属性过滤:
bash uv run scripts/chembl_api.py molecule --filter molecule_properties__mw_freebase__lte=500 --limit 5 --output /tmp/mol_filter.json按范围过滤:
bash uv run scripts/chembl_api.py molecule --filter molecule_properties__mw_freebase__range=150,200 --limit 5 --output /tmp/mol_range.json下载SDF结构文件:
bash uv run scripts/chembl_api.py molecule --id CHEMBL25 --dl_format sdf --output /tmp/aspirin.sdf提示:SDF/MOL文件可直接传入PyMOL或RDKit等工具进行3D可视化与分析。
3. Target Queries
3. 靶点查询
Search for targets:
bash uv run scripts/chembl_api.py target --search "EGFR" --limit 5 --output /tmp/targets.jsonFetch by ID:
bash uv run scripts/chembl_api.py target --id CHEMBL203 --output /tmp/egfr.json搜索靶点:
bash uv run scripts/chembl_api.py target --search "EGFR" --limit 5 --output /tmp/targets.json按ID获取:
bash uv run scripts/chembl_api.py target --id CHEMBL203 --output /tmp/egfr.json4. Bioactivity Data
4. 生物活性数据
Fetch activity by ID:
bash uv run scripts/chembl_api.py activity --id 31863 --output /tmp/act.jsonSearch activities:
bash uv run scripts/chembl_api.py activity --search "EGFR" --limit 5 --output /tmp/act_search.jsonFilter activities for a target:
bash uv run scripts/chembl_api.py activity --filter target_chembl_id=CHEMBL203 standard_type=IC50 --limit 10 --output /tmp/egfr_ic50.jsonNormalize bioactivity units to nM:
bash uv run scripts/chembl_api.py activity --filter target_chembl_id=CHEMBL203 standard_type=IC50 --limit 5 --normalize --output /tmp/egfr_normalized.jsonImportant: Bioactivity values come in various units (nM, µM, pM). Useto convert all values to nM for consistent comparison. Each record will include--normalizeandnormalized_value_nM.normalization_note
按ID获取活性数据:
bash uv run scripts/chembl_api.py activity --id 31863 --output /tmp/act.json搜索活性数据:
bash uv run scripts/chembl_api.py activity --search "EGFR" --limit 5 --output /tmp/act_search.json按靶点过滤活性数据:
bash uv run scripts/chembl_api.py activity --filter target_chembl_id=CHEMBL203 standard_type=IC50 --limit 10 --output /tmp/egfr_ic50.json将生物活性单位标准化为nM:
bash uv run scripts/chembl_api.py activity --filter target_chembl_id=CHEMBL203 standard_type=IC50 --limit 5 --normalize --output /tmp/egfr_normalized.json重要说明:生物活性值有多种单位(nM、µM、pM)。使用参数可将所有值转换为nM,以便统一比较。每条记录都会包含--normalize和normalized_value_nM字段。normalization_note
5. Drug Information
5. 药物信息
Fetch drug details:
bash uv run scripts/chembl_api.py drug --id CHEMBL25 --output /tmp/drug.jsonDrug indications:
bash uv run scripts/chembl_api.py drug_indication --filter molecule_chembl_id=CHEMBL25 --limit 10 --output /tmp/indications.jsonFilter indications by phase:
bash uv run scripts/chembl_api.py drug_indication --filter molecule_chembl_id=CHEMBL25 max_phase_for_ind=4.0 --limit 10 --output /tmp/approved_indications.jsonDrug warnings:
bash uv run scripts/chembl_api.py drug_warning --limit 5 --output /tmp/warnings.jsonMechanisms of action:
bash uv run scripts/chembl_api.py mechanism --filter molecule_chembl_id=CHEMBL25 --limit 5 --output /tmp/mech.json获取药物详情:
bash uv run scripts/chembl_api.py drug --id CHEMBL25 --output /tmp/drug.json药物适应症:
bash uv run scripts/chembl_api.py drug_indication --filter molecule_chembl_id=CHEMBL25 --limit 10 --output /tmp/indications.json按研发阶段过滤适应症:
bash uv run scripts/chembl_api.py drug_indication --filter molecule_chembl_id=CHEMBL25 max_phase_for_ind=4.0 --limit 10 --output /tmp/approved_indications.json药物警示信息:
bash uv run scripts/chembl_api.py drug_warning --limit 5 --output /tmp/warnings.json作用机制:
bash uv run scripts/chembl_api.py mechanism --filter molecule_chembl_id=CHEMBL25 --limit 5 --output /tmp/mech.json6. Structure-Based Searches
6. 基于结构的搜索
Note: Both similarity and substructure searches are performed server-side on ChEMBL's pre-indexed database. They do not require a local RDKit installation.
Similarity search (SMILES + threshold):
bash uv run scripts/chembl_api.py similarity --smiles "CC(=O)Oc1ccccc1C(=O)O" --similarity 85 --limit 5 --output /tmp/similar.jsonSubstructure search (SMILES):
bash uv run scripts/chembl_api.py substructure --smiles "c1ccccc1" --limit 5 --output /tmp/substruct.json注意:相似性和子结构搜索均在ChEMBL的预索引数据库服务器端执行,无需本地安装RDKit。
相似性搜索(SMILES + 阈值):
bash uv run scripts/chembl_api.py similarity --smiles "CC(=O)Oc1ccccc1C(=O)O" --similarity 85 --limit 5 --output /tmp/similar.json子结构搜索(SMILES):
bash uv run scripts/chembl_api.py substructure --smiles "c1ccccc1" --limit 5 --output /tmp/substruct.json7. Compound Image
7. 化合物图像
Download a 2D structure image (SVG by default, scalable for publication):
bash
uv run scripts/chembl_api.py image --id CHEMBL25 --output /tmp/chembl25.svgOptions:
- : Image size in pixels (max 500, default 500).
--dimensions - : Rendering engine (default: rdkit).
--engine - : Output format —
--img_format(default, vector) orsvg(raster).png
下载2D结构图像(默认SVG格式,可缩放用于出版物):
bash
uv run scripts/chembl_api.py image --id CHEMBL25 --output /tmp/chembl25.svg可选参数:
- : 图像像素尺寸(最大500,默认500)。
--dimensions - : 渲染引擎(默认:rdkit)。
--engine - : 输出格式 —
--img_format(默认,矢量图)或svg(位图)。png
8. Cross-Referencing with Other Databases
8. 与其他数据库交叉引用
ChEMBL integrates with UniProt, Ensembl, PubChem, and other databases. Common
cross-referencing patterns:
Find a ChEMBL target from a UniProt accession:
bash uv run scripts/chembl_api.py target --filter target_components__accession=P00533 --limit 5 --output /tmp/uniprot_target.jsonResolve any ChEMBL ID to its entity type:
bash uv run scripts/chembl_api.py chembl_id_lookup --id CHEMBL203 --output /tmp/lookup.jsonLook up cross-reference sources:
bash uv run scripts/chembl_api.py xref_source --limit 10 --output /tmp/xrefs.jsonTip: Use theendpoint to find UniProt accessions, gene names, and protein sequences for any ChEMBL target.target_component
ChEMBL与UniProt、Ensembl、PubChem等数据库集成。常见交叉引用方式:
通过UniProt编号查找ChEMBL靶点:
bash uv run scripts/chembl_api.py target --filter target_components__accession=P00533 --limit 5 --output /tmp/uniprot_target.json解析ChEMBL ID对应的实体类型:
bash uv run scripts/chembl_api.py chembl_id_lookup --id CHEMBL203 --output /tmp/lookup.json查看交叉引用来源:
bash uv run scripts/chembl_api.py xref_source --limit 10 --output /tmp/xrefs.json提示:使用端点可查找任意ChEMBL靶点对应的UniProt编号、基因名称和蛋白质序列。target_component
9. Pagination
9. 分页
All list endpoints support and for pagination:
--limit--offsetbash
undefined所有列表端点均支持和参数用于分页:
--limit--offsetbash
undefinedFirst page: 2 results starting at offset 0
第一页:从偏移量0开始返回2条结果
uv run scripts/chembl_api.py molecule --limit 2 --offset 0 --output /tmp/page1.json
uv run scripts/chembl_api.py molecule --limit 2 --offset 0 --output /tmp/page1.json
Second page: next 2 results starting at offset 2
第二页:从偏移量2开始返回下2条结果
uv run scripts/chembl_api.py molecule --limit 2 --offset 2 --output /tmp/page2.json
The response includes `page_meta` with `total_count`, `limit`, `offset`, `next`,
and `previous` links. Use successive `--offset` values to page through large
result sets.
--------------------------------------------------------------------------------uv run scripts/chembl_api.py molecule --limit 2 --offset 2 --output /tmp/page2.json
响应结果包含`page_meta`字段,其中有`total_count`、`limit`、`offset`、`next`和`previous`链接。可通过连续设置`--offset`值来遍历大型结果集。
--------------------------------------------------------------------------------10. Other Endpoints
10. 其他端点
All remaining endpoints follow the same pattern:
bash
uv run scripts/chembl_api.py <subcommand> --output <file> [--id ID | --ids ID1;ID2 | --search QUERY] [--limit N] [--offset N] [--filter KEY=VAL ...]Key subcommands at a glance:
- (searchable: true): Molecules/compounds — the primary entry point
molecule - (searchable: true): Drug targets (proteins, organisms, etc.)
target - (searchable: true): Bioactivity data (IC50, Ki, EC50, etc.)
activity - (searchable: false): Approved drugs
drug - (searchable: false): Mechanisms of action
mechanism - (searchable: true): Assay descriptions
assay - (searchable: false): Similarity search (special)
similarity - (searchable: false): Substructure search (special)
substructure - (searchable: false): Compound image download (special)
image
Full subcommand list:
- (searchable: false): Supplementary activity data
activity_supp - (searchable: false): Assay classifications
assay_class - (searchable: false): ATC drug classifications
atc_class - (searchable: false): Binding site information
binding_site - (searchable: false): Biotherapeutic molecules
biotherapeutic - (searchable: false): Cell line details
cell_line - (searchable: true): ChEMBL ID resolution
chembl_id_lookup - (searchable: false): Database release info
chembl_release - (searchable: false): Compound records
compound_record - (searchable: false): Structural alerts
compound_structural_alert - (searchable: true): Literature documents
document - (searchable: false): Document similarity
document_similarity - (searchable: false): Drug indications
drug_indication - (searchable: false): Drug safety warnings
drug_warning - (searchable: false): GO slim terms
go_slim - (searchable: false): Metabolism data
metabolism - (searchable: false): Molecule forms (salts/parents)
molecule_form - (searchable: false): Organisms
organism - (searchable: true): Protein classifications
protein_classification - (searchable: false): Data sources
source - (searchable: false): Target protein components
target_component - (searchable: false): Target relationships
target_relation - (searchable: false): Tissue types
tissue - (searchable: false): Cross-reference sources
xref_source - (searchable: false): API status check (special)
status
所有剩余端点遵循相同格式:
bash
uv run scripts/chembl_api.py <subcommand> --output <file> [--id ID | --ids ID1;ID2 | --search QUERY] [--limit N] [--offset N] [--filter KEY=VAL ...]核心子命令概览:
- (可搜索:是):分子/化合物 — 主要入口
molecule - (可搜索:是):药物靶点(蛋白质、生物等)
target - (可搜索:是):生物活性数据(IC50、Ki、EC50等)
activity - (可搜索:否):已获批药物
drug - (可搜索:否):作用机制
mechanism - (可搜索:是):试验描述
assay - (可搜索:否):相似性搜索(特殊)
similarity - (可搜索:否):子结构搜索(特殊)
substructure - (可搜索:否):化合物图像下载(特殊)
image
完整子命令列表:
- (可搜索:否):补充活性数据
activity_supp - (可搜索:否):试验分类
assay_class - (可搜索:否):ATC药物分类
atc_class - (可搜索:否):结合位点信息
binding_site - (可搜索:否):生物治疗分子
biotherapeutic - (可搜索:否):细胞系详情
cell_line - (可搜索:是):ChEMBL ID解析
chembl_id_lookup - (可搜索:否):数据库版本信息
chembl_release - (可搜索:否):化合物记录
compound_record - (可搜索:否):结构警示
compound_structural_alert - (可搜索:是):文献资料
document - (可搜索:否):文献相似性
document_similarity - (可搜索:否):药物适应症
drug_indication - (可搜索:否):药物安全警示
drug_warning - (可搜索:否):GO精简术语
go_slim - (可搜索:否):代谢数据
metabolism - (可搜索:否):分子形式(盐/母核)
molecule_form - (可搜索:否):生物种类
organism - (可搜索:是):蛋白质分类
protein_classification - (可搜索:否):数据源
source - (可搜索:否):靶点蛋白质组件
target_component - (可搜索:否):靶点关联关系
target_relation - (可搜索:否):组织类型
tissue - (可搜索:否):交叉引用来源
xref_source - (可搜索:否):API状态检查(特殊)
status
Common Options
通用参数
- : Required. Output file path for JSON results.
--output FILE - : Fetch a single record by ID.
--id ID - : Batch fetch multiple records.
--ids ID1;ID2;... - : Free-text search (only for searchable endpoints, marked ✓).
--search QUERY - : Max results to return (default: 5).
--limit N - : Pagination offset.
--offset N - : Filter parameters (can specify multiple).
--filter KEY=VAL - : (activity only) Normalize values to nM.
--normalize - : (molecule only) Download structure file.
--dl_format sdf|mol
- :必填。JSON结果的输出文件路径。
--output FILE - :按ID获取单条记录。
--id ID - :批量获取多条记录。
--ids ID1;ID2;... - :自由文本搜索(仅适用于标记为可搜索的端点)。
--search QUERY - :返回的最大结果数(默认:5)。
--limit N - :分页偏移量。
--offset N - :过滤参数(可指定多个)。
--filter KEY=VAL - :(仅activity端点)将值标准化为nM。
--normalize - :(仅molecule端点)下载结构文件。
--dl_format sdf|mol
Reference
参考资料
- API Endpoints Reference: See references/api_endpoints.md for the full list of endpoints and filter operators.
- API端点参考:查看references/api_endpoints.md获取完整端点列表和过滤操作符。
Workflow
工作流程
- Use to verify the API is available.
status --output /tmp/status.json - Search for targets, molecules, or drugs using the relevant subcommand.
- Read the output JSON file to extract IDs and data.
- Use IDs from search results to fetch detailed records.
- Query with filters to get bioactivity data for targets/molecules. Use
activitywhen comparing values across studies.--normalize - Use or
similarityfor server-side structure-based queries.substructure - Download compound images with or structure files with
image.molecule --dl_format sdf - Use to cross- reference with UniProt.
target --filter target_components__accession=<UniProt>
- 使用验证API是否可用。
status --output /tmp/status.json - 使用相关子命令搜索靶点、分子或药物。
- 读取输出JSON文件以提取ID和数据。
- 使用搜索结果中的ID获取详细记录。
- 带过滤参数查询端点,获取靶点/分子的生物活性数据。比较不同研究的数据时使用
activity参数。--normalize - 使用或
similarity端点执行服务器端基于结构的查询。substructure - 使用端点下载化合物图像,或使用
image下载结构文件。molecule --dl_format sdf - 使用与UniProt进行交叉引用。
target --filter target_components__accession=<UniProt>