mojaie / MolecularGraph.jl

Graph-based molecule modeling toolkit for cheminformatics
MIT License
189 stars 27 forks source link

Update and expand 3D display functions? #88

Closed tmcgrath325 closed 1 year ago

tmcgrath325 commented 1 year ago

Related: #74, #46

Since AbstractPlotting.jl is no longer supported, it seems like a good idea to update the 3D display to require Makie.jl instead. It also might be nice to be able to have some additional plotting options, like the stick and wire-frame displays here.

I've started to implement these while keeping the existing interface mostly intact:

julia> using GLMakie, MolecularGraph

julia> mol = sdftomol("assets/test/aspirin_3d.sdf")

julia> ballstick(mol)

ballstick

I also wanted to add the option for a "stick" display...

julia> stick(mol)

stick

...as well as a way to easily plot multiple molecules in a single figure:

julia> tforms = [x -> [x[1] + (i-1)*10, x[2], x[3]] for i=1:4];

julia> fig = stick(mol; tform=tforms[1])

julia> ax = fig.content[1];

julia> ballstick!(ax, mol; tform=tforms[2]);

julia> spacefilling!(ax, mol; tform=tforms[3]);

julia> wire!(ax, mol; tform=tforms[4]);

draw3d

Would you be interested in making these kinds of changes to the 3D display implementation? If so, I can put together a pull request with the work I've done so far.

mojaie commented 1 year ago

Thank you for the great idea! I'm already working on Makie interface (see new_graph and 'dev' branch) Could you wait for the branch is merged to main branch?

DoktorMike commented 1 year ago

As the dev branch is merged now, would it make sense to address this? I think this would indeed be a cool addition to this project. :)

tmcgrath325 commented 1 year ago

Since @mojaie indicated that contributions to 3D drawing are welcome in #89, I made a pull request with some additional features (see #90).

New additions include the "stick" and "wire" plots shown above. I've also tried to make it easy to combine multiple molecules or display types:

julia> using GLMakie, MolecularGraph

julia> mol = sdftomol("assets/test/aspirin_3d.sdf");

julia> f = wire(mol); spacefilling!(mol, alpha=0.2); f

combined

mojaie commented 1 year ago

Thank you very much, it looks great! I could reproduce with also WGLMakie スクリーンショット 2023-04-18 11 32 12