diff --git a/openmmforcefields/generators/system_generators.py b/openmmforcefields/generators/system_generators.py index 54a2fcc..e8e0c78 100644 --- a/openmmforcefields/generators/system_generators.py +++ b/openmmforcefields/generators/system_generators.py @@ -247,6 +247,7 @@ def __init__( # Create and cache a residue template generator from openmmforcefields.generators.template_generators import ( SmallMoleculeTemplateGenerator, + GAFFNotSupportedError, ) self.template_generator = None @@ -260,10 +261,17 @@ def __init__( template_generator_kwargs=self.template_generator_kwargs, ) break - except (ValueError, NotImplementedError) as e: + except (ValueError, GAFFNotSupportedError) as e: _logger.debug(f" {template_generator_cls.__name__} cannot load {small_molecule_forcefield}") _logger.debug(e) if self.template_generator is None: + if small_molecule_forcefield.startswith("gaff"): + raise GAFFNotSupportedError( + "This release (0.13.x) of openmmforcefields temporarily drops GAFF support and " + "thereby the GAFFTemplateGenerator class. Support will be re-introduced in " + "future releases (0.14.x). To use this class, install version 0.12.0 or older." + ) + msg = ( "No registered small molecule template generators could load force field " f"'{small_molecule_forcefield}'\n" diff --git a/openmmforcefields/generators/template_generators.py b/openmmforcefields/generators/template_generators.py index ca552eb..e65b915 100644 --- a/openmmforcefields/generators/template_generators.py +++ b/openmmforcefields/generators/template_generators.py @@ -27,6 +27,10 @@ class ForceException(Exception): """Exception for forces""" +class GAFFNotSupportedError(Exception): + """Exception for missing GAFF support""" + + class SmallMoleculeTemplateGenerator: """ Abstract base class for small molecule template generation for OpenMM ForceField. @@ -503,7 +507,7 @@ def __init__(self, molecules=None, forcefield=None, cache=None, **kwargs): Newly parameterized molecules will be written to the cache, saving time next time! """ - raise NotImplementedError( + raise GAFFNotSupportedError( "This release (0.13.x) of openmmforcefields temporarily drops GAFF support and " "thereby the GAFFTemplateGenerator class. Support will be re-introduced in " "future releases (0.14.x). To use this class, install version 0.12.0 or older."