ngl icon indicating copy to clipboard operation
ngl copied to clipboard

Define a volume from residue list, and select all atoms inside volume

Open pguillem opened this issue 1 year ago • 3 comments

Hello everyone. Is there a way to use the NGL selection language to:

  1. Create a "volume" or a "3d mesh/cube" provided a residue list? (the volume should include all space in between them).
  2. Return every atom contained in such volume.

The idea is to fill the volume of a protein-protein interface with a different color, and to extract everything contained in such space.

Best Pedro

pguillem avatar Mar 02 '23 13:03 pguillem

You can create a StructureView from a structure and a selection, this has a bounding box (a Box3 instance). Box3 has a contains method that will test whether a 3D point is within it.

If you don't want an axes-aligned box it's more involved...

The other approach might be to find all atoms in the first protein within some distance of the second protein (and vice-versa). The SpatialHash (structure.spatialHash) allows you to do this efficiently and build selections for those two sets (which you can then colour differently).

fredludlow avatar Mar 02 '23 15:03 fredludlow

Excellent approach. I'm truly amazed at how powerful the library is. Thank you very much @fredludlow

Can these objects be instantiated from the python nglview API? (not to view them for now ... just to work with the structure/tjframes as a python objects instead of JS)

Best! Pedro

pguillem avatar Mar 02 '23 17:03 pguillem

Can these objects be instantiated from the python nglview API?

No I don't think so.

hainm avatar Mar 09 '23 16:03 hainm