Biopython提供了Bio.PDB模块来操纵多肽结构。PDB(蛋白质数据库)是在线上最大的蛋白质结构资源。它具有许多不同的蛋白质结构,包括蛋白质-蛋白质,蛋白质-DNA,蛋白质-RNA复合物。

1. 下载结构数据文件

from Bio.PDB import *

pdbl = PDBList()
# 它将从服务器下载指定的文件(2fat.cif)并将其存储在当前工作目录中。
pdbl.retrieve_pdb_file('3JCL', pdir = '.', file_format = 'mmCif')
# pdbl.retrieve_pdb_file('3JCL', pdir = '.', file_format = 'pdb') 

## 批量下载
pdb_lst = ["3JCL","2FAT"]
for id in ["3JCL","2FAT"]:
    pdbl.retrieve_pdb_file(id, pdir = '.', file_format = 'mmCif')

2. 结构可视化

#可视化插件安装

pip install nglview

# 启动jupyter时候加载
jupyter-nbextension enable nglview --py --sys-prefix

# 查看结构

import nglview
view = nglview.show_file("pdb3jcl.ent")
view

3. 结构解析器

parser = MMCIFParser(QUIET = True) 
structure = parser.get_structure("3JCL", "3jcl.cif")
## for pdf文件类型
# parser = PDBParser(PERMISSIVE = True, QUIET = True)
# data = parser.get_structure("3jcl","pdb3jcl.ent")

print(type(structure)) 
print(structure.header.keys()) 
print(structure.header) 

# Structure.get_models()方法返回模型上的迭代器
model = structure.get_models() 
models = list(model) 
print(models[0])
print("模型的数量:",end="")
print(len(models))

# Model.get_chain()方法返回链上的迭代器
chain_lst = list(models[0].get_chains())
print("链的数量:",end="")
print(len(chain_lst))

for chain in chain_lst:
    print(chain)
    #Chain.get_residues()方法返回残基上的迭代器
    residue_lst = list(chain.get_residues())
    print("肽链长度:",end="")
    print(len(residue_lst)) 
    print(residue_lst)
    
    print("氨基酸序列信息:")
    for residue in residue_lst:
        print(end="")
        print(residue.get_id())
        print(residue.get_resname())
        print (residue)  
        # Residue.get_atom()返回原子上的迭代器
        print("此氨基酸上的原子信息:")
        for atom in list(residue.get_atoms()):
            print(atom)
            print(atom.get_vector())
            print(atom.get_coord())
        print("======")

参考:

https://www.rcsb.org/
https://biopython.org/wiki/The_Biopython_Structural_Bioinformatics_FAQ
https://www.yiibai.com/biopython/biopython-pdb-module.html

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐