-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpdb_fix.py
52 lines (46 loc) · 1.74 KB
/
pdb_fix.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
from pdbfixer import PDBFixer
from openmm.app.pdbfile import PDBFile
import os
def fix_pdb(pdb_id):
path = os.getcwd()
if len(pdb_id) != 4:
print("Creating PDBFixer...")
fixer = PDBFixer(pdb_id)
print("Finding missing residues...")
fixer.findMissingResidues()
chains = list(fixer.topology.chains())
keys = fixer.missingResidues.keys()
for key in list(keys):
chain = chains[key[0]]
if key[1] == 0 or key[1] == len(list(chain.residues())):
print("ok")
del fixer.missingResidues[key]
print("Finding nonstandard residues...")
fixer.findNonstandardResidues()
print("Replacing nonstandard residues...")
fixer.replaceNonstandardResidues()
print("Removing heterogens...")
fixer.removeHeterogens(keepWater=True)
print("Finding missing atoms...")
fixer.findMissingAtoms()
print("Adding missing atoms...")
fixer.addMissingAtoms()
print("Adding missing hydrogens...")
fixer.addMissingHydrogens(7)
print("Writing PDB file...")
PDBFile.writeFile(
fixer.topology,
fixer.positions,
open(os.path.join(path, "%s_fixed_pH_%s.pdb" % (pdb_id.split('.')[0], 7)),
"w"),
keepIds=True)
return "%s_fixed_pH_%s.pdb" % (pdb_id.split('.')[0], 7)
fix_pdb('pdbs/aaa_capped.pdb')
from simtk.openmm.app import *
from simtk.openmm import *
from simtk.unit import *
from sys import stdout
pdb = app.PDBFile('pdbs/aaa_capped_pdbfixed.pdb')
modeller = app.Modeller(pdb.topology, pdb.positions)
forcefield = ForceField('amber14-all.xml', 'amber14/tip3pfb.xml')
system = forcefield.createSystem(modeller.topology)