Comments (5)
(I've renamed the issue as the root cause is the major bug)
from sire.
I'm happy this is now fixed in feature_restraint
. I'll associate this issue with the PR for that branch when I make it, so that this issue will get closed automatically.
from sire.
I noticed that the same logic is used in the regular dynamics code, so perhaps we won't catch exceptions there either? I see there is special handling to check the kinetic energy when check-pointing at the end of a block, but I wonder what happens if something else goes wrong, or if there is an error on startup due to some invalid configuration/settings?
from sire.
Regarding the actual exception that was thrown, this is helpful. The error message is somewhat dependent on the chosen platform. For example, if we chose to run using the CPU platform, then the exception is raised prior to the minimisation being run, i.e.:
In [1]: import BioSimSpace as BSS
In [2]: import sire as sr
In [3]: system = BSS.Stream.load("Methane_Ethane_solv.bss")
In [4]: mols = sr.system.System(system._sire_object)
In [5]: m = mols.minimisation(lambda_value=0.4, map={"platform":"cpu"})
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/lester/.conda/envs/openbiosim/lib/python3.10/site-packages/sire/legacy/Convert/__init__.py │
│ :330 in sire_to_openmm │
│ │
│ 327 │ │ try: │
│ 328 │ │ │ from ._sommcontext import SOMMContext │
│ 329 │ │ │ │
│ ❱ 330 │ │ │ context = SOMMContext( │
│ 331 │ │ │ │ system=system, │
│ 332 │ │ │ │ integrator=integrator, │
│ 333 │ │ │ │ platform=platform, │
│ │
│ /home/lester/.conda/envs/openbiosim/lib/python3.10/site-packages/sire/legacy/Convert/_sommcontex │
│ t.py:53 in __init__ │
│ │
│ 50 │ │ │ # the system based on the requested value of lambda │
│ 51 │ │ │ # There are some things that are unchangeable once │
│ 52 │ │ │ # the context has been created (e.g. constraints) │
│ ❱ 53 │ │ │ super().__init__(system, integrator, platform) │
│ 54 │ │ │ │
│ 55 │ │ │ # place the coordinates and velocities into the context │
│ 56 │ │ │ _set_openmm_coordinates_and_velocities(self, metadata) │
│ │
│ /home/lester/.conda/envs/openbiosim/lib/python3.10/site-packages/openmm/openmm.py:3749 in │
│ __init__ │
│ │
│ 3746 │ │ properties : map< std::string, std::string > │
│ 3747 │ │ │ a set of values for platform-specific properties. Keys are the property name │
│ 3748 │ │ """ │
│ ❱ 3749 │ │ _openmm.Context_swiginit(self, _openmm.new_Context(*args)) │
│ 3750 │ │ │
│ 3751 │ │ self._system = args[0] │
│ 3752 │ │ self._integrator = args[1] │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
OpenMMException: All Forces must have identical exclusions
During handling of the above exception, another exception occurred:
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in <module>:1 │
│ │
│ /home/lester/.conda/envs/openbiosim/lib/python3.10/site-packages/sire/system/_system.py:433 in │
│ minimisation │
│ │
│ 430 │ │ """ │
│ 431 │ │ from ..mol import _minimisation │
│ 432 │ │ │
│ ❱ 433 │ │ return _minimisation(self, *args, **kwargs) │
│ 434 │ │
│ 435 │ def dynamics(self, *args, **kwargs): │
│ 436 │ │ """ │
│ │
│ /home/lester/.conda/envs/openbiosim/lib/python3.10/site-packages/sire/mol/__init__.py:1644 in │
│ _minimisation │
│ │
│ 1641 │ if device is not None: │
│ 1642 │ │ map.set("device", str(device)) │
│ 1643 │ │
│ ❱ 1644 │ return Minimisation( │
│ 1645 │ │ view, │
│ 1646 │ │ cutoff=cutoff, │
│ 1647 │ │ cutoff_type=cutoff_type, │
│ │
│ /home/lester/.conda/envs/openbiosim/lib/python3.10/site-packages/sire/mol/_minimisation.py:83 in │
│ __init__ │
│ │
│ 80 │ │ │
│ 81 │ │ map = create_map(map, extras) │
│ 82 │ │ │
│ ❱ 83 │ │ self._d = MinimisationData(mols=mols, map=map) │
│ 84 │ │
│ 85 │ def __str__(self): │
│ 86 │ │ return f"Minimisation()" │
│ │
│ /home/lester/.conda/envs/openbiosim/lib/python3.10/site-packages/sire/mol/_minimisation.py:15 in │
│ __init__ │
│ │
│ 12 │ """ │
│ 13 │ │
│ 14 │ def __init__(self, mols=None, map=None): │
│ ❱ 15 │ │ super().__init__(mols=mols, map=map) │
│ 16 │ │
│ 17 │ def run(self, max_iterations: int): │
│ 18 │ │ from openmm import LocalEnergyMinimizer │
│ │
│ /home/lester/.conda/envs/openbiosim/lib/python3.10/site-packages/sire/mol/_dynamics.py:81 in │
│ __init__ │
│ │
│ 78 │ │ │ │
│ 79 │ │ │ from ..convert import to │
│ 80 │ │ │ │
│ ❱ 81 │ │ │ self._omm_mols = to(self._sire_mols, "openmm", map=self._map) │
│ 82 │ │ │ self._omm_state = None │
│ 83 │ │ │ self._omm_state_has_cv = (False, False) │
│ 84 │
│ │
│ /home/lester/.conda/envs/openbiosim/lib/python3.10/site-packages/sire/convert/__init__.py:74 in │
│ to │
│ │
│ 71 │ elif format == "biosimspace": │
│ 72 │ │ return to_biosimspace(obj, map=map) │
│ 73 │ elif format == "openmm": │
│ ❱ 74 │ │ return to_openmm(obj, map=map) │
│ 75 │ else: │
│ 76 │ │ raise ValueError( │
│ 77 │ │ │ f"Cannot convert {obj} as the format '{format}' is " │
│ │
│ /home/lester/.conda/envs/openbiosim/lib/python3.10/site-packages/sire/convert/__init__.py:193 in │
│ to_openmm │
│ │
│ 190 │ Convert the passed object from its current object format to an │
│ 191 │ openmm object format. │
│ 192 │ """ │
│ ❱ 193 │ return sire_to_openmm(to_sire(obj, map=map), map=map) │
│ 194 │
│ 195 │
│ 196 def biosimspace_to_sire(obj, map=None): │
│ │
│ /home/lester/.conda/envs/openbiosim/lib/python3.10/site-packages/sire/convert/__init__.py:366 in │
│ sire_to_openmm │
│ │
│ 363 │ │
│ 364 │ from ..base import create_map │
│ 365 │ │
│ ❱ 366 │ mols = _sire_to_openmm(obj, map=create_map(map)) │
│ 367 │ │
│ 368 │ return mols │
│ 369 │
│ │
│ /home/lester/.conda/envs/openbiosim/lib/python3.10/site-packages/sire/legacy/Convert/__init__.py │
│ :338 in sire_to_openmm │
│ │
│ 335 │ │ │ │ map=map, │
│ 336 │ │ │ ) │
│ 337 │ │ except Exception as e: │
│ ❱ 338 │ │ │ raise ValueError( │
│ 339 │ │ │ │ "There was a problem creating the OpenMM context. Perhaps " │
│ 340 │ │ │ │ "the platform was not supported for this system, options " │
│ 341 │ │ │ │ f"or on this computer? The error message is: {e}" │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: There was a problem creating the OpenMM context. Perhaps the platform was not supported for this system, options or on this
computer? The error message is: All Forces must have identical exclusions
It's a bit annoying that the behaviour is different, since it would be good to catch this immediately, rather than when minimisation.run()
is called.
from sire.
Thanks - I've fixed the lost exception in this commit.
The exception was lost because I hadn't copied across the way that I capture the exception in _dynamics.py
. In this script, the exception is returned if something goes wrong, and the code checks for this, and then raises it if it is detected, e.g.
def runfunc(num_steps):
try:
integrator = self._omm_mols.getIntegrator()
integrator.step(num_steps)
return 0
except Exception as e:
return e
...
while not run_promise.done():
try:
result = run_promise.result(timeout=1.0)
except Exception:
pass
if result == 0:
completed += nrun
nrun_till_save -= nrun
progress.set_progress(completed)
run_promise = None
else:
# make sure we finish processing the last block
if process_promise is not None:
try:
process_promise.result()
except Exception:
pass
if completed == 0 and auto_fix_minimise:
raise NeedsMinimiseError()
# something went wrong - re-raise the exception
raise result
I've added this same logic to _minimisation.py
(well, GitHub Copilot did - I started typing it, and it saw what I was doing and copied in the rest!).
The underlying exception is, as you've found, due to the annoying undocumented requirement to match exclusions between NonbondedForce
and my two CustomNonbondedForce
objects. I thought I'd got them all, but something during the perturbation must be setting a parameter to zero. OpenMM eagerly converts interactions that involve zero parameters into exclusions, so I have lots of code that uses near-zero values for those, e.g.
I've reproduced the error locally and will debug this week which interactions are causing the issue. There are lots of ways that this can be fixed. I suspect I may go back to managing all of the exceptions/exclusions manually again, rather than relying on them being automatically set.
from sire.
Related Issues (20)
- Preserve PDB information when interconverting with RDKit
- Add support for reading Gromacs FEP topology files HOT 2
- [BUG] - Iron not recognised as a biological element
- Add square root, power etc to units HOT 2
- Not recognising amide bond? HOT 1
- [BUG] create_from_pertfile uses next instead of continue when skipping atoms that don't match the perturbation template HOT 2
- [BUG] Update cmake version as upcoming deprecation HOT 2
- Add "auto" constraints and then update tutorial HOT 1
- [BUG] sire.morph.create_from_pertfile doesn't assign different element properties to the end states
- [BUG] ForceFieldInfo sets incorrect cutoff from a TriclinicBox space HOT 8
- Add trajectory sorting function
- [BUG] mol.move().align() fails to align two proteins HOT 3
- GROMACS host requirement is breaking macOS CI HOT 4
- [BUG] GroTop parser fails when position restraint include directives are present HOT 2
- [BUG] AttributeError: 'EMLEEngine' object has no attribute 'get_forces' HOT 4
- [BUG] somd-freenrg.py fails with "Periodic box vectors must be in reduced form" HOT 5
- [BUG] make_whole center kwarg not exposed HOT 1
- [BUG] RDKit pin isn't strict enough
- [BUG] Inconsistent behaviour with reindexed molecules HOT 6
- [BUG] somd-freenrg is expanding the water box HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sire.