<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hello,<div class=""><br class=""></div><div class="">I am working on a Python project that uses ChimeraX (currently running 1.5 to interactively view dynamics data by mapping it onto a molecule. All the figures/movies in this paper, <a href="https://www.nature.com/articles/s41467-021-27417-y" class="">https://www.nature.com/articles/s41467-021-27417-y</a>, were made possible by Chimera! Also thanks to Tom Goddard for explaining to me how some of those figures could be made awhile ago (<a href="https://rbvi.github.io/chimerax-recipes/spherical_harmonics/spherical_harmonics.html" class="">https://rbvi.github.io/chimerax-recipes/spherical_harmonics/spherical_harmonics.html</a> ). </div><div class=""><br class=""></div><div class="">So we’re controlling ChimeraX remotely; we launch a session and then can send commands from Python over to Chimera and edit images from within our python code (while still allowing us to interact via the ChimeraX interface). The basic way this works is as follows</div><div class=""><br class=""></div><div class="">launch chimeraX from our code, including a short python script</div><div class="">python script imports our libraries, launches “cmxr” (chimeraX remote)</div><div class="">cmxr uses multiprocessing.connection.Listener to listen for commands/data coming from Client in our python code</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>!!!The Listener runs in a thread (threading.Thread) so that we continue to be able to interact normally with ChimeraX (launching the Listener without using a thread freezes ChimeraX while waiting for commands, rendering it unusable)</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>Then, we just tell it to run some function(s) that we’ve imported into ChimeraX, and provide some data, atom ids, etc. over the Client/Listener connection</div><div class=""><br class=""></div><div class="">There are a few things that I can’t figure how to make work via this process. We’ve had a few long-standing workarounds, but I’ve always been a little disturbed that we can’t get this all to work from python alone. At the moment, when we launch ChimeraX, we also enable remote control via curl, and some commands are then sent that way (remotecontrol rest start port XXXX)</div><div class=""><br class=""></div><div class="">In particular, if I want to send commands that would normally be executed at ChimeraX’s command line, in principle I should be able to use chimerax.core.commands.run. If I execute “run” from a simple python script, everything works, but if I run it from within a thread (as required by our Listener setup), then ChimeraX freezes. So, we send these commands via curl on the remotecontrol instead.</div><div class=""><br class=""></div><div class="">Second, is there a right way to open models/surfaces from the ChimeraX python shell? At the moment, we also open pdbs via curl commands. For pdbs, maybe I just don’t know the right python command. However, I am re-implementing spherical harmonics referenced above. Once I have prepared the surface (“s”), if I add it to session.models, it crashes chimeraX if it is being added within the listener thread, and if there are no models already open. If another model is already open, then it works just fine, and if I load the same modules/execute the same commands from within the python shell provided in ChimeraX, it also works (regardless of other models being open). It seems like maybe ChimeraX isn’t able to fully initialize the session from within a thread. </div><div class=""><br class=""></div><div class="">I’ve grouped these problems together because I guess mainly they have to do with being unable to do some actions from within threads, and if there’s an explanation/workaround for dealing with that.</div><div class=""><br class=""></div><div class="">Thanks for your help!</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Albert</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div class="">
<meta charset="UTF-8" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div><span style="font-size: 11px;" class="">–––––––––––––––––––––––––––––––––––</span></div><div><span style="font-size: 11px;" class="">Albert Smith-Penzel, Ph.D.</span></div><div><span style="font-style: normal; font-size: 11px;" class="">DFG Project Leader</span></div><div><span style="font-style: normal; font-size: 11px;" class="">Institute for Medical Physics and Biophysics</span></div><div><span style="font-style: normal; font-size: 11px;" class="">Leipzig University</span></div><div><span style="font-style: normal; font-size: 11px;" class="">04107 Leipzig, Germany</span></div><div><span style="font-style: normal; font-size: 11px;" class="">E-mail: </span><a href="mailto:albert.smith-penzel@medizin.uni-leipzig.de" class="">albert.smith-penzel@uni-leipzig.de</a></div><div class=""><br class=""></div></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>
<br class=""></div></body></html>