schrodinger / pymol-open-source

Open-source foundation of the user-sponsored PyMOL molecular visualization system.
https://pymol.org/
Other
1.13k stars 271 forks source link

Electrostatic potentials at surface: what does ramp_new do exactly? #265

Open eloyvallinaes opened 1 year ago

eloyvallinaes commented 1 year ago

I am working with APBS calculations on a set of interesting proteins. Briefly, what I want is an explicit representation of the potential at the protein's solvent accessible surface area—that is the actual numbers, not just the coloured surface. This entails:

  1. finding a PDB structure of a protein
  2. obtaining a triangulated mesh of the protein surface
  3. working out protonation states with pdb2pqr
  4. running the APBS calculation
  5. mapping the results on the grid to the triangulated mesh

This is in many ways equivalent to the first example in the pymol docs for ramp_new: https://pymolwiki.org/index.php/Ramp_New#Examples. It feels like that command pulls quite a lot of weight, so I am wondering: what is ramp_new doing exactly? My guess was that values from the APBS solution grid (.dx) were being mapped to the faces or the vertices of the surface by some simple nearest-neighbour type of search, with a k-d tree or some other sort of structure, but I am not getting the same results as pymol gets with ramp_new.

I suspect the reason why my trivial solution doesn't work is because ramp_new performs some sort of smoothing over multiple neighbours—how many neighbours? how are they smoothed?—or that pymol's surfaces are much more dense than the solution grid—how many vertices? Sadly, I don't think these details are documented anywhere.

Below is an example of the type of results I am seeing with a small protein: trimesh_avg_5n pymol_ramp

Left my solution. A noisy surface, with abrupt changes in potential. Right pymol's smoother, more reasonable, less complicated surface. Protein is chain I (trypsin inhibitor) in PDB structure 1TPA. In both images, the same .dx file containing the APBS electrostatic potential solution grid is being used.

Many thanks!

JarrettSJohnson commented 1 year ago

I commend you for giving that a go. But I honestly can't give you a solid or helpful answer for this as it'll be pure conjecture. I haven't delved too much into the code (because frankly it's a lot).

This is my best guess just from cursory view from where the coloring is done. There does seem to be a lot of interpolation and smoothing happening with close neighbors especially in the last file here, but I am not aware really what the broad algorithm is.

https://github.com/schrodinger/pymol-open-source/blob/master/layer2/RepSurface.cpp#L2171 https://github.com/schrodinger/pymol-open-source/blob/master/layer1/Color.cpp#L191 https://github.com/schrodinger/pymol-open-source/blob/master/layer2/ObjectGadgetRamp.cpp#L470