
Hi all, I'm wondering if anyone has any experience running ChimeraX with either a standard REPL or IPython REPL? ChimeraX already has a 'shell' tool that allows interacting with ChimeraX through a Python REPL which I've found invaluable for testing out ideas and poking around in ChimeraX in general. It would be really nice though if I could send Python code directly from my IDE to be evaluated. In order to make this work, it would be great if ChimeraX could be run from a terminal and provide a Python (or preferably IPython) REPL. As it stands, I've managed to nearly make this work with the following script: import IPython.terminal.embed IPython.terminal.embed.embed() I then run: ChimeraX --script repl.py After typing, `%gui qt5`, the ChimeraX GUI appears. I can then interact with the REPL directly from the comfort of Emacs and evaluate things - but! - the main 3D view does not end up being displayed. Does anyone know how to get the REPL and 3D stuff to work side-by-side? Kind regards, Tom

Hi Tom, Your shell runs its own event loop, which prevents ChimeraX's normal event loop from running, which will make using the interface directly unpredictable. For instance, the Model Panel never shows any models open. The redrawing of the 3D graphics depends on a QTimer event, which it never receives, so it never gets drawn. You can force it to draw however. You can either use the "wait" command (I recommend "wait 2", i.e. draw two frames, which might be necessary to get the Rapid Access interface to disappear and a redraw to happen), or directly in Python with session.update_loop.draw_new_frame(). Note that you can concatenate commands by separating them with semi-colon (;), so you could open 1gcn and get the redraw with "open 1gcn ; wait 2". --Eric Eric Pettersen UCSF Computer Graphics Lab
On Oct 21, 2021, at 4:00 AM, Tom Mulvaney via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Hi all,
I'm wondering if anyone has any experience running ChimeraX with either a standard REPL or IPython REPL?
ChimeraX already has a 'shell' tool that allows interacting with ChimeraX through a Python REPL which I've found invaluable for testing out ideas and poking around in ChimeraX in general.
It would be really nice though if I could send Python code directly from my IDE to be evaluated. In order to make this work, it would be great if ChimeraX could be run from a terminal and provide a Python (or preferably IPython) REPL. As it stands, I've managed to nearly make this work with the following script:
import IPython.terminal.embed IPython.terminal.embed.embed()
I then run:
ChimeraX --script repl.py
After typing, `%gui qt5`, the ChimeraX GUI appears.
I can then interact with the REPL directly from the comfort of Emacs and evaluate things - but! - the main 3D view does not end up being displayed.
Does anyone know how to get the REPL and 3D stuff to work side-by-side?
Kind regards,
Tom
_______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users

Hi Eric and Tom, Thanks for the pointers - I figured there was some kind of loop that needed to be kicked off. I have modified the script to call `session.update_loop.start_redraw_timer()` before firing up the IPython shell. I haven't noticed any unpredictability (yet) but I'm now able to directly evaluate Python code from Emacs and ChimeraX seems to behave like normal with 3D graphics! This should save me a lot of time! Thanks again, Tom From: "Eric Pettersen" <pett@cgl.ucsf.edu> To: "Tom Mulvaney" <thomas.mulvaney@cssb-hamburg.de> Cc: "ChimeraX Users Help" <chimerax-users@cgl.ucsf.edu> Sent: Thursday, 21 October, 2021 23:54:23 Subject: Re: [chimerax-users] Running ChimeraX and a REPL Hi Tom, Your shell runs its own event loop, which prevents ChimeraX's normal event loop from running, which will make using the interface directly unpredictable. For instance, the Model Panel never shows any models open. The redrawing of the 3D graphics depends on a QTimer event, which it never receives, so it never gets drawn. You can force it to draw however. You can either use the "wait" command (I recommend "wait 2", i.e. draw two frames, which might be necessary to get the Rapid Access interface to disappear and a redraw to happen), or directly in Python with session. update_loop.draw_new_frame(). Note that you can concatenate commands by separating them with semi-colon (;), so you could open 1gcn and get the redraw with "open 1gcn ; wait 2". --Eric Eric Pettersen UCSF Computer Graphics Lab On Oct 21, 2021, at 4:00 AM, Tom Mulvaney via ChimeraX-users < [ mailto:chimerax-users@cgl.ucsf.edu | chimerax-users@cgl.ucsf.edu ] > wrote: Hi all, I'm wondering if anyone has any experience running ChimeraX with either a standard REPL or IPython REPL? ChimeraX already has a 'shell' tool that allows interacting with ChimeraX through a Python REPL which I've found invaluable for testing out ideas and poking around in ChimeraX in general. It would be really nice though if I could send Python code directly from my IDE to be evaluated. In order to make this work, it would be great if ChimeraX could be run from a terminal and provide a Python (or preferably IPython) REPL. As it stands, I've managed to nearly make this work with the following script: import IPython.terminal.embed IPython.terminal.embed.embed() I then run: ChimeraX --script repl.py After typing, `%gui qt5`, the ChimeraX GUI appears. I can then interact with the REPL directly from the comfort of Emacs and evaluate things - but! - the main 3D view does not end up being displayed. Does anyone know how to get the REPL and 3D stuff to work side-by-side? Kind regards, Tom _______________________________________________ ChimeraX-users mailing list [ mailto:ChimeraX-users@cgl.ucsf.edu | ChimeraX-users@cgl.ucsf.edu ] Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users

Hi Tom, Chimera has a tool called ReadStdin which allows it to be run from a terminal and have commands typed into the terminal and output messages go to the terminal while the GUI shows the molecules or other data. https://www.cgl.ucsf.edu/chimera/docs/ContributedSoftware/readstdin/readstdi... But we have not added that tool to ChimeraX. It seems like this is what you want for ChimeraX. There is a ChimeraX "remotecontrol" command https://www.cgl.ucsf.edu/chimerax/docs/user/commands/remotecontrol.html that allows sending commands to ChimeraX using http for example, doing an http request via a browser or command-line program (wget / curl) http://127.0.0.1:60958/run?command=open+1a0m <http://127.0.0.1:60958/run?command=open+1a0m> would run the command "open 1a0m". Probably emacs is not going to support that mechanism. As Eric mentioned your problem with the IPython.terminal.embed.embed() is it seems to run its own event loop. If you type exit to that terminal all of sudden the ChimeraX gui displays and works because IPython exits its event loop and ChimeraX gets its going. In fact I suspect that the above embed() call simply does not return until IPython is exit, and ChimeraX only starts its event loop after the script completes. I don't know how to remedy this. Tom
On Oct 21, 2021, at 4:00 AM, Tom Mulvaney via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Hi all,
I'm wondering if anyone has any experience running ChimeraX with either a standard REPL or IPython REPL?
ChimeraX already has a 'shell' tool that allows interacting with ChimeraX through a Python REPL which I've found invaluable for testing out ideas and poking around in ChimeraX in general.
It would be really nice though if I could send Python code directly from my IDE to be evaluated. In order to make this work, it would be great if ChimeraX could be run from a terminal and provide a Python (or preferably IPython) REPL. As it stands, I've managed to nearly make this work with the following script:
import IPython.terminal.embed IPython.terminal.embed.embed()
I then run:
ChimeraX --script repl.py
After typing, `%gui qt5`, the ChimeraX GUI appears.
I can then interact with the REPL directly from the comfort of Emacs and evaluate things - but! - the main 3D view does not end up being displayed.
Does anyone know how to get the REPL and 3D stuff to work side-by-side?
Kind regards,
Tom
_______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
participants (3)
-
Eric Pettersen
-
Tom Goddard
-
Tom Mulvaney