Skip to content

Commit 3783cc8

Browse files
authored
Fix glycam ffxml and conversion script (#180)
* fix glycam * fix imports * fix OLP external bonds * remove diffs in atom ordering * remove atom ordering diffs introduced by last commit * fix remaining atom ordering diffs
1 parent 73a0707 commit 3783cc8

File tree

2 files changed

+49
-41
lines changed

2 files changed

+49
-41
lines changed

amber/convert_amber.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
from __future__ import print_function, division
44
from io import StringIO
55
import parmed
6-
from parmed.utils.six import iteritems
7-
from parmed.utils.six.moves import StringIO, zip
6+
import openmm
87
import openmm.app as app
98
import openmm.unit as u
109
import os
@@ -1493,19 +1492,37 @@ def modify_glycan_ffxml(input_ffxml_path):
14931492

14941493
# Add initialization script for setting up GlycamTemplateMatcher
14951494
initialization_script = etree.SubElement(root, 'InitializationScript')
1496-
initialization_script.text = """
1495+
initialization_script.text = """
1496+
from openmm.app.internal import compiled
1497+
14971498
class GlycamTemplateMatcher(object):
1499+
14981500
def __init__(self, glycam_residues):
14991501
self.glycam_residues = glycam_residues
1500-
def __call__(self, ff, residue):
1502+
1503+
def __call__(self, ff, residue, bondedToAtom, ignoreExternalBonds, ignoreExtraParticles):
15011504
if residue.name in self.glycam_residues:
1502-
return ff._templates[residue.name]
1505+
template = ff._templates[residue.name]
1506+
if compiled.matchResidueToTemplate(residue, template, bondedToAtom, ignoreExternalBonds, ignoreExtraParticles) is not None:
1507+
return template
1508+
1509+
# The residue doesn't actually match the template with the same name. Try the terminal variants.
1510+
1511+
if 'N'+residue.name in self.glycam_residues:
1512+
template = ff._templates['N'+residue.name]
1513+
if compiled.matchResidueToTemplate(residue, template, bondedToAtom, ignoreExternalBonds, ignoreExtraParticles) is not None:
1514+
return template
1515+
if 'C'+residue.name in self.glycam_residues:
1516+
template = ff._templates['C'+residue.name]
1517+
if compiled.matchResidueToTemplate(residue, template, bondedToAtom, ignoreExternalBonds, ignoreExtraParticles) is not None:
1518+
return template
15031519
return None
15041520
15051521
glycam_residues = set()
15061522
for residue in tree.getroot().find('Residues').findall('Residue'):
15071523
glycam_residues.add(residue.get('name'))
15081524
self.registerTemplateMatcher(GlycamTemplateMatcher(glycam_residues))
1525+
15091526
"""
15101527

15111528
tree.write(input_ffxml_path)

amber/ffxml/GLYCAM_06j-1.xml

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<ForceField>
22
<Info>
3-
<DateGenerated>2021-07-13</DateGenerated>
3+
<DateGenerated>2021-10-29</DateGenerated>
44
<Source Source="glycam/leaprc.GLYCAM_06j-1" md5hash="a7359f8d717f92dba02d57d6e0c8f3f7" sourcePackage="AmberTools" sourcePackageVersion="20.15">glycam/leaprc.GLYCAM_06j-1</Source>
55
<Reference>R. Kadirvelraj; O. C. Grant; I. J. Goldstein; H. C. Winter; H. Tateno; E. Fadda; R. J. Woods. Structure and binding analysis of Polyporus squamosus lectin in complex with the Neu5Ac&#945;2-6Gal&#946;1-4GlcNAc human- type influenza receptor. Glycobiology, 2011, 21, 973&#8211;984. M. L. DeMarco; R. J. Woods. From agonist to antagonist: Structure and dynamics of innate immune glycoprotein MD-2 upon recognition of variably acylated bacterial endotoxins. Mol. Immunol., 2011, 49, 124&#8211;133. B. L. Foley; M. B. Tessier; R. J. Woods. Carbohydrate force fields. WIREs Comput. Mol. Sci., 2012, 2, 652&#8211;697. E. Ficko-Blean; C. P. Stuart; M. D. Suits; M. Cid; M. Tessier; R. J. Woods; A. B. Boraston. Carbohy- drate Recognition by an Architecturally Complex &#945;-N-Acetylglucosaminidase from Clostridium perfrin- gens. PLoS ONE, 2012, 7, e33524.</Reference>
66
</Info>
@@ -40829,9 +40829,7 @@
4082940829
<Bond atomName1="CH3" atomName2="H2" />
4083040830
<Bond atomName1="CH3" atomName2="H3" />
4083140831
<Bond atomName1="CH3" atomName2="O" />
40832-
<ExternalBond atomName="H1" />
4083340832
<ExternalBond atomName="O" />
40834-
<ExternalBond atomName="CH3" />
4083540833
</Residue>
4083640834
<Residue name="PEA" override="1">
4083740835
<Atom name="C1" type="glycam-Cg" charge="0.48" />
@@ -45177,7 +45175,6 @@
4517745175
<Atom name="HO1" type="glycam-Ho" charge="0.445" />
4517845176
<Atom name="O1" type="glycam-Oh" charge="-0.639" />
4517945177
<Bond atomName1="HO1" atomName2="O1" />
45180-
<ExternalBond atomName="HO1" />
4518145178
<ExternalBond atomName="O1" />
4518245179
</Residue>
4518345180
<Residue name="RTA" override="1">
@@ -46421,9 +46418,6 @@
4642146418
<Bond atomName1="S1" atomName2="O2" />
4642246419
<Bond atomName1="S1" atomName2="O3" />
4642346420
<ExternalBond atomName="S1" />
46424-
<ExternalBond atomName="O1" />
46425-
<ExternalBond atomName="O2" />
46426-
<ExternalBond atomName="O3" />
4642746421
</Residue>
4642846422
<Residue name="STA" override="1">
4642946423
<Atom name="C1" type="glycam-Cg" charge="0.456" />
@@ -47229,7 +47223,6 @@
4722947223
<Bond atomName1="C4" atomName2="H7" />
4723047224
<Bond atomName1="C4" atomName2="H8" />
4723147225
<Bond atomName1="C4" atomName2="H9" />
47232-
<ExternalBond atomName="C2" />
4723347226
<ExternalBond atomName="O1" />
4723447227
</Residue>
4723547228
<Residue name="TDA" override="1">
@@ -66389,9 +66382,6 @@
6638966382
<Bond atomName1="C" atomName2="O" />
6639066383
<ExternalBond atomName="N" />
6639166384
<ExternalBond atomName="C" />
66392-
<ExternalBond atomName="CG" />
66393-
<ExternalBond atomName="OD1" />
66394-
<ExternalBond atomName="HOD" />
6639566385
</Residue>
6639666386
<Residue name="OLP" override="1">
6639766387
<Atom name="N" type="protein-N" charge="-0.2548" />
@@ -66424,7 +66414,7 @@
6642466414
<Bond atomName1="C" atomName2="O" />
6642566415
<ExternalBond atomName="N" />
6642666416
<ExternalBond atomName="C" />
66427-
<ExternalBond atomName="CG" />
66417+
<ExternalBond atomName="OD1" />
6642866418
</Residue>
6642966419
<Residue name="CHYP" override="1">
6643066420
<Atom name="N" type="protein-N" charge="-0.28" />
@@ -66460,10 +66450,6 @@
6646066450
<Bond atomName1="C" atomName2="O" />
6646166451
<Bond atomName1="C" atomName2="OXT" />
6646266452
<ExternalBond atomName="N" />
66463-
<ExternalBond atomName="C" />
66464-
<ExternalBond atomName="CG" />
66465-
<ExternalBond atomName="OD1" />
66466-
<ExternalBond atomName="HD1" />
6646766453
</Residue>
6646866454
<Residue name="CNLN" override="1">
6646966455
<Atom name="N" type="protein-N" charge="-0.3821" />
@@ -66494,7 +66480,6 @@
6649466480
<Bond atomName1="C" atomName2="O" />
6649566481
<Bond atomName1="C" atomName2="OXT" />
6649666482
<ExternalBond atomName="N" />
66497-
<ExternalBond atomName="C" />
6649866483
<ExternalBond atomName="ND2" />
6649966484
</Residue>
6650066485
<Residue name="COLP" override="1">
@@ -66529,8 +66514,7 @@
6652966514
<Bond atomName1="C" atomName2="O" />
6653066515
<Bond atomName1="C" atomName2="OXT" />
6653166516
<ExternalBond atomName="N" />
66532-
<ExternalBond atomName="C" />
66533-
<ExternalBond atomName="CG" />
66517+
<ExternalBond atomName="OD1" />
6653466518
</Residue>
6653566519
<Residue name="COLS" override="1">
6653666520
<Atom name="N" type="protein-N" charge="-0.3821" />
@@ -66555,7 +66539,6 @@
6655566539
<Bond atomName1="C" atomName2="O" />
6655666540
<Bond atomName1="C" atomName2="OXT" />
6655766541
<ExternalBond atomName="N" />
66558-
<ExternalBond atomName="C" />
6655966542
<ExternalBond atomName="OG" />
6656066543
</Residue>
6656166544
<Residue name="COLT" override="1">
@@ -66587,7 +66570,6 @@
6658766570
<Bond atomName1="C" atomName2="O" />
6658866571
<Bond atomName1="C" atomName2="OXT" />
6658966572
<ExternalBond atomName="N" />
66590-
<ExternalBond atomName="C" />
6659166573
<ExternalBond atomName="OG1" />
6659266574
</Residue>
6659366575
<Residue name="NHYP" override="1">
@@ -66625,11 +66607,7 @@
6662566607
<Bond atomName1="CA" atomName2="HA" />
6662666608
<Bond atomName1="CA" atomName2="C" />
6662766609
<Bond atomName1="C" atomName2="O" />
66628-
<ExternalBond atomName="N" />
6662966610
<ExternalBond atomName="C" />
66630-
<ExternalBond atomName="CG" />
66631-
<ExternalBond atomName="OD1" />
66632-
<ExternalBond atomName="HD1" />
6663366611
</Residue>
6663466612
<Residue name="NNLN" override="1">
6663566613
<Atom name="N" type="protein-N3" charge="0.1801" />
@@ -66661,9 +66639,8 @@
6666166639
<Bond atomName1="CG" atomName2="ND2" />
6666266640
<Bond atomName1="ND2" atomName2="HD21" />
6666366641
<Bond atomName1="C" atomName2="O" />
66664-
<ExternalBond atomName="N" />
66665-
<ExternalBond atomName="C" />
6666666642
<ExternalBond atomName="ND2" />
66643+
<ExternalBond atomName="C" />
6666766644
</Residue>
6666866645
<Residue name="NOLP" override="1">
6666966646
<Atom name="N" type="protein-N3" charge="-0.202" />
@@ -66698,9 +66675,8 @@
6669866675
<Bond atomName1="CA" atomName2="HA" />
6669966676
<Bond atomName1="CA" atomName2="C" />
6670066677
<Bond atomName1="C" atomName2="O" />
66701-
<ExternalBond atomName="N" />
66678+
<ExternalBond atomName="OD1" />
6670266679
<ExternalBond atomName="C" />
66703-
<ExternalBond atomName="CG" />
6670466680
</Residue>
6670566681
<Residue name="NOLS" override="1">
6670666682
<Atom name="N" type="protein-N3" charge="0.1849" />
@@ -66726,9 +66702,8 @@
6672666702
<Bond atomName1="CB" atomName2="HB3" />
6672766703
<Bond atomName1="CB" atomName2="OG" />
6672866704
<Bond atomName1="C" atomName2="O" />
66729-
<ExternalBond atomName="N" />
66730-
<ExternalBond atomName="C" />
6673166705
<ExternalBond atomName="OG" />
66706+
<ExternalBond atomName="C" />
6673266707
</Residue>
6673366708
<Residue name="NOLT" override="1">
6673466709
<Atom name="N" type="protein-N3" charge="0.1812" />
@@ -66760,9 +66735,8 @@
6676066735
<Bond atomName1="CG2" atomName2="HG22" />
6676166736
<Bond atomName1="CG2" atomName2="HG23" />
6676266737
<Bond atomName1="C" atomName2="O" />
66763-
<ExternalBond atomName="N" />
66764-
<ExternalBond atomName="C" />
6676566738
<ExternalBond atomName="OG1" />
66739+
<ExternalBond atomName="C" />
6676666740
</Residue>
6676766741
</Residues>
6676866742
<HarmonicBondForce>
@@ -67918,17 +67892,34 @@ for force in sys.getForces():
6791867892
force.setExceptionParameters(i, p1, p2, atom_charges[p1]*atom_charges[p2], (atom_sigmas[p1]+atom_sigmas[p2])/2, unit.sqrt(atom_epsilons[p1]*atom_epsilons[p2]))
6791967893
</Script>
6792067894
<InitializationScript>
67895+
from openmm.app.internal import compiled
67896+
6792167897
class GlycamTemplateMatcher(object):
67898+
6792267899
def __init__(self, glycam_residues):
6792367900
self.glycam_residues = glycam_residues
67924-
def __call__(self, ff, residue):
67901+
67902+
def __call__(self, ff, residue, bondedToAtom, ignoreExternalBonds, ignoreExtraParticles):
6792567903
if residue.name in self.glycam_residues:
67926-
return ff._templates[residue.name]
67904+
template = ff._templates[residue.name]
67905+
if compiled.matchResidueToTemplate(residue, template, bondedToAtom, ignoreExternalBonds, ignoreExtraParticles) is not None:
67906+
return template
67907+
67908+
# The residue doesn't actually match the template with the same name. Try the terminal variants.
67909+
67910+
if 'N'+residue.name in self.glycam_residues:
67911+
template = ff._templates['N'+residue.name]
67912+
if compiled.matchResidueToTemplate(residue, template, bondedToAtom, ignoreExternalBonds, ignoreExtraParticles) is not None:
67913+
return template
67914+
if 'C'+residue.name in self.glycam_residues:
67915+
template = ff._templates['C'+residue.name]
67916+
if compiled.matchResidueToTemplate(residue, template, bondedToAtom, ignoreExternalBonds, ignoreExtraParticles) is not None:
67917+
return template
6792767918
return None
6792867919

6792967920
glycam_residues = set()
6793067921
for residue in tree.getroot().find('Residues').findall('Residue'):
6793167922
glycam_residues.add(residue.get('name'))
6793267923
self.registerTemplateMatcher(GlycamTemplateMatcher(glycam_residues))
6793367924

67934-
</InitializationScript></ForceField>
67925+
</InitializationScript></ForceField>

0 commit comments

Comments
 (0)