Isra3l / ligpargen

MIT License
54 stars 20 forks source link

OpenMM Xml atom order Improper Dihedrals #15

Closed wutobias closed 1 month ago

wutobias commented 2 years ago

The order of the atoms in the Improper Dihedral definition of OpenMM xml files may be incorrect. AFAIK OpenMM force field xml input expects the central atom at position 1. Attached is a case that causes the problem.

Running

ligpargen -p test -i mol_0.mol -cgen CM1A -c 0

gets the following improper dihedral definition in the OpenMM xml file:

<Improper class1="C800" class2="C801" class3="N804" class4="O806" k1="0.000000" k2="43.932000" k3="0.000000" k4="0.000000" periodicity1="1" periodicity2="2" periodicity3="3" periodicity4="4" phase1="0.00" phase2="3.141592653589793" phase3="0.00" phase4="3.141592653589793"/>

However, the atom order should be

<Improper class1="C801" class2="C800" class3="N804" class4="O806" k1="0.000000" k2="43.932000" k3="0.000000" k4="0.000000" periodicity1="1" periodicity2="2" periodicity3="3" periodicity4="4" phase1="0.00" phase2="3.141592653589793" phase3="0.00" phase4="3.141592653589793" />

When parsing the force field to openmm, the four Improper dihedrals in the molecule cannot be found. It should have 35 Torsions in total. Check out:

import openmm
from openmm import app

forcefield = app.ForceField("test/mol_0.openmm.xml")
pdb        = app.PDBFile("mol_0.pdb")
system = forcefield.createSystem(pdb.topology)
tor_force = system.getForce(2)
print(
    "Number of torsions:",
    tor_force.getNumTorsions()
)

I think there is an easy fix, but I am not sure if it is going to break anything.

Attached file: mol_0.pdb mol_0.pdb.txt

Isra3l commented 1 month ago

Hey Tobias! I have fixed this issue. I apologize for the delay and appreciate your patience.