@@ -1064,6 +1064,14 @@ def _write_omm_nonbonded(self, xml_root, skip_types, separate_ljforce):
10641064 warnings .warn (f"Overwriting SCNB value { scnb [canonical_key ]} for { "-" .join (canonical_key )} with { dihedral_type .scnb } " , ParameterWarning )
10651065 scnb [canonical_key ] = dihedral_type .scnb
10661066
1067+ # We don't know what order the types will be in when checking, and some
1068+ # other script might change the type names, so instead of relying on
1069+ # sorting them for the lookup in the script, add reversed types here.
1070+ for key in tuple (scee ):
1071+ scee [key [::- 1 ]] = scee [key ]
1072+ for key in tuple (scnb ):
1073+ scnb [key [::- 1 ]] = scnb [key ]
1074+
10671075 # Write NonbondedForce records.
10681076 xml_force = etree .SubElement (xml_root , 'NonbondedForce' , coulomb14scale = str (1.0 / self .default_scee ), lj14scale = str (1.0 / self .default_scnb ))
10691077 etree .SubElement (xml_force , 'UseAttributeFromResidue' , name = "charge" )
@@ -1104,8 +1112,8 @@ def _write_omm_nonbonded(self, xml_root, skip_types, separate_ljforce):
11041112 if scee or scnb :
11051113 # Some 1-4 interactions use non-default scalings. Add a script to fix them.
11061114 script = etree .SubElement (xml_root , 'Script' )
1107- scee_table = "\n " .join (["{" ] + [f" { key !r} : { value !r} " for key , value in scee .items ()] + ["}" ])
1108- scnb_table = "\n " .join (["{" ] + [f" { key !r} : { value !r} " for key , value in scnb .items ()] + ["}" ])
1115+ scee_table = "\n " .join (["{" ] + [f" { key !r} : { value !r} , " for key , value in scee .items ()] + ["}" ])
1116+ scnb_table = "\n " .join (["{" ] + [f" { key !r} : { value !r} , " for key , value in scnb .items ()] + ["}" ])
11091117 script .text = f"""
11101118import openmm
11111119import openmm.unit
0 commit comments