OpenFreeEnergy / openfe

The Open Free Energy toolkit
https://docs.openfree.energy
MIT License
124 stars 14 forks source link

Using OPC water models for RBFE calculations #869

Open palominohernandez opened 2 weeks ago

palominohernandez commented 2 weeks ago

Dear all,

I have been trying to use other water models such as OPC (a 4 point model).

I thought that intuitively it should be as simple as:

rbfe_settings = RelativeHybridTopologyProtocol.default_settings()

rbfe_settings.forcefield_settings.forcefields=["amber/RNA.OL3.xml","amber/opc_standard.xml"]
rbfe_settings.solvation_settings.solvent_model="opc"

However, I get an error that says:

File /data/sw/mamba/envs/openfe_env/lib/python3.12/site-packages/pydantic/v1/main.py:384, in BaseModel.__setattr__(self, name, value)
    [382](https://vscode-remote+ssh-002dremote-002blinux.vscode-resource.vscode-cdn.net/data/sw/mamba/envs/openfe_env/lib/python3.12/site-packages/pydantic/v1/main.py:382) value, error_ = known_field.validate(value, dict_without_original_value, loc=name, cls=self.__class__)
    [383](https://vscode-remote+ssh-002dremote-002blinux.vscode-resource.vscode-cdn.net/data/sw/mamba/envs/openfe_env/lib/python3.12/site-packages/pydantic/v1/main.py:383) if error_:
--> [384](https://vscode-remote+ssh-002dremote-002blinux.vscode-resource.vscode-cdn.net/data/sw/mamba/envs/openfe_env/lib/python3.12/site-packages/pydantic/v1/main.py:384)     raise ValidationError([error_], self.__class__)
    [385](https://vscode-remote+ssh-002dremote-002blinux.vscode-resource.vscode-cdn.net/data/sw/mamba/envs/openfe_env/lib/python3.12/site-packages/pydantic/v1/main.py:385) else:
    [386](https://vscode-remote+ssh-002dremote-002blinux.vscode-resource.vscode-cdn.net/data/sw/mamba/envs/openfe_env/lib/python3.12/site-packages/pydantic/v1/main.py:386)     new_values[name] = value

ValidationError: 1 validation error for OpenMMSolvationSettings
solvent_model
  unexpected value; permitted: 'tip3p', 'spce', 'tip4pew', 'tip5p' (type=value_error.const; given=opc; permitted=('tip3p', 'spce', 'tip4pew', 'tip5p'))

I tried to go deep in the gufe rabbit hole yet it was a bit unclear.

I thought I could just set up another 4 point model such as tip4pew and run the system with it, as the opc parameters should override the tip4pew setup. Doing this, I could write the transformations to disk. However, when running the json files with openfe quickrun, I got the following output:

Done with all simulations! Analyzing the results....
Here is the result:
        dG = None ± None

Error: The protocol unit 'LIG1 to LIG2 repeat 0 generation 0' failed with the error message:
ValueError: Residue template U with the same override level 0 already exists.

Details provided in output.

For reference, the same simulation runs properly when using the default force field parameters.

Thanks, O.

IAlibay commented 2 weeks ago

Thanks @palominohernandez - unfortunately I don't think we've ever tested out simulations with the opc models.

My initial thought here is that openmm.Modeller.addSolvent just doesn't support it properly yet (hence why you are getting a validation error when trying to set the solvent_model settings to 'opc'.

There is likely a way to fix this, but we'll need to triage exactly what is going wrong & how much work fixing it will take.

mikemhenry commented 5 hours ago

I believe that the issue is we only allow a subset of the solvation models that https://github.com/openmm/openmmforcefields supports. Looking at http://docs.openmm.org/latest/api-python/generated/openmm.app.modeller.Modeller.html#openmm.app.modeller.Modeller.addSolvent @IAlibay is correct that addSolvent only supports the models we allow in the settings:

model (str='tip3p') – the water model to use. Supported values are ‘tip3p’, ‘spce’, ‘tip4pew’, ‘tip5p’, and ‘swm4ndp’ (polarizable).

https://github.com/OpenFreeEnergy/openfe/blob/6aaf7e30eea4fd65255fc6660923b33c2156c6e3/openfe/protocols/openmm_utils/omm_settings.py#L46

There are other ways to solvate a system, but our current OpenMM protocols use Modeller.addSolvent AFAIK

palominohernandez commented 2 hours ago

Thanks! Do I get it from the comments that there is no easy fix at the moment, correct?