[chimerax-users] Executing a script in chimerax python shell for an interactive session
Zach Pearson
zjp at cgl.ucsf.edu
Tue May 24 09:17:12 PDT 2022
Hi Shubham,
I’d recommend converting your script to a ChimeraX command.
Put your script under a function, say “visualize_pairs(live_session, saved_session, pair_input, pairs)” and then, at the bottom of your script, include some boilerplate to register the command along the lines of this example:
https://rbvi.github.io/chimerax-recipes/copycolors/copycolors.html <https://rbvi.github.io/chimerax-recipes/copycolors/copycolors.html>
Then, when you launch ChimeraX you need only open your Python script to register the command.
Please look at the linked page and let me know if you have any questions for adapting your Python script into a ChimeraX command.
— Zach
> On May 22, 2022, at 22:51, Shubham Devesh Ramgoolam via ChimeraX-users <chimerax-users at cgl.ucsf.edu> wrote:
>
> Hi all,
> I hope you are doing well.
> I have a python script that allows the user to visualize specific residue pairs.
> Here is an overview of how the script functions:
> Ask the user to input the path of a .cxs file (created previously) and a text file containing the pairs to be visualized
> Print the names of the pairs along a uniquely assigned number
> Ask the user to input a number in order to visualize the pair assigned to it
>
> To run the script currently, I have to do the following: i)Open chimerax ii)Show the shell iii) Call the script from the shell
>
> Now, is it possible to include some codes in the script that would allow me to just open chimerax, click on File -> Open -> this script, and then the shell would show up and the execution would continue there?
>
> Right now, if I ran the script using File -> Open -> this script, I would get this error:
> Traceback (most recent call last):
> File "C:/Users/Shubham/Desktop/this_script.py", line 8, in
> session_path = input('Enter file (.cxs) to be visualized with path: \n')
> RuntimeError: input(): lost sys.stdin
>
> Regards,
> Shubham
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows
>
> _______________________________________________
> ChimeraX-users mailing list
> ChimeraX-users at cgl.ucsf.edu <mailto:ChimeraX-users at cgl.ucsf.edu>
> Manage subscription:
> https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users <https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.rbvi.ucsf.edu/pipermail/chimerax-users/attachments/20220524/c8a48a35/attachment.html>
More information about the ChimeraX-users
mailing list