mojaie / MolecularGraph.jl

Graph-based molecule modeling toolkit for cheminformatics
MIT License
197 stars 29 forks source link

Any interest in 3d display? #46

Closed timholy closed 3 years ago

timholy commented 3 years ago

Using Makie it's possible to create 3d plots:

julia> calotte(mol; H=false,markersize=2)

image

(This would be improved by having a table of atomic radii.)

julia> ballstick(mol)

image

If you're interested I could make a pull request. There are really three options wrt implementation:

I suspect the latter two are the best options. If you're interested, which do you prefer? One concern about the Requires approach is that it's not currently compatible with precompilation, but putting it in a separate package would allow that. Makie itself is not very well precompilable now, so at present it wouldn't really make any difference, but hopefully Makie will get more precompilable over time.

CC @SimonDanisch

SimonDanisch commented 3 years ago

There are also other projects for plotting molecules, which already have a dependency on Makie: https://github.com/ffreyer/LatPhysPlottingMakie.jl https://github.com/kool7d/BioMakie.jl

You can also make a hard dependency on AbstractPlotting, which will allow the user to switch backends!

mojaie commented 3 years ago

Thank you very much! It looks really exciting. If the basic 3D display can be simply implemented by using Makie or AbstractPlotting, I prefer using @require. More specialized and larger codes unrelated to molecular graph model should be in separate packages. I would be happy if you could add the functionality.

timholy commented 3 years ago

OK, see #47. I added an atom radius table, picking the covalent radius rather than van der Waals radius in part because I could find nearly-comprehensive tables for covalent radii but not for VdW radii. That means that my spacefilling function is not really space-filling in the usual sense; compare https://en.wikipedia.org/wiki/File:Thc.pdb.gif with

image

I'm happy to make changes in the implementation, or to rename it to be something else.

timholy commented 3 years ago

@SimonDanisch, I tried setting strokecolor=nothing to see if I could prevent it from drawing the surface of each of the spheres in black, but that was not effective. Any ideas? It's not a big deal, and maybe I'd prefer it with the surfaces drawn, but I thought I'd at least see what it looks iike without.

SimonDanisch commented 3 years ago

I'd use meshscatter in this case ;) If you want them to look flat, you can set shading=false!

timholy commented 3 years ago

I like meshscatter. Interesting: meshscatter interprets markersize as a radius, but scatter interprets it as a diametersomething else. xref https://github.com/JuliaPlots/Makie.jl/issues/772

timholy commented 3 years ago

For comparison:

image