Autodesk / notebook-molecular-visualization

2D and 3D molecular visualization in Jupyter notebooks using 3DMol.js and D3.js
http://moldesign.bionano.autodesk.com
Apache License 2.0
75 stars 21 forks source link

viewer.color_by is slow for large molecules #39

Open avirshup opened 7 years ago

avirshup commented 7 years ago

This actually looks cool, although it's probably not what we want :)

To reproduce: In a notebook, execute this cell:

mol = mdt.from_pdb('3aid')
drug = mol.chains['A'].get_ligand()
viewer = mol.draw(display=True)
viewer.stick()

Then this one:

viewer.color_by(lambda atom:atom.distance(drug))

In the latest version, the colors draw in 1-at-a-time, which takes a while: color_by_slow

In 0.7.3, the color comes in all-at-once after thinking for a second or two: color_by_fast

justinmc commented 7 years ago

Were you running the latest code that includes my performance PR https://github.com/Autodesk/notebook-molecular-visualization/pull/27 when you saw this? Just making sure.

avirshup commented 7 years ago

Yeah - it's all from the latest master (fb2eee08faca347444dc7bbf85de2d8792ccd6f2)

On Nov 2, 2016, at 5:16 PM, Justin McCandless notifications@github.com wrote:

Were you running the latest code that includes my performance PR #27 https://github.com/Autodesk/notebook-molecular-visualization/pull/27 when you saw this? Just making sure.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Autodesk/notebook-molecular-visualization/issues/39#issuecomment-258037963, or mute the thread https://github.com/notifications/unsubscribe-auth/AI8_5-8qjuV-eBlDKc9mMPIgiaQU2FyYks5q6SfPgaJpZM4Kn3Kx.

justinmc commented 7 years ago

Solution here: https://github.com/Autodesk/notebook-molecular-visualization/pull/42

It was syncing the data over the network 1 color at a time, which was very slow AND caused a rerender for reach color. Now we do it all at once. The frontend still has to call 3dmol's setStyle for each color, which is a lot, but it happens fast enough and with no pop-in.