Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Overhaul parameterization scheme used for small molecules #536

Closed
wants to merge 48 commits into from

Conversation

jchodera
Copy link
Member

@jchodera jchodera commented Apr 14, 2019

This PR (originally #517) changes the way that we parameterize small molecules with GAFF.

OEGAFFTemplateGenerator

Instead of using the flawed gaffTemplateGenerator, which was buggy in perceiving chemistry from the OpenMM Topology (which lacks chemical information)---and didn't even run in many cases on osx---I have implemented a new OEGAFFTemplateGenerator that accepts OEMol versions of molecules it should match within the Topology object in order to determine what chemical species they are.

The OEGAFFTemplateGenerator also supports the ability to specify a JSON cache file, allowing parameters for small molecules to be computed only once and then cached thereafter. This should also greatly speed up testing.

Examples:

Create a template generator for GAFF for a single OEMol and register it with ForceField:
    >>> from openmoltools.forcefield_generators import OEGAFFTemplateGenerator
    >>> template_generator = OEGAFFTemplateGenerator(oemols=oemol)
    >>> from simtk.openmm.app import ForceField
    >>> forcefield = ForceField('gaff.xml', 'amber14-all.xml', 'tip3p.xml')
    >>> forcefield.registerTemplateGenerator(template_generator.generator)
Create a template generator for GAFF2 for multiple OEMols:
    >>> template_generator = OEGAFFTemplateGenerator(oemols=[oemol1, oemol2], gaff_version='gaff2')
You can also some OEMols later on after the generator has been registered:
    >>> forcefield.add_oemols(oemol)
    >>> forcefield.add_oemols([oemol1, oemol2])
You can optionally create or use a tiny database cache of pre-parameterized molecules:
    >>> template_generator = OEGAFFTemplateGenerator(cache='gaff-molecules.json')
Newly parameterized molecules will be written to the cache, saving time next time!

SystemGenerator

The SystemGenerator has been moved to perses.forcefield. To use the OEGAFFTemplateGenerator, we simple specify some oemols and optionally a cache path to the JSON file that stores small molecule parameters. This will automatically configure an OEGAFFTemplateGenerator.

Here's an example:

    # Set up SystemGenerator for vacuum or explicit solvent
    gaff_filename = get_data_filename('gaff.xml')
    forcefield_ffxml_filenames = [gaff_filename, 'amber99sbildn.xml', 'tip3p.xml']
    nonbonded_method = app.PME if solvent else app.NoCutoff
    barostat = openmm.MonteCarloBarostat(1.0*unit.atmosphere, temperature, 50) if (use_barostat and solvent) else None
    cache = get_data_filename('OEGAFFTemplateGenerator-cache.json')
    default_forcefield_kwargs = {'removeCMMotion': False, 'nonbondedMethod': app.NoCutoff, 'constraints' : app.HBonds}
    forcefield_kwargs = default_forcefield_kwargs.update(forcefield_kwargs) if (forcefield_kwargs is not None) else default_forcefield_kwargs
    system_generator_kwargs = system_generator_kwargs if (system_generator_kwargs is not None) else dict()
    system_generator = SystemGenerator(forcefield_ffxml_filenames,
        forcefield_kwargs={'removeCMMotion': False, 'nonbondedMethod': nonbonded_method},
        barostat=barostat,
        oemols=[old_oemol, new_oemol],
        cache=cache, **system_generator_kwargs)

Status

I'm still working on remediating code and examples that had previously used the gaffTemplateGenerator.

  • Add tests for SystemGenerator
  • Update perses/tests/testsystems.py
  • Update perses/tests/test_RJMC_vacuum.py
  • Update perses/tests/test_hybrid_builder.py
  • Update perses/tests/test_elimination.py
  • Fix issues in perses/dispersed/feptasks.py related to managing nonequilibrium integrators attached to contexts and those not attached to contexts

jchodera and others added 30 commits March 13, 2019 21:05
…tests; WARNING: May be bugs due to complex merge
@jchodera
Copy link
Member Author

jchodera commented May 1, 2019

I should be able to finish this up quickly now!

@jchodera jchodera mentioned this pull request May 4, 2019
@jchodera jchodera requested review from dominicrufa and hannahbrucemacdonald and removed request for dominicrufa June 6, 2019 12:53
@jchodera
Copy link
Member Author

jchodera commented Jun 6, 2019

@hannahbrucemacdonald @dominicrufa : Would be great to get your reviews / comments on this, since I think I've resurrected all the tests I can easily resurrect at this point.

Be sure to check out the change in information flow where OEMols are now passed around instead of constructing them from OpenMM Topology objects (which was highly unreliable).

@jchodera
Copy link
Member Author

Supplanted by #616 and #620

@jchodera jchodera closed this Jan 15, 2020
@hannahbrucemacdonald hannahbrucemacdonald deleted the oegaff-template-generator branch February 19, 2020 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant