Вы можете взглянуть на пакет 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