[chimerax-users] python loop with ChimeraX

Rangarajan, Amith Amith.Rangarajan at ucsf.edu
Wed Jul 21 11:55:49 PDT 2021


Hi,

Thanks for this suggestion.

I updated my chimeraX to the latest(nightly) build and i wrote a cxc script to measure SASA of CYS,CSO,CSD,OCS residues . I added the commands into .cxc file and used tom's example ( open sasa.cxc foreach *.pdb)  to run it inside a folder with a set of 1000 pdb structures .  The SASA and defattr file is not getting updated for each pdb file.

A sample of the log is as shown below :
open 7BY4_mm1.pdb
select :CYS12 atoms, 10 bonds, 2 residues, 1 model selected
save CYS.defattr attrName r:area selectedOnly trueSaved attribute 'area' of 0 residues using match mode: 1-to-1 to CYS.defattr
select :CSO7 atoms, 6 bonds, 1 residue, 1 model selected
save CSO.defattr attrName r:area selectedOnly trueSaved attribute 'area' of 0 residues using match mode: 1-to-1 to CSO.defattr

I have attached the output to this email along with the cxc script.

I look  forward to hearing  your thoughts regarding fixing this.

Sincerely appreciate your thoughts and comments,

best,
Amith


________________________________
From: Tom Goddard <goddard at sonic.net>
Sent: Tuesday, July 20, 2021 6:24 PM
To: Rangarajan, Amith <Amith.Rangarajan at ucsf.edu>
Cc: ChimeraX Users Help <ChimeraX-users at cgl.ucsf.edu>
Subject: Re: [chimerax-users] python loop with ChimeraX

Hi Amith, It is also possible to run a ChimeraX command script (.cxc) file once on each PDB file in a directory. open myscript.cxc foreach ~/data/*.cif as described in the docs https://www.rbvi.ucsf.edu/chimerax/docs/user/commands/open.html#forEachFile ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
ZjQcmQRYFpfptBannerEnd
Hi Amith,

It is also possible to run a ChimeraX command script (.cxc) file once on each PDB file in a directory.

open myscript.cxc foreach ~/data/*.cif

as described in the docs

https://www.rbvi.ucsf.edu/chimerax/docs/user/commands/open.html#forEachFile

That was added after the ChimeraX 1.2 release so would need the ChimeraX daily build to use it.

Tom


On Jul 20, 2021, at 5:42 PM, Rangarajan, Amith via ChimeraX-users <chimerax-users at cgl.ucsf.edu<mailto:chimerax-users at cgl.ucsf.edu>> wrote:

Dear Elaine  & Eric

Thanks a lot !. i now have a better sense of how to approach this . I will update this thread soon with the results.


best
Amith
________________________________
From: Eric Pettersen <pett at cgl.ucsf.edu<mailto:pett at cgl.ucsf.edu>>
Sent: Tuesday, July 20, 2021 3:50 PM
To: ChimeraX Users Help <ChimeraX-users at cgl.ucsf.edu<mailto:ChimeraX-users at cgl.ucsf.edu>>
Cc: Rangarajan, Amith <Amith.Rangarajan at ucsf.edu<mailto:Amith.Rangarajan at ucsf.edu>>
Subject: Re: [chimerax-users] python loop with ChimeraX

This Message Is From an External Sender
This message came from outside your organization.
To supplement Elaine's answer, looping through a set of data files and applying commands to them is done in a fashion very similar to the way it is done in Chimera, and therefore the documentation for how to do it in Chimera is still pretty useful:  Very Basic Chimera Programming Primer<https://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/basicPrimer.html>

The differences are:

1) ChimeraX is Python 3 whereas Chimera is Python 2.  That doesn't actually make any difference to the code shown in the example except for the import statements, which would have to change anyway.

2) To run a command, instead of:

from chimera import runCommand
runCommand("color red")

it's:

from chimerax.core.commands import run
run(session, "color red")

3) To issue status messages, instead of:

from chimera import replyobj
replyobj.status("Processing file")

it's just:

session.logger.status("Processing file")

--Eric

Eric Pettersen
UCSF Computer Graphics Lab


On Jul 20, 2021, at 11:28 AM, Elaine Meng via ChimeraX-users <chimerax-users at cgl.ucsf.edu<mailto:chimerax-users at cgl.ucsf.edu>> wrote:

One correction, the saved attribute file should have "defattr" filename extension instead of "txt", so my examples should instead be:

save /location/myfile.defattr  attrName r:area
save /location/myfile.defattr attrName r:area selectedOnly true

Sorry about that.
Elaine

On Jul 20, 2021, at 11:23 AM, Elaine Meng via ChimeraX-users <chimerax-users at cgl.ucsf.edu<mailto:chimerax-users at cgl.ucsf.edu>> wrote:

Hi Amith,
Seems like two parts to this question:
(A) what are the ChimeraX commands (which could be put into a .cxc file)?
(B) how to loop over multiple inputs?  ...alluded to by "python loop" in your subject line... .cxc files only contain ChimeraX commands, not python.

I don't know python, so somebody else would need to address part B, but I can give some hints on part A.  However, depending on the solution to part B, you might instead choose to just make a python script instead of using ChimeraX commands directly.  The usual procedure is to figure out the commands first, often with some trial and error of simply typing them in to the command line.

Relevant ChimeraX commands are "measure sasa" to assign residue SASA values as an attribute and then "save" to write the file of attribute values.

<https://rbvi.ucsf.edu/chimerax/docs/user/commands/measure.html#sasa>
<https://rbvi.ucsf.edu/chimerax/docs/user/commands/save.html#attributes>

I'm guessing you want the SASA of the residues but in the context of the complex, i.e. if they are completely buried in the interface between two proteins even though they would be on the surface of one protein by itself, you would still expect SASA zero.  In that case, you'd want the surface to enclose all the proteins in one blob, and then get the SASA of individual residues, and the command would be something like

measure sasa protein setAttribute true
save /location/myfile.txt  attrName r:area

However, if you only want to specify certain residues instead of writing a file for all residues, you would need to use "select" command to select them and then save with the selectedOnly option, e.g. something like

select /A:24-53 /B:258
save /location/myfile.txt  attrName r:area selectedOnly true

For part B you may need to embed these in some python script where it keeps closing the previous structure, opening a new structure, and substituting a different name for each save file.

I hope this helps,
Elaine
-----
Elaine C. Meng, Ph.D.
UCSF Chimera(X) team
Department of Pharmaceutical Chemistry
University of California, San Francisco

On Jul 20, 2021, at 10:12 AM, Rangarajan, Amith via ChimeraX-users <chimerax-users at cgl.ucsf.edu<mailto:chimerax-users at cgl.ucsf.edu>> wrote:

Hi,
I am new to chimeraX , i want to loop through a set of biological assemblies  measuring SASA of  selecting residues and write them to a file. I need some help with starting on this .How to include this into the .cxc script? is there a example somewhere?
please share your tips and suggestions,
thanks everyone !
warm regards,
Amith


_______________________________________________
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


_______________________________________________
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

_______________________________________________
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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimerax-users/attachments/20210721/b579d66e/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CSD.defattr
Type: application/octet-stream
Size: 58 bytes
Desc: CSD.defattr
URL: <http://plato.cgl.ucsf.edu/pipermail/chimerax-users/attachments/20210721/b579d66e/attachment-0005.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CSO.defattr
Type: application/octet-stream
Size: 170 bytes
Desc: CSO.defattr
URL: <http://plato.cgl.ucsf.edu/pipermail/chimerax-users/attachments/20210721/b579d66e/attachment-0006.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CYS.defattr
Type: application/octet-stream
Size: 636 bytes
Desc: CYS.defattr
URL: <http://plato.cgl.ucsf.edu/pipermail/chimerax-users/attachments/20210721/b579d66e/attachment-0007.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OCS.defattr
Type: application/octet-stream
Size: 58 bytes
Desc: OCS.defattr
URL: <http://plato.cgl.ucsf.edu/pipermail/chimerax-users/attachments/20210721/b579d66e/attachment-0008.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sasa.cxc
Type: application/octet-stream
Size: 295 bytes
Desc: sasa.cxc
URL: <http://plato.cgl.ucsf.edu/pipermail/chimerax-users/attachments/20210721/b579d66e/attachment-0009.obj>


More information about the ChimeraX-users mailing list