0

我正在使用 Biopython 对 pdb 文件执行各种操作。随后我想在 Biopython 生成的 Biopython 结构对象中添加一些新的原子。在 Python 中是否有一个好的/推荐的方法来做到这一点。似乎 Biopython 只提供选项来写出 pdb 文件的现有元素,而不是创建新元素。

4

2 回答 2

1

您可以查看 Python 包Biotite ( https://www.biotite-python.org/ ),这是我正在开发的一个包。在以下示例代码中,下载、读取 PDB 结构,然后添加原子:

import biotite.database.rcsb as rcsb
import biotite.structure as struc
import biotite.structure.io as strucio


# Download lysozyme structure for example
file_name = rcsb.fetch("1aki", "pdb", target_path=".")

# Read the file into Biotite's structure object (atom array)
atom_array = strucio.load_structure(file_name)

# Add an HETATM
atom = struc.Atom(
    coord = [1.0, 2.0, 3.0],
    chain_id = "A",
    # The residue ID is the last ID in the file +1
    res_id = atom_array.res_id[-1] + 1,
    res_name = "ABC",
    hetero = True,
    atom_name = "CA",
    element = "C"
)
atom_array += struc.array([atom])

# Save edited structure
strucio.save_structure("1aki_edited.pdb", atom_array)

的最后几行1aki_edited.pdb

...
HETATM 1075 O    HOH A 203      12.580  21.214   5.006  1.00 0.000          O   
HETATM 1076 O    HOH A 204      19.687  23.750  -4.851  1.00 0.000          O   
HETATM 1077 O    HOH A 205      27.098  35.956 -12.358  1.00 0.000          O   
HETATM 1078 O    HOH A 206      37.255   9.634  10.002  1.00 0.000          O   
HETATM 1079 O    HOH A 207      43.755  23.843   8.038  1.00 0.000          O   
HETATM 1080 CA   ABC A 208       1.000   2.000   3.000  1.00 0.000          C 
于 2019-11-11T10:11:43.060 回答
0

I have used RDKit to add and edit atoms in PDB-files succesfully. Below I've shown a small example of how to add a carbon atom to a PDB-file and creating a new .pdb-file

from rdkit import Chem
from rdkit.Chem import rdGeometry

prot = Chem.MolFromPDBFile("./3etr.pdb") #Read in the .pdb-file
protconf = prot.GetConformer() #create a conformer of the molecule

#create an editable mol-object
mw = Chem.RWMol(mol)

#create an editable conformer. This dictates the atoms coordinates and other attributes
mw_conf = mw.GetConformer() 

#add a carbon atom to the editable mol. Returns the index of the new atom, which is the same as prot.GetNumAtoms() + 1
c_idx = mw.AddAtom(Chem.Atom(6))  

#cartesian coordinates of the new atom. I think the Point3D object is not strictly necessary. but can be easier to handle in RDKit
coord = rdGeometry.Point3D(1.0, 2.0, 3.0)

#set the new coordinates
mw_conf.SetAtomPosition(c_idx, coord) 

#save the edited PDB-file
pdb_out = Chem.MolToPDBFile(mw_conf, "_out.pdb")
于 2020-02-27T14:41:54.717 回答