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

Add truncated octahedral solvation option for Modeller.addSolvent() #3124

Closed
jchodera opened this issue May 24, 2021 · 10 comments · Fixed by #3480
Closed

Add truncated octahedral solvation option for Modeller.addSolvent() #3124

jchodera opened this issue May 24, 2021 · 10 comments · Fixed by #3480
Milestone

Comments

@jchodera
Copy link
Member

It turns out that it's quite difficult to automate solvation within a truncated octahedron.

Could we add an option to Modeller.addSolvent() that would allow the user to select between standard box shapes?

cc : @glass-w, who can provide more information on use cases.

@peastman
Copy link
Member

In what way is it difficult? You just specify appropriate box vectors. Here's the code from OpenMM-Setup that does it.

https://github.com/openmm/openmm-setup/blob/931bddaf9fa185e44c79af2c638c22eed3cbe7d4/openmmsetup/openmmsetup.py#L249-L256

@jchodera
Copy link
Member Author

@glass-w can provide more information about the difficulties here, but I think the bigger picture question is that you're asking "why is it hard for a new user to just do

vectors = mm.Vec3(1,0,0), mm.Vec3(1/3,2*sqrt(2)/3,0), mm.Vec3(-1/3,sqrt(2)/3,sqrt(6)/3)                
boxVectors = [(maxSize+geompadding)*v for v in vectors]

?" then the point is already made. :)

If we can easily encapsulate these lines into Modeller.addSolvent() under the control of an optional box_geometry kwarg, we can make it easier for anyone to just specify a supported geometry and not have to worry about this.

Related to #3113, are there any assumptions in Modeller.addSolvent() that assume a particular box geometry? There are some lines that do not appear to be agnostic.

@peastman
Copy link
Member

I was thinking more along the lines of, "Why is it hard for a new user to just select the 'truncated octahedron' option in OpenMM-Setup."

@jchodera
Copy link
Member Author

Because we need to automate it, and OpenMM-Setup is intended to be used as a web app and not a user-accessible library like openmm.app.Modeller is intended.

@peastman peastman added this to the 7.7 milestone Aug 9, 2021
@zhang-ivy
Copy link
Contributor

zhang-ivy commented Aug 25, 2021

I've just tried solvating (with a truncated octahedron) my protein complex with the following code (mostly copied from https://github.com/openmm/openmm-setup/blob/931bddaf9fa185e44c79af2c638c22eed3cbe7d4/openmmsetup/openmmsetup.py#L249-L256):

# Create a modeller
modeller = app.Modeller(topology, positions)

# Solvate     
geompadding = 0.9 * unit.nanometers
maxSize = max(max((pos[i] for pos in positions))-min((pos[i] for pos in positions)) for i in range(3))
vectors = openmm.Vec3(1,0,0), openmm.Vec3(1/3,2*np.sqrt(2)/3,0), openmm.Vec3(-1/3,np.sqrt(2)/3,np.sqrt(6)/3)
boxVectors = [(maxSize+geompadding)*v for v in vectors]
modeller.addSolvent(self.system_generator.forcefield, model=water_model, boxVectors=boxVectors, ionicStrength=ionic_strength)

# Write to a PDB file
solvated_topology = modeller.getTopology()
solvated_positions = modeller.getPositions()
app.PDBFile.writeFile(solvated_topology, solvated_positions, open("trunc_oct_box_vecs_complex.pdb", "w"), keepIds=True)

And when I visualize my system in pymol, the solvent box looks rectangular:
Screen Shot 2021-08-25 at 11 47 44 AM

When I use supercell to visualize the unit cells, it looks like the unit cell isn't actually rectangular, but has rhombic nature:
Screen Shot 2021-08-25 at 11 47 17 AM

Is this the desired behavior? Or should the solvent box/unit cells actually look like a truncated octahedron?

@peastman
Copy link
Member

That's correct. See the last paragraph under http://docs.openmm.org/latest/userguide/theory.html#periodic-boundary-conditions.

@zhang-ivy
Copy link
Contributor

Got it, thanks!

@peastman peastman modified the milestones: 7.7, 7.8 Nov 5, 2021
@peastman
Copy link
Member

I'm looking into how to implement this. Here is how we currently implement the padding option:

3. You can give a padding distance. The largest dimension of the solute (along the x, y, or z axis) is determined, and a cubic
box of size (largest dimension)+2*padding is used.

An obvious implementation would be to add another option for box shape. We would build a box of the specified shape with the specified padding distance. However, the way we currently compute box size (largest dimension along x, y, or z) doesn't really make sense for a non-rectangular box. Would it be better to instead find the minimal bounding sphere containing all particles, then set the box width to (sphere diameter)+padding? This could produce boxes either larger or smaller than the current calculation. It would guarantee what you really want: no matter how the molecule rotates, it will never come closer than the specified padding to another copy. The current calculation doesn't guarantee that. And it makes sense for any box shape, not just rectangular ones.

@zhang-ivy
Copy link
Contributor

@peastman : Sounds good to me, tagging @jchodera to see what he thinks.

@jchodera
Copy link
Member Author

jchodera commented Feb 24, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants