mcpField
B
bindingdb-database

bindingdb-database

github.com/leonchaox数据与数据库98570 次安装14 周前更新
代码仓库

关于 bindingdb-database

bindingdb-database 是用于查询和分析 BindingDB 的技能;该公共数据库收录药物与蛋白质的实测结合亲和力。它通过 API 和可下载数据支持药物发现及计算化学研究。

主要功能

  1. 01按蛋白质靶标查询亲和力
  2. 02按名称或 SMILES 搜索化合物
  3. 03分析构效关系
  4. 04分析化合物靶标选择性
  5. 05整理用于 ML 的亲和力数据

适用场景

  1. 01查找靶标的配体及亲和力
  2. 02比较一组类似物的效力
  3. 03检查潜在脱靶结合
  4. 04整理蛋白质-配体训练数据

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/leonchaox/qinyan-academic-skills --skill bindingdb-database

安装后在 Claude Code 中输入/bindingdb-database确认已加载。

附带文件references/affinity_queries.md

详细介绍

BindingDB 数据库

概述

BindingDB(https://www.bindingdb.org/)是主要的公开药物-蛋白质结合亲和力测量数据库。它包含超过 300 万条结合数据记录,涉及约 140 万种化合物与约 9,200 个蛋白质靶点的测试数据,这些数据整理自科学文献和专利文献。BindingDB 存储定量结合测量值(Ki、Kd、IC50、EC50),对药物发现、药理学和计算化学研究至关重要。

关键资源:

何时使用此技能

以下情况可使用 BindingDB:

  • 基于靶点的药物发现:有哪些已知化合物能与某个靶蛋白结合?其亲和力如何?
  • SAR 分析:结构修饰如何影响一系列类似物的结合亲和力?
  • 先导化合物分析:某种化合物能与哪些靶点结合(选择性/多重药理学)?
  • 基准数据集:获取经过整理的蛋白质-配体亲和力数据,用于 ML 模型训练
  • 药物再利用分析:已获批药物是否能与非预期靶点结合?
  • 竞争分析:某类靶点已报道的最佳亲和力是多少?
  • 片段筛选:查找针对某个靶点的片段验证结合数据

核心功能

1. BindingDB REST API

基础 URL:https://www.bindingdb.org/axis2/services/BDBService

import requests

BASE_URL = "https://www.bindingdb.org/axis2/services/BDBService"

def bindingdb_query(method, params):
    """Query the BindingDB REST API."""
    url = f"{BASE_URL}/{method}"
    response = requests.get(url, params=params, headers={"Accept": "application/json"})
    response.raise_for_status()
    return response.json()
2. 按靶点(UniProt ID)查询
def get_ligands_for_target(uniprot_id, affinity_type="Ki", cutoff=10000, unit="nM"):
    """
    Get all ligands with measured affinity for a UniProt target.

    Args:
        uniprot_id: UniProt accession (e.g., "P00519" for ABL1)
        affinity_type: "Ki", "Kd", "IC50", "EC50"
        cutoff: Maximum affinity value to return (in nM)
        unit: "nM" or "uM"
    """
    params = {
        "uniprot_id": uniprot_id,
        "affinity_type": affinity_type,
        "affinity_cutoff": cutoff,
        "response": "json"
    }
    return bindingdb_query("getLigandsByUniprotID", params)

# Example: Get all compounds binding ABL1 (imatinib target)
ligands = get_ligands_for_target("P00519", affinity_type="Ki", cutoff=100)
3. 按化合物名称或 SMILES 查询
def search_by_name(compound_name, limit=100):
    """Search BindingDB for compounds by name."""
    params = {
        "compound_name": compound_name,
        "response": "json",
        "max_results": limit
    }
    return bindingdb_query("getAffinitiesByCompoundName", params)

def search_by_smiles(smiles, similarity=100, limit=50):
    """
    Search BindingDB by SMILES string.

    Args:
        smiles: SMILES string of the compound
        similarity: Tanimoto similarity threshold (1-100, 100 = exact)
    """
    params = {
        "SMILES": smiles,
        "similarity": similarity,
        "response": "json",
        "max_results": limit
    }
    return bindingdb_query("getAffinitiesByBEI", params)

# Example: Search for imatinib binding data
result = search_by_name("imatinib")
4. 基于下载的数据进行分析(大规模查询时推荐)

如需进行全面分析,可直接下载 BindingDB 数据:

import pandas as pd

def load_bindingdb(filepath="BindingDB_All.tsv"):
    """
    Load BindingDB TSV file.
    Download from: https://www.bindingdb.org/bind/chemsearch/marvin/Download.jsp
    """
    # Key columns
    usecols = [
        "BindingDB Reactant_set_id",
        "Ligand SMILES",
        "Ligand InChI",
        "Ligand InChI Key",
        "BindingDB Target Chain  Sequence",
        "PDB ID(s) for Ligand-Target Complex",
        "UniProt (SwissProt) Entry Name of Target Chain",
        "UniProt (SwissProt) Primary ID of Target Chain",
        "UniProt (TrEMBL) Primary ID of Target Chain",
        "Ki (nM)",
        "IC50 (nM)",
        "Kd (nM)",
        "EC50 (nM)",
        "kon (M-1-s-1)",
        "koff (s-1)",
        "Target Name",
        "Target Source Organism According to Curator or DataSource",
        "Number of Protein Chains in Target (>1 implies a multichain complex)",
        "PubChem CID",
        "PubChem SID",
        "ChEMBL ID of Ligand",
        "DrugBank ID of Ligand",
    ]

    df = pd.read_csv(filepath, sep="\t", usecols=[c for c in usecols if c],
                     low_memory=False, on_bad_lines='skip')

    # Convert affinity columns to numeric
    for col in ["Ki (nM)", "IC50 (nM)", "Kd (nM)", "EC50 (nM)"]:
        if col in df.columns:
            df[col] = pd.to_numeric(df[col], errors='coerce')

    return df

def query_target_affinity(df, uniprot_id, affinity_types=None, max_nm=10000):
    """Query loaded BindingDB for a specific target."""
    if affinity_types is None:
        affinity_types = ["Ki (nM)", "IC50 (nM)", "Kd (nM)"]

    # Filter by UniProt ID
    mask = df["UniProt (SwissProt) Primary ID of Target Chain"] == uniprot_id
    target_df = df[mask].copy()

    # Filter by affinity cutoff
    has_affinity = pd.Series(False, index=target_df.index)
    for col in affinity_types:
        if col in target_df.columns:
            has_affinity |= target_df[col] <= max_nm

    result = target_df[has_affinity][["Ligand SMILES"] + affinity_types +
                                      ["PubChem CID", "ChEMBL ID of Ligand"]].dropna(how='all')
    return result.sort_values(affinity_types[0])
5. SAR 分析
import pandas as pd

def sar_analysis(df, target_uniprot, affinity_col="IC50 (nM)"):
    """
    Structure-activity relationship analysis for a target.
    Retrieves all compounds with affinity data and ranks by potency.
    """
    target_data = query_target_affinity(df, target_uniprot, [affinity_col])

    if target_data.empty:
        return target_data

    # Add pIC50 (negative log of IC50 in molar)
    if affinity_col in target_data.columns:
        target_data = target_data[target_data[affinity_col].notna()].copy()
        target_data["pAffinity"] = -((target_data[affinity_col] * 1e-9).apply(
            lambda x: __import__('math').log10(x)
        ))
        target_data = target_data.sort_values("pAffinity", ascending=False)

    return target_data

# Most potent compounds against EGFR (P00533)
# sar = sar_analysis(df, "P00533", "IC50 (nM)")
# print(sar.head(20))
6. 多重药理学概况
def polypharmacology_profile(df, ligand_smiles_or_name, affinity_cutoff_nM=1000):
    """
    Find all targets a compound binds to.
    Uses PubChem CID or SMILES for matching.
    """
    # Search by ligand SMILES (exact match)
    mask = df["Ligand SMILES"] == ligand_smiles_or_name

    ligand_data = df[mask].copy()

    # Filter by affinity
    aff_cols = ["Ki (nM)", "IC50 (nM)", "Kd (nM)"]
    has_aff = pd.Series(False, index=ligand_data.index)
    for col in aff_cols:
        if col in ligand_data.columns:
            has_aff |= ligand_data[col] <= affinity_cutoff_nM

    result = ligand_data[has_aff][
        ["Target Name", "UniProt (SwissProt) Primary ID of Target Chain"] + aff_cols
    ].dropna(how='all')

    return result.sort_values("Ki (nM)")

查询工作流

工作流 1:查找某个靶点的最佳抑制剂
import pandas as pd

def find_best_inhibitors(uniprot_id, affinity_type="IC50 (nM)", top_n=20):
    """Find the most potent inhibitors for a target in BindingDB."""
    df = load_bindingdb("BindingDB_All.tsv")  # Load once and reuse
    result = query_target_affinity(df, uniprot_id, [affinity_type])

    if result.empty:
        print(f"No data found for {uniprot_id}")
        return result

    result = result.sort_values(affinity_type).head(top_n)
    print(f"Top {top_n} inhibitors for {uniprot_id} by {affinity_type}:")
    for _, row in result.iterrows():
        print(f"  {row['PubChem CID']}: {row[affinity_type]:.1f} nM | SMILES: {row['Ligand SMILES'][:40]}...")
    return result
工作流 2:选择性分析
  1. 获取化合物针对所有靶点的全部亲和力数据
  2. 比较靶内与靶外的亲和力比值
  3. 找出选择性断崖(可提高选择性的结构变化)
  4. 与 ChEMBL 交叉比对,获取更多选择性数据
工作流 3:机器学习数据集准备
def prepare_ml_dataset(df, uniprot_ids, affinity_col="IC50 (nM)",
                        max_affinity_nM=100000, min_count=50):
    """Prepare BindingDB data for ML model training."""
    records = []
    for uid in uniprot_ids:
        target_df = query_target_affinity(df, uid, [affinity_col], max_affinity_nM)
        if len(target_df) >= min_count:
            target_df = target_df.copy()
            target_df["target"] = uid
            records.append(target_df)

    if not records:
        return pd.DataFrame()

    combined = pd.concat(records)
    # Add pAffinity (normalized)
    combined["pAffinity"] = -((combined[affinity_col] * 1e-9).apply(
        lambda x: __import__('math').log10(max(x, 1e-12))
    ))
    return combined[["Ligand SMILES", "target", "pAffinity", affinity_col]].dropna()

关键数据字段

字段描述
Ligand SMILES化合物的 2D 结构
Ligand InChI Key唯一化学标识符
Ki (nM)抑制常数(平衡态、功能性)
Kd (nM)解离常数(热力学、结合)
IC50 (nM)半数抑制浓度
EC50 (nM)半数有效浓度
kon (M-1-s-1)结合速率常数
koff (s-1)解离速率常数
UniProt (SwissProt) Primary ID靶点 UniProt 登录号
Target Name蛋白质名称
PDB ID(s) for Ligand-Target Complex晶体结构
PubChem CIDPubChem 化合物 ID
ChEMBL ID of LigandChEMBL 化合物 ID

亲和力解读

亲和力分类药物相似性
< 1 nM亚纳摩尔级效力极强(皮摩尔级)
1–10 nM纳摩尔级效力强,是已获批药物的典型水平
10–100 nM中等常见的先导化合物
100–1000 nM较弱片段/起始点
> 1000 nM极弱通常低于与药物相关的阈值

最佳实践

  • 直接结合时使用 Ki:Ki 反映真实的结合亲和力,不受酶作用机制影响
  • IC50 受上下文影响:IC50 值取决于底物浓度(Cheng-Prusoff 方程)
  • 统一单位:BindingDB 以 nM 为单位报告数据;跨研究比较时请确认单位
  • 按靶标生物筛选:使用 Target Source Organism 确保数据来自人类蛋白质
  • 处理缺失值:并非所有化合物都有所有类型的测量数据
  • 与 ChEMBL 交叉参考:ChEMBL 为药物化学提供了更多经过整理的活性数据

其他资源

评论

支持 Markdown