-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathprepareComplex.py
65 lines (54 loc) · 2.2 KB
/
prepareComplex.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from simtk.openmm.app import *
from simtk.openmm import *
from pdbfixer import PDBFixer
if len(sys.argv) != 4:
print('Usage: python prepareComplex.py input.pdb ligand.mol system')
exit(1)
pdb_in = sys.argv[1]
ligand_in = sys.argv[2]
outname = sys.argv[3]
# This PDB file contains:
# - the protein (single chain)
# - a ligand
# - 3 DMSO molecules
# - A number of waters
# No hydrogens are present.
# The C-teminal THR residue is missing an oxygen atom.
fixer = PDBFixer(filename=pdb_in)
fixer.findMissingResidues()
fixer.findMissingAtoms()
fixer.findNonstandardResidues()
print('Residues:', fixer.missingResidues)
print('Atoms:', fixer.missingAtoms)
print('Terminals:', fixer.missingTerminals)
print('Non-standard:', fixer.nonstandardResidues)
fixer.addMissingAtoms()
fixer.addMissingHydrogens(7.4)
# The following removes the DMS components and retains the ligand and waters.
# If instead we want to remove the ligand it will be easier to use:
# fixer.removeHeterogens(True) or fixer.removeHeterogens(False)
# True keeps the waters, False removes them leaving only the protein.
# See prepareProtein.py for this in action.
modeller = Modeller(fixer.topology, fixer.positions)
toDelete = []
for res in modeller.topology.residues():
if res.name == 'DMS':
toDelete.append(res)
print('Deleting', res)
modeller.delete(toDelete)
with open(outname + '_receptor.pdb', 'w') as outfile:
PDBFile.writeFile(modeller.topology, modeller.positions, file=outfile, keepIds=True)
# Now the ligand. We write it to a file in PDB format. It would be good to write to Molfile format but seems that
# OpenMM does not support that.
# Note: this may not be the best way to do this. Other toolkits might be better.
# Note: your ligand may not be named 'LIG'
# Note: modeller.addHydrogens() does not work for ligands. We'll need to use another toolkit such as OpenBabel or RDKit to do this.
modeller = Modeller(fixer.topology, fixer.positions)
toDelete = []
for res in modeller.topology.residues():
if res.name != 'LIG':
toDelete.append(res)
modeller.delete(toDelete)
with open(outname + '_ligand.pdb', 'w') as outfile:
PDBFile.writeFile(modeller.topology, modeller.positions, file=outfile, keepIds=True)
print('Done')