choderalab / perses

Experiments with expanded ensembles to explore chemical space
http://perses.readthedocs.io
MIT License
179 stars 50 forks source link

Support for use of custom force fields (e.g., one generated from openff-bespokefit) #1231

Closed arjun-nufc closed 5 months ago

arjun-nufc commented 10 months ago

Hi, I used openff-bespokefit to get custom force field parameters for ligands to do RBFE with Perses. However when i supply the file for the custom .offxml file to Perses as the small molecule force field, I get errors from SystemGenerator of openmmforcefields saying "ValueError: No registered small molecule template generators could load force field 'bespokefit-out.offxml' " . @ijpulidos mentioned that Perses should be able to read it if it is local to the directory where perses is run. I tried that as well and am still getting the same errors. I do see an earlier error/Warning that says "openmmforcefields.generators.template_generators:SMIRNOFF offxml file was written with version 0.4, but this version of ForceField only supports version 0.3 to version 0.3" . FYI, i am using Perses 0.10.1, openmmforcefields 0.11.2, and openff-toolkit 0.10.6. Thanks in advance for any help! Below is a more full accounting of the error log:


2023-09-05 16:04:11,302:(0.00s):openmmforcefields.generators.template_generators:Using espaloma model found at bespokefit-out.offxml
2023-09-05 16:04:11,303:(0.65s):openmmforcefields.generators.template_generators:SMIRNOFF offxml file was written with version 0.4, but this version of ForceField only supports version 0.3 to version 0.3
2023-09-05 16:04:11,303:(0.00s):openmmforcefields.generators.template_generators:Using espaloma model found at bespokefit-out.offxml
Traceback (most recent call last):
  File "/cluster/home/narayaa2/.conda/envs/perses/bin/perses-relative", line 10, in <module>
Traceback (most recent call last):
  File "/cluster/home/narayaa2/.conda/envs/perses/bin/perses-relative", line 10, in <module>
    sys.exit(run())
    sys.exit(run())
  File "/cluster/home/narayaa2/.conda/envs/perses/lib/python3.10/site-packages/perses/app/setup_relative_calculation.py", line 812, in run
  File "/cluster/home/narayaa2/.conda/envs/perses/lib/python3.10/site-packages/perses/app/setup_relative_calculation.py", line 812, in run
    setup_dict = run_setup(setup_options)
  File "/cluster/home/narayaa2/.conda/envs/perses/lib/python3.10/site-packages/perses/app/setup_relative_calculation.py", line 515, in run_setup
    setup_dict = run_setup(setup_options)
  File "/cluster/home/narayaa2/.conda/envs/perses/lib/python3.10/site-packages/perses/app/setup_relative_calculation.py", line 515, in run_setup
    fe_setup = RelativeFEPSetup(ligand_file, old_ligand_index, new_ligand_index, forcefield_files,phases=phases,
  File "/cluster/home/narayaa2/.conda/envs/perses/lib/python3.10/site-packages/perses/app/relative_setup.py", line 353, in __init__
    fe_setup = RelativeFEPSetup(ligand_file, old_ligand_index, new_ligand_index, forcefield_files,phases=phases,
  File "/cluster/home/narayaa2/.conda/envs/perses/lib/python3.10/site-packages/perses/app/relative_setup.py", line 353, in __init__
    self._system_generator = SystemGenerator(forcefields=forcefield_files, barostat=barostat, forcefield_kwargs=forcefield_kwargs,
    self._system_generator = SystemGenerator(forcefields=forcefield_files, barostat=barostat, forcefield_kwargs=forcefield_kwargs,
  File "/cluster/home/narayaa2/.conda/envs/perses/lib/python3.10/site-packages/openmmforcefields/generators/system_generators.py", line 208, in __init__
  File "/cluster/home/narayaa2/.conda/envs/perses/lib/python3.10/site-packages/openmmforcefields/generators/system_generators.py", line 208, in __init__
    raise ValueError(msg)
    raise ValueError(msg)
ValueError: No registered small molecule template generators could load force field 'bespokefit-out.offxml'
Available installed force fields are:
  GAFFTemplateGenerator: ['gaff-1.4', 'gaff-1.8', 'gaff-1.81', 'gaff-2.1', 'gaff-2.11']
  SMIRNOFFTemplateGenerator: ['smirnoff99Frosst-1.0.0', 'smirnoff99Frosst-1.0.9', 'smirnoff99Frosst-1.0.4', 'smirnoff99Frosst-1.0.1', 'smirnoff99Frosst-1.0.2', 'smirnoff99Frosst-1.0.5', 'smirnoff99Frosst-1.0.7', 'smirnoff99Frosst-1.0.6', 'smirnoff99Frosst-1.0.3', 'smirnoff99Frosst-1.0.8', 'smirnoff99Frosst-1.1.0', 'openff-1.3.0', 'openff-1.2.0', 'openff-1.1.1', 'openff-2.0.0-rc.2', 'openff-1.1.0', 'openff-1.0.0-RC2', 'openff-1.0.0', 'openff-2.0.0', 'openff-1.2.1', 'openff-1.0.1', 'openff-1.0.0-RC1', 'openff-1.3.1-alpha.1', 'openff-2.0.0-rc.1', 'openff-1.3.1']
  EspalomaTemplateGenerator: ['espaloma-0.2.2']

ValueError: No registered small molecule template generators could load force field 'bespokefit-out.offxml'
Available installed force fields are:
  GAFFTemplateGenerator: ['gaff-1.4', 'gaff-1.8', 'gaff-1.81', 'gaff-2.1', 'gaff-2.11']
  SMIRNOFFTemplateGenerator: ['smirnoff99Frosst-1.0.0', 'smirnoff99Frosst-1.0.9', 'smirnoff99Frosst-1.0.4', 'smirnoff99Frosst-1.0.1', 'smirnoff99Frosst-1.0.2', 'smirnoff99Frosst-1.0.5', 'smirnoff99Frosst-1.0.7', 'smirnoff99Frosst-1.0.6', 'smirnoff99Frosst-1.0.3', 'smirnoff99Frosst-1.0.8', 'smirnoff99Frosst-1.1.0', 'openff-1.3.0', 'openff-1.2.0', 'openff-1.1.1', 'openff-2.0.0-rc.2', 'openff-1.1.0', 'openff-1.0.0-RC2', 'openff-1.0.0', 'openff-2.0.0', 'openff-1.2.1', 'openff-1.0.1', 'openff-1.0.0-RC1', 'openff-1.3.1-alpha.1', 'openff-2.0.0-rc.1', 'openff-1.3.1']
  EspalomaTemplateGenerator: ['espaloma-0.2.2']```
mikemhenry commented 10 months ago

Can you try updating perses to 0.10.2 and see if you run into the same error? We recently added support for this.

arjun-nufc commented 10 months ago

Thanks @mikemhenry, will do. i didn't see anything about it in the changelog for 0.10.2 but maybe i missed it. I'll give it a shot and report back!

ijpulidos commented 10 months ago

@arjun-nufc can you share the contents of your environment, that is, the output of conda list?. I have the feeling this is due to having an old version of the openff-toolkit, as per the warning message in the output you shared, specifically:

2023-09-05 16:04:11,303:(0.65s):openmmforcefields.generators.template_generators:SMIRNOFF offxml file was written with version 0.4, but this version of ForceField only supports version 0.3 to version 0.3

ijpulidos commented 10 months ago

@arjun-nufc Oh, just realized that you said you were using version 0.10.6 from the openff-toolkit in your original message. In that case, I'd advice to upgrade that one to the latest version (0.14.3) and try again.

arjun-nufc commented 5 months ago

Thanks @ijpulidos and @mikemhenry , as you guys suggested this all works now after using the updated openff-toolkit and perses >= 0.10.2. Thanks again!