3dmol / 3Dmol.js

WebGL accelerated JavaScript molecular graphics library
https://3dmol.org/
Other
813 stars 195 forks source link

Drawing contacts/interactions between atoms #736

Closed JavierSanchez-Utges closed 1 year ago

JavierSanchez-Utges commented 1 year ago

I was wondering which would be the best way to represent contacts/interactions, e.g., between a protein and a ligand. Given a list of protein-ligand atom pairs, would the best way be using the viewer.addLine method: as you show in the documentation: viewer.addLine({dashed: true, start: {x:0, y:0, z:0}, end: {x:100, y:100, z:100}});. Using LineSpec, different types of interactions could be depicted. Are there any examples of this usage available? Thanks a lot!

dkoes commented 1 year ago

https://colab.research.google.com/drive/1bee2K0rtDauhqJD8U1YutSCXwAR7qq1d?usp=sharing

JavierSanchez-Utges commented 1 year ago

I see. Thanks, dashed cylinder is the way and can control the radius as well as dash and gap lengths. I realised as I have viewer.setViewStyle({'style': 'outline', 'color': 'black','width': 0.1}); to add outline to surface, and structure, that this outline also applies to the cylinder. Is there a way to avoid this? I mean to have the outline for the structure, but not for the cylinders, or even have a different cylinder outline width? Also, can the cylinders be filled? It seems by default they are hollow. How can I use the toCap and fromCap? I see the options are FLAT, ROUND, and NONE. I am guessing I pass those options as strings? Thanks!

dkoes commented 1 year ago

Outline will outline everything. You can pass the numerical values of the cap constants: 2 for round, 1 for flat.

JavierSanchez-Utges commented 1 year ago

OK. Thanks! What about filling the cylinders? It seems by default they are hollow.

dkoes commented 1 year ago

I'm not sure what you are asking. All rendered 3D objects are surface meshes of triangles (i.e., they are hollow). If you want caps that close off the ends of the cylinders, specify a 1 or 2 for the cap style.

JavierSanchez-Utges commented 1 year ago

Yes, apologies, I thought the caps were only present at the beginning and end of the first and last cylinder (start/end of the "line"), I see now that they apply to every cylinder, so that is what I wanted. Many thanks!