michellab / BioSimSpace

Code and resources for the EPSRC BioSimSpace project.
https://biosimspace.org
GNU General Public License v3.0
77 stars 19 forks source link

BioSimSpace.IO.readMolecules failed to read amber prm7 and rst7 file #387

Closed Naf-Guo closed 2 years ago

Naf-Guo commented 2 years ago

Dear all,

I'm trying to use biosimspace to perform MD, when I try to load an amber system:

system = BSS.IO.readMolecules(["system.prm7","system.rst7"])

It returns: OSError: Failed to read molecules from ['system.prm7', 'system.rst7']. It looks like you failed to include a topology file.

But the system can be read by openmm:

from openmm import from openmm.app import from openmm.unit import * prmtop = AmberPrmtopFile("system.prm7") inpcrd = AmberInpcrdFile("system.rst7")

Any idea how to deal with it?

system..zip

lohedges commented 2 years ago

Hi there,

Thanks for this. The issue is that the AMBER topology file contains CMAP records, which we don't currently support. Apologies that the message isn't a little more informative. We currently only provided high-level error messages by default, since the low-level messages from Sire, on which BioSImSpace is built, are often quite cryptic to the end user. We are working on an improved way to expose these.

If you are using Sire/BioSImSpace < 2023.0, you can get full error messages as follows:

import BioSImSpace as BSS
BSS.setVerbose(True)
system = BSS.IO.readMolecules(["system.prm7","system.rst7"])

For BioSimSpace 2023.0.0, this doesn't work in quite the same way since Sire has changed its error handling. To get the same error, you'd need to try loading the topology directly with Sire.

from sire.legacy import IO
amber_prm = AmberPrm("system.prm7")

Both report the following:

...

UserWarning: SireIO::parse_error: Could not extract the format from the line '%COMMENT  Ala CMAP                                                              '. Expected to read a line similar to '%FORMAT(5E16.8)'. 

CMAP records are in our roadmap of features for the next year. While it is easy enough to add read/write support for a given format, we need to do some work dealing with interoperability and making sure that the terms are preserved during molecular editing, or applied correctly for certain simulation protocols.

For now, I'll try to give the user a more informative error message when this problem occurs.

lohedges commented 2 years ago

I've now parsed the error message and let the user know that CMAP records are currently unsupported. Thanks again for reporting.