[chimerax-users] How to do repetitive task using Python or command line in ChimeraX?
Eric Pettersen
pett at cgl.ucsf.edu
Thu Apr 9 09:22:37 PDT 2020
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 at 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 at cgl.ucsf.edu on behalf of selcia20 at 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_chimerax_docs_devel_core_commands_user-5Fcommands.html&d=DwIGaQ&c=lb62iw4YL4RFalcE2hQUQealT9-RXrryqt9KZX2qu2s&r=JnYzuUa3E5p4u7qrfPzeZV8LIgMpwauz4WIvX7NJIi8&m=j7Tpmyo5XDVqMjqkGEuzR9uY2VhT76OIZl-yNu45ox0&s=kEjKLfMWQpeflIuqRONfyOB_NGRIqwqyxp73rpxs77c&e= )
>
> Best regards, Seowon
> ______________________________________________________________________________________
> 이 서 원 | Selcia Seowon Lee
> selcia20 at 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 at cgl.ucsf.edu
> Manage subscription:
> https://urldefense.proofpoint.com/v2/url?u=http-3A__plato.cgl.ucsf.edu_mailman_listinfo_chimerax-2Dusers&d=DwIGaQ&c=lb62iw4YL4RFalcE2hQUQealT9-RXrryqt9KZX2qu2s&r=JnYzuUa3E5p4u7qrfPzeZV8LIgMpwauz4WIvX7NJIi8&m=j7Tpmyo5XDVqMjqkGEuzR9uY2VhT76OIZl-yNu45ox0&s=C_8GYBsGzC9LRaFmXp0M3U5bvSGr7ngVpmMz7JnS9b8&e=
>
>
>
> _______________________________________________
> ChimeraX-users mailing list
> ChimeraX-users at cgl.ucsf.edu
> Manage subscription:
> http://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimerax-users/attachments/20200409/45507bb7/attachment-0001.html>
More information about the ChimeraX-users
mailing list