michellab / bssccpbiosim2022

Material for the BioSimSpace workshop at the upcoming 2022 CCPBioSim Training Week
GNU General Public License v3.0
9 stars 3 forks source link

alchemical_introduction.ipynb: 2.3 visualising solvated merged molecules #9

Closed jmichel80 closed 2 years ago

jmichel80 commented 2 years ago

In section 2.3 of the intro notebook for learning purposes it would be good for delegates to visuliase the state of the system they assembled after solvation.

However visualising the solvated system with

solvated = BSS.Solvent.tip3p(molecule=merged, box=3*[40*BSS.Units.Length.angstrom])
BSS.Notebook.View(solvated).system()

doesn't show the merged molecule.

image

Earlier visualisations of solutes loaded from PDB do work (section 1.1. of notebook)

lohedges commented 2 years ago

The issue is that you are writing an intermediate PDB file for NGLView using inconsistent propertly names. The water molecules have things like coordinates, element, etc., whereas those in the merged molecules have property names with an additional suffix 0 or 1 to specify the end state, e.g. coordinates0. This means that the merged molecule isn't being written to file properly.

If you want to view the merged molecule, then you'll need to convert to one of the end states, e.g.:

lam0 = merged._toRegularMolecule()
lam1 = merged._toRegualrMolecule(is_lambda1=True)

You could then combine this with the solvent to view.

For the purposes of visualisation, I could modify the View class to do this internally. always convert to one of the end states (perhaps specified by an option) when a merged molecule is detected. Let me know if this would be useful. I've also realised that the View class doesn't let you specify a property map (unlike most other functionality) so you wouldn't be able to remap properties anyway. (Meaning you'd need to manually reconstruct the system before creating the view, as I suggest above.)

jmichel80 commented 2 years ago

I think it would be useful to hide these details from the users of BSS.Notebook . We could by default map merged molecules to lambda0 and use a keyword arg to control this setting. This would also help understand the visualisation of the mappings.

lohedges commented 2 years ago

No problem, I'll try to add this later today when I get a chance. In the old workshops we just used ._toRegularMolecule() to view the end states, but now have the nicer viewMapping functionality built in. I agree that it would be good to have general support for merged molecules in the viewer in case the user wants to visualise it as part of a larger system, e.g. with solvent.

annamherz commented 2 years ago

but now have the nicer viewMapping functionality built in.

yep this is really nice and we have it earlier in the notebook!

No problem, I'll try to add this later today when I get a chance.

Thank you! I'll adjust the notebook once the support is added for the viewer 😊

lohedges commented 2 years ago

Okay, I've added some functionality that reconstructs a chosen end state of a perturbable system behind the scenes. This allows you to view perturbable molecules, or systems containing them, directly, i.e. without first needing to extract the end state.

I've tested locally and it works for me (although in this case you can't really see anything without first hiding the solvent with not water in the selection box). Let me know if you find other issues.

Cheers.