SuperAPI AI 工具集

pdb

数据与分析

查看项目

更新于 10-15 10:04

技能介绍

用途

该技能用于从 RCSB PDB 获取和分析蛋白质结构,服务于蛋白质设计流程中的结构准备与检索需求。它直接使用 RCSB PDB 的 Web API,所有操作在本地通过 HTTP 请求完成,无需 Modal 部署。

主要能力

获取结构

可按 PDB ID 下载结构文件,支持 PDB 和 mmCIF 格式。例如使用 curl 下载 PDB 文件:

curl -o 1alu.pdb "https://files.rcsb.org/download/1ALU.pdb"

下载 mmCIF:

curl -o 1alu.cif "https://files.rcsb.org/download/1ALU.cif"

也可使用 Python 的 Bio.PDB 模块:

from Bio.PDB import PDBList

pdbl = PDBList()
pdbl.retrieve_pdb_file("1ABC", pdir="structures/", file_format="pdb")

或通过 RCSB API 获取:

import requests

def fetch_pdb(pdb_id: str, format: str = "pdb") -> str:
    """Fetch structure from RCSB PDB."""
    url = f"https://files.rcsb.org/download/{pdb_id}.{format}"
    response = requests.get(url)
    response.raise_for_status()
    return response.text

def fetch_fasta(pdb_id: str) -> str:
    """Fetch sequence in FASTA format."""
    url = f"https://www.rcsb.org/fasta/entry/{pdb_id}"
    return requests.get(url).text

# Example usage
pdb_content = fetch_pdb("1ALU")
with open("1ALU.pdb", "w") as f:
    f.write(pdb_content)

结构准备

可选择特定链,例如提取链 A:

from Bio.PDB import PDBParser, PDBIO, Select

class ChainSelect(Select):
    def __init__(self, chain_id):
        self.chain_id = chain_id

    def accept_chain(self, chain):
        return chain.id == self.chain_id

# Extract chain A
parser = PDBParser()
structure = parser.get_structure("protein", "1abc.pdb")
io = PDBIO()
io.set_structure(structure)
io.save("chain_A.pdb", ChainSelect("A"))

可围绕指定残基裁剪结合区域:

def trim_around_residues(pdb_file, center_residues, buffer=10.0):
    """Trim structure to region around specified residues."""
    parser = PDBParser()
    structure = parser.get_structure("protein", pdb_file)

    # Get center coordinates
    center_coords = []
    for res in structure.get_residues():
        if res.id[1] in center_residues:
            center_coords.extend([a.coord for a in res.get_atoms()])

    center = np.mean(center_coords, axis=0)

    # Keep residues within buffer
    class RegionSelect(Select):
        def accept_residue(self, res):
            for atom in res.get_atoms():
                if np.linalg.norm(atom.coord - center) < buffer:
                    return True
            return False

    io = PDBIO()
    io.set_structure(structure)
    io.save("trimmed.pdb", RegionSelect())

搜索 PDB

可通过 RCSB Search API 进行全文搜索:

import requests

query = {
    "query": {
        "type": "terminal",
        "service": "full_text",
        "parameters": {
            "value": "EGFR kinase domain"
        }
    },
    "return_type": "entry"
}

response = requests.post(
    "https://search.rcsb.org/rcsbsearch/v2/query",
    json=query
)
results = response.json()

也可按序列相似性搜索:

query = {
    "query": {
        "type": "terminal",
        "service": "sequence",
        "parameters": {
            "value": "MKTAYIAKQRQISFVK...",
            "evalue_cutoff": 1e-10,
            "identity_cutoff": 0.9
        }
    }
}

结构分析

可获取链信息:

def get_structure_info(pdb_file):
    parser = PDBParser(QUIET=True)
    structure = parser.get_structure("protein", pdb_file)

    info = {
        "chains": [],
        "total_residues": 0
    }

    for model in structure:
        for chain in model:
            residues = list(chain.get_residues())
            info["chains"].append({
                "id": chain.id,
                "length": len(residues),
                "first_res": residues[0].id[1],
                "last_res": residues[-1].id[1]
            })
            info["total_residues"] += len(residues)

    return info

可查找两条链之间的界面残基:

def find_interface_residues(pdb_file, chain_a, chain_b, distance=4.0):
    """Find residues at interface between two chains."""
    parser = PDBParser(QUIET=True)
    structure = parser.get_structure("complex", pdb_file)

    interface_a = set()
    interface_b = set()

    for res_a in structure[0][chain_a].get_residues():
        for res_b in structure[0][chain_b].get_residues():
            for atom_a in res_a.get_atoms():
                for atom_b in res_b.get_atoms():
                    if atom_a - atom_b < distance:
                        interface_a.add(res_a.id[1])
                        interface_b.add(res_b.id[1])

    return interface_a, interface_b

使用方式

该技能通过本地 HTTP 请求调用 RCSB PDB 的文件下载接口和搜索接口,结合 Bio.PDB 进行结构解析、链选择、区域裁剪和界面分析。典型流程包括:下载结构、识别目标链、去除水和配体(如需要)、裁剪到结合区域加缓冲、识别潜在热点、必要时重新编号。

适用场景

适用于结合剂设计中的靶点准备,例如需要下载特定 PDB 结构、搜索相似结构、提取特定链、裁剪结合区域、分析链间界面残基等任务。资料提到后续可将结构用于 boltzgen(推荐)或 rfdiffusion 进行设计。

限制

资料未提供收费、价格、平台支持范围等信息。使用中可能遇到的问题包括:结构未找到时需检查 PDB ID 格式(4 个字符);存在多个模型时建议选择第一个模型用于设计;缺失残基时需检查结构中的缺口。