michellab / Sire

Sire Molecular Simulations Framework
http://siremol.org
GNU General Public License v3.0
94 stars 26 forks source link

Plan for old Amber prm parser? #240

Open jmichel80 opened 5 years ago

jmichel80 commented 5 years ago

The 'old' SireIO:Amber() object that implements readCrdTop() is still needed because the new parser doesn't create a SIreMol::AmberParameters object for each loaded molecule. This object is needed for initialising an OpenMM system in SOMD.

What should we do longer term?

  1. Maintain both parsers
  2. Add functionality to create an AmberParameters object for each molecule loaded with the new parser in OpenMMMD.py
  3. Modify SireMove:OpenMMFrENergySt and SireMove::OpenMMMDIntegrator to initialise by loading the required parameters from other Sire objects.
chryswoods commented 5 years ago

SOMD should be ported to use the SireMM::AmberParams object. This can be initialised from any molecule, even those loaded from other parsers, and provides interfaces to extract all of the amber parameters for the molecule in a native amber format. For example;

from Sire.IO import MoleculeParser
from Sire.MM import AmberParams
from Sire.Mol import MolIdx, BondID, AtomIdx

s = MoleculeParser.read("ANY INPUT FILES")

mol = s[MolIdx(0)]

params = AmberParams(mol)

bond = params.getParameter(BondID(AtomIdx(0),AtomIdx(1)))

# bond is a AmberBond object
k = bond.k()
r0 = bond.r0()

AmberParams comes with AmberBond, AmberAngle, AmberDihPart, AmberDihedral, AmberNB and AmberNB14, which convert from generic parameters (e.g. algebraic dihedral expressions) into the Amber parameter values (e.g. each dihedral/improper term accessed as AmberDihPart via the collection in AmberDihedral). It gives exactly the same information as the SireMol::AmberParameters::getParams, but with a much cleaner interface, python wrapping, and ability to use the independent parts, e.g.

from Sire.MM import AmberDihedral
from Sire.CAS import Expression, Symbol

dihedral_expression = "SOME ALGEBRAIC EXPRESSION"
phi = Symbol("phi")
amber_dihedral = AmberDihedral(dihedral_expression, phi)
for term in amber_dihedral.terms():
    print(term.k(), term.periodicity(), term.phase())

If you do this, then we can drop the SireMol::AmberParameters object (it would be kept for historical reasons, but moved into SireMol::deprecated::AmberParameters in case we load any S3 files that need this object).

This is the best approach as it will allow somd to work with all of the current (and future) parsers without us having to maintain two code branches.