OpenBioSim / sire

Sire Molecular Simulations Framework
https://sire.openbiosim.org
GNU General Public License v3.0
39 stars 11 forks source link

[BUG] GroTop parser fails when position restraint include directives are present #194

Closed lohedges closed 3 months ago

lohedges commented 4 months ago

The presence of include directives such as the following cause the parser to fail with no informative error.

#include "posre_0001.itp"

These files are written by BioSimSpace for when setting up a GROMACS system using position restraints. As such, the system can't be recovered from the topology and coordinate files without first removing these directives.

We could probably ignore this while parsing, but I'm not sure of the best approach. The itp extension is used for other includes too, so we can't just ignore that. BioSimSpace does always write using the same format, i.e. #include "posre_XXXX.itp``, so we could probably just matchposre` in the include?

I'll open a fix branch for this.

lohedges commented 4 months ago

Just adding example files. The following fails:

import sire
mols = sr.load("ABFE*")

OSError: SireError::io_error: Cannot load the molecules: There is not enough information in this parser (Gro87( title() = BioSimSpace_System,
nAtoms() = 26777, nResidues() = 8291, nFrames() = 1, hasCoordinates() = 1, hasVelocities() = 1 )) to start the creation of a new System. You
need to use a more detailed input file. (call sire.error.get_last_error_details() for more info)

get_last_error_details()
{'where': 'FILE: /home/lester/Code/openbiosim/sire/wrapper/IO/_IO_load.cpp, LINE: 204, FUNCTION: SireSystem::System load_molecules(const QStringList&, const SireBase::PropertyMap&)',
 'pid': '',
 'from': 'FILE: /home/lester/Code/openbiosim/sire/wrapper/IO/_IO_load.cpp, LINE: 204, FUNCTION: SireSystem::System load_molecules(const QStringList&, const SireBase::PropertyMap&)',
 'type': 'SireError::io_error',
 'why': 'Cannot load the molecules: There is not enough information in this parser (Gro87( title() = BioSimSpace_System, nAtoms() = 26777, nResidues() = 8291, nFrames() = 1, hasCoordinates() = 1, hasVelocities() = 1 )) to start the creation of a new System. You need to use a more detailed input file.',
 'backtrace': 'Backtrace disabled. Call sire.error.enable_backtrace_exceptions() to re-enable.'}
lohedges commented 4 months ago

It does give an informative error if you just read the topology file in isolation, i.e.:

This file could not be parsed by any of the file parsers! It was recognised as a file of type top,prm7, but all parsers failed to parse this
file. The errors from the parsers associated with the suffix top,prm7 are printed below:

*-- Failed to parse '/home/lester/Code/openbiosim/biosimspace/posre_bug/posre.top' with parser 'GROTOP'.
Cannot find the file 'posre_0001.itp' using GROMACS_PATH = [ /home/lester/.conda/envs/openbiosim/share/Sire/gromacs ], current directory
'/home/lester/Code/openbiosim/biosimspace/posre_bug'. Please make sure the file exists and is readable within your GROMACS_PATH from the
current directory '/home/lester/Code/openbiosim/biosimspace/posre_bug' (e.g. set the GROMACS_PATH environment variable to include the
directory that contains 'posre_0001.itp', or copy this file into one of the existing directories [
/home/lester/.conda/envs/openbiosim/share/Sire/gromacs ])

*-- Failed to parse '/home/lester/Code/openbiosim/biosimspace/posre_bug/posre.top' with parser 'PRM7'.
Cannot understand the required combining rules from ''. These should be either 'arithmetic' or 'geometric'.
 (call sire.error.get_last_error_details() for more info)