将多个 PDB 文件拆分为链并保存为单独的文件

发布于 2025-01-11 22:08:42 字数 587 浏览 0 评论 0原文

我正在尝试使用 Biopython 拆分大量 pdb 文件,然后将它们保存为名为 pdbid_chain.pdb 的单独文件。到目前为止我还没有成功。另外,我对 python 还很陌生。

非常感谢任何帮助!

这是我的代码:

#pdb_list contains a list of 208 pdb structures 

io = PDBIO()
     
#parse structures
for f in pdb_list:
    pdb_parsed = PDBParser().get_structure(pdb_ids, str(PDB_RAW_DIR) + '/' + f)
    
#save chains
for structure in pdb_parsed:
        pdb_chains = structure.get_chains()
        for chain in pdb_chains:
            io.set_structure(chain)
            io.save(pdb_parsed.get_id() + "_" + chain.get_id() + ".pdb")

干杯!

I am trying to split a large number of pdb files using Biopython and then save them as separate files called pdbid_chain.pdb . So far I did not succeed. Additionally, I am quite new to python.

Any help is highly appreciated!

Here is my code:

#pdb_list contains a list of 208 pdb structures 

io = PDBIO()
     
#parse structures
for f in pdb_list:
    pdb_parsed = PDBParser().get_structure(pdb_ids, str(PDB_RAW_DIR) + '/' + f)
    
#save chains
for structure in pdb_parsed:
        pdb_chains = structure.get_chains()
        for chain in pdb_chains:
            io.set_structure(chain)
            io.save(pdb_parsed.get_id() + "_" + chain.get_id() + ".pdb")

Cheers!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绮烟 2025-01-18 22:08:42

一种简单的解决方案是使用 MDAnalysis 并使用选择代数来选择不同的链。

这是一个简单的例子。 Complex.pdb 包含两个链 A 和 I。将创建两个新的 pdb 文件,其中链是分开的。

import MDAnalysis

# Import the pdb file as universe
u = MDAnalysis.Universe('complex.pdb')

# select chain A as receptor
receptor = u.select_atoms("chainID A")

# select chain I as ligand
ligand = u.select_atoms("chainID I")

# Save separated files as pdb
receptor.write("receptor.pdb")
ligand.write("ligand.pdb")

One simple solution is to use MDAnalysis and use the selection algebra to select different chains.

Here is a simple example. The complex.pdb contains two chains A and I. Two new pdb files are created in which the chains are separated.

import MDAnalysis

# Import the pdb file as universe
u = MDAnalysis.Universe('complex.pdb')

# select chain A as receptor
receptor = u.select_atoms("chainID A")

# select chain I as ligand
ligand = u.select_atoms("chainID I")

# Save separated files as pdb
receptor.write("receptor.pdb")
ligand.write("ligand.pdb")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文