How to do repetitive task using Python or command line in ChimeraX?

Hello, I think I'm good at dealing with the previous Chimera command line, and I'm learning Python coding and ChimeraX little by little. In Chimera, I was able to apply the Chimera command to a Python script using runCommand. So, I wrote some python scripts for Chimera, such as automatically coloring or cropping maps and/or models based on the target specification list in plain text. However, I think there's no python modules like runCommand, and I don't know how to repetitively input specifications by .cxc files. (Do I have to make as many .cxc files as many as the number of the variables?) Also I tried to understand the ChimeraX developer tutorial, but I failed to import color functions on chimeraX Python Shell. (I didn't understand how to import experimental API) Is there any fancy way to create a .cxc file that executes by sequentially inputting variables in the list? Or, How to import python modules such as color functions? (https://www.cgl.ucsf.edu/chimerax/docs/devel/core/commands/user_commands.htm...) Best regards, Seowon ______________________________________________________________________________________ 이 서 원 | Selcia Seowon Lee selcia20@snu.ac.kr Laboratory of Molecular Imaging , Ph.D. Candidate Department of Biological Sciences, College of Natural Sciences Seoul National University, Gwanak-gu Gwanak-ro 1, Bldg105 Rm109, Seoul 08826, Korea

Hi Seowon, You can create a cxc file in a text editor and then execute it at the ChimeraX command line using the "open script-name.cxc" command. Just be sure to provide the full path to the script, or change your working directory. There are some nice example scripts on the ChimeraX page which can help migrate from Chimera to ChimeraX. https://www.cgl.ucsf.edu/chimerax/gallery.html I hope that answers your question. Best, Joel On 4/9/20, 1:26 AM, "ChimeraX-users on behalf of 이서원" <chimerax-users-bounces@cgl.ucsf.edu on behalf of selcia20@snu.ac.kr> wrote: Hello, I think I'm good at dealing with the previous Chimera command line, and I'm learning Python coding and ChimeraX little by little. In Chimera, I was able to apply the Chimera command to a Python script using runCommand. So, I wrote some python scripts for Chimera, such as automatically coloring or cropping maps and/or models based on the target specification list in plain text. However, I think there's no python modules like runCommand, and I don't know how to repetitively input specifications by .cxc files. (Do I have to make as many .cxc files as many as the number of the variables?) Also I tried to understand the ChimeraX developer tutorial, but I failed to import color functions on chimeraX Python Shell. (I didn't understand how to import experimental API) Is there any fancy way to create a .cxc file that executes by sequentially inputting variables in the list? Or, How to import python modules such as color functions? (https://urldefense.proofpoint.com/v2/url?u=https-3A__www.cgl.ucsf.edu_chimer... ) Best regards, Seowon ______________________________________________________________________________________ 이 서 원 | Selcia Seowon Lee selcia20@snu.ac.kr Laboratory of Molecular Imaging , Ph.D. Candidate Department of Biological Sciences, College of Natural Sciences Seoul National University, Gwanak-gu Gwanak-ro 1, Bldg105 Rm109, Seoul 08826, Korea _______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: https://urldefense.proofpoint.com/v2/url?u=http-3A__plato.cgl.ucsf.edu_mailm...

To supplement Joel’s answer, there is an exact analog of Chimera’s “runCommand” in ChimeraX, named “run”. To run the command “color red” from Python: from chimerax.core.commands import run run(session, “color red”) You could also import the corresponding Python function, but using it would be more work in many circumstances. Nonetheless, since you had trouble finding the correct import statement (which isn’t 100% obvious), it is: from chimerax.std_commands.color import color --Eric Eric Pettersen UCSF Computer Graphics Lab
On Apr 9, 2020, at 5:40 AM, Joel Meyerson <jrm2008@med.cornell.edu> wrote:
Hi Seowon, You can create a cxc file in a text editor and then execute it at the ChimeraX command line using the "open script-name.cxc" command. Just be sure to provide the full path to the script, or change your working directory. There are some nice example scripts on the ChimeraX page which can help migrate from Chimera to ChimeraX.
https://www.cgl.ucsf.edu/chimerax/gallery.html
I hope that answers your question. Best, Joel On 4/9/20, 1:26 AM, "ChimeraX-users on behalf of 이서원" <chimerax-users-bounces@cgl.ucsf.edu on behalf of selcia20@snu.ac.kr> wrote:
Hello,
I think I'm good at dealing with the previous Chimera command line, and I'm learning Python coding and ChimeraX little by little.
In Chimera, I was able to apply the Chimera command to a Python script using runCommand. So, I wrote some python scripts for Chimera, such as automatically coloring or cropping maps and/or models based on the target specification list in plain text.
However, I think there's no python modules like runCommand, and I don't know how to repetitively input specifications by .cxc files. (Do I have to make as many .cxc files as many as the number of the variables?) Also I tried to understand the ChimeraX developer tutorial, but I failed to import color functions on chimeraX Python Shell. (I didn't understand how to import experimental API)
Is there any fancy way to create a .cxc file that executes by sequentially inputting variables in the list? Or, How to import python modules such as color functions? (https://urldefense.proofpoint.com/v2/url?u=https-3A__www.cgl.ucsf.edu_chimer... )
Best regards, Seowon ______________________________________________________________________________________ 이 서 원 | Selcia Seowon Lee selcia20@snu.ac.kr Laboratory of Molecular Imaging , Ph.D. Candidate Department of Biological Sciences, College of Natural Sciences Seoul National University, Gwanak-gu Gwanak-ro 1, Bldg105 Rm109, Seoul 08826, Korea
_______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: https://urldefense.proofpoint.com/v2/url?u=http-3A__plato.cgl.ucsf.edu_mailm...
_______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: http://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users

Oh, I think I should try those. Thank you for all your assistance. I seriously appreciate it! ______________________________________________________________________________________ 이 서 원 | Selcia Seowon Lee selcia20@snu.ac.kr Laboratory of Molecular Imaging , Ph.D. Candidate Department of Biological Sciences, College of Natural Sciences Seoul National University, Gwanak-gu Gwanak-ro 1, Bldg105 Rm109, Seoul 08826, Korea 2020년 4월 10일 (금) 오전 1:22, Eric Pettersen <pett@cgl.ucsf.edu>님이 작성:
To supplement Joel’s answer, there is an exact analog of Chimera’s “runCommand” in ChimeraX, named “run”. To run the command “color red” from Python:
from chimerax.core.commands import run run(session, “color red”)
You could also import the corresponding Python function, but using it would be more work in many circumstances. Nonetheless, since you had trouble finding the correct import statement (which isn’t 100% obvious), it is:
from chimerax.std_commands.color import color
--Eric
Eric Pettersen UCSF Computer Graphics Lab
On Apr 9, 2020, at 5:40 AM, Joel Meyerson <jrm2008@med.cornell.edu> wrote:
Hi Seowon, You can create a cxc file in a text editor and then execute it at the ChimeraX command line using the "open script-name.cxc" command. Just be sure to provide the full path to the script, or change your working directory. There are some nice example scripts on the ChimeraX page which can help migrate from Chimera to ChimeraX.
https://www.cgl.ucsf.edu/chimerax/gallery.html
I hope that answers your question. Best, Joel On 4/9/20, 1:26 AM, "ChimeraX-users on behalf of 이서원" <chimerax-users-bounces@cgl.ucsf.edu on behalf of selcia20@snu.ac.kr> wrote:
Hello,
I think I'm good at dealing with the previous Chimera command line, and I'm learning Python coding and ChimeraX little by little.
In Chimera, I was able to apply the Chimera command to a Python script using runCommand. So, I wrote some python scripts for Chimera, such as automatically coloring or cropping maps and/or models based on the target specification list in plain text.
However, I think there's no python modules like runCommand, and I don't know how to repetitively input specifications by .cxc files. (Do I have to make as many .cxc files as many as the number of the variables?) Also I tried to understand the ChimeraX developer tutorial, but I failed to import color functions on chimeraX Python Shell. (I didn't understand how to import experimental API)
Is there any fancy way to create a .cxc file that executes by sequentially inputting variables in the list? Or, How to import python modules such as color functions? (https://urldefense.proofpoint.com/v2/url?u=https-3A__www.cgl.ucsf.edu_chimer... )
Best regards, Seowon ______________________________________________________________________________________ 이 서 원 | Selcia Seowon Lee selcia20@snu.ac.kr Laboratory of Molecular Imaging , Ph.D. Candidate Department of Biological Sciences, College of Natural Sciences Seoul National University, Gwanak-gu Gwanak-ro 1, Bldg105 Rm109, Seoul 08826, Korea
_______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: https://urldefense.proofpoint.com/v2/url?u=http-3A__plato.cgl.ucsf.edu_mailm...
_______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: http://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
participants (3)
-
Eric Pettersen
-
Joel Meyerson
-
이서원