<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Dear Elaine,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
This solution worked well and it is writing out values into defattr files. I have attached the working script for reference.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
thanks a lot for your support,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
warm regards,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Amith</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Elaine Meng <meng@cgl.ucsf.edu><br>
<b>Sent:</b> Wednesday, July 21, 2021 12:24 PM<br>
<b>To:</b> Rangarajan, Amith <Amith.Rangarajan@ucsf.edu><br>
<b>Cc:</b> ChimeraX-users@cgl.ucsf.edu <ChimeraX-users@cgl.ucsf.edu><br>
<b>Subject:</b> Re: [chimerax-users] python loop with ChimeraX</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Hi Amith,<br>
The logical error in your workflow is that if you always save the defattr files with the same name, then you will only have results for one structure, probably the last one that was opened.<br>
<br>
If you want to save all the results for all of the structures, you have to use "$file" to substitute in the name of the structure file into the names of the output defattr files, so that they will all have unique names. This is described in the help for the
"foreach" option:<br>
<<a href="https://rbvi.ucsf.edu/chimerax/docs/user/commands/open.html#forEachFile">https://rbvi.ucsf.edu/chimerax/docs/user/commands/open.html#forEachFile</a>><br>
<br>
e.g. in your sasa.cxc instead of this<br>
<br>
save CYS.defattr attrName r:area selectedOnly true<br>
<br>
...could be something like this<br>
<br>
save $file-CYS.defattr attrName r:area selectedOnly true<br>
<br>
Then you will get separate files of results for each input structure.<br>
I hope this helps,<br>
Elaine<br>
<br>
<br>
> On Jul 21, 2021, at 11:55 AM, Rangarajan, Amith via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:<br>
> <br>
> Hi,<br>
> <br>
> Thanks for this suggestion. <br>
> <br>
> 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.<br>
> <br>
> A sample of the log is as shown below :<br>
> open 7BY4_mm1.pdb<br>
> select :CYS12 atoms, 10 bonds, 2 residues, 1 model selected<br>
> save CYS.defattr attrName r:area selectedOnly trueSaved attribute 'area' of 0 residuesusing match mode: 1-to-1 to CYS.defattr<br>
> select :CSO7 atoms, 6 bonds, 1 residue, 1 model selected<br>
> save CSO.defattr attrName r:area selectedOnly trueSaved attribute 'area' of 0 residues using match mode: 1-to-1 to CSO.defattr<br>
> <br>
> I have attached the output to this email along with the cxc script.<br>
> <br>
> I look forward to hearing your thoughts regarding fixing this.<br>
> <br>
> Sincerely appreciate your thoughts and comments,<br>
> <br>
> best,<br>
> Amith<br>
> <br>
> <br>
> From: Tom Goddard <goddard@sonic.net><br>
> Sent: Tuesday, July 20, 2021 6:24 PM<br>
> To: Rangarajan, Amith <Amith.Rangarajan@ucsf.edu><br>
> Cc: ChimeraX Users Help <ChimeraX-users@cgl.ucsf.edu><br>
> Subject: Re: [chimerax-users] python loop with ChimeraX<br>
> <br>
> This Message Is From an External Sender <br>
> This message came from outside your organization. <br>
> Hi Amith,<br>
> <br>
> It is also possible to run a ChimeraX command script (.cxc) file once on each PDB file in a directory.<br>
> <br>
> open myscript.cxc foreach ~/data/*.cif<br>
> <br>
> as described in the docs<br>
> <br>
> <a href="https://www.rbvi.ucsf.edu/chimerax/docs/user/commands/open.html#forEachFile">
https://www.rbvi.ucsf.edu/chimerax/docs/user/commands/open.html#forEachFile</a><br>
> <br>
> That was added after the ChimeraX 1.2 release so would need the ChimeraX daily build to use it.<br>
> <br>
> Tom<br>
> <br>
> <br>
>> On Jul 20, 2021, at 5:42 PM, Rangarajan, Amith via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:<br>
>> <br>
>> Dear Elaine & Eric<br>
>> <br>
>> Thanks a lot !. i now have a better sense of how to approach this . I will update this thread soon with the results.<br>
>> <br>
>> <br>
>> best<br>
>> Amith<br>
>> From: Eric Pettersen <pett@cgl.ucsf.edu><br>
>> Sent: Tuesday, July 20, 2021 3:50 PM<br>
>> To: ChimeraX Users Help <ChimeraX-users@cgl.ucsf.edu><br>
>> Cc: Rangarajan, Amith <Amith.Rangarajan@ucsf.edu><br>
>> Subject: Re: [chimerax-users] python loop with ChimeraX<br>
>> <br>
>> This Message Is From an External Sender <br>
>> This message came from outside your organization. <br>
>> 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<br>
>> <br>
>> The differences are:<br>
>> <br>
>> 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.<br>
>> <br>
>> 2) To run a command, instead of:<br>
>> <br>
>> from chimera import runCommand<br>
>> runCommand("color red")<br>
>> <br>
>> it's:<br>
>> <br>
>> from chimerax.core.commands import run<br>
>> run(session, "color red")<br>
>> <br>
>> 3) To issue status messages, instead of:<br>
>> <br>
>> from chimera import replyobj<br>
>> replyobj.status("Processing file")<br>
>> <br>
>> it's just:<br>
>> <br>
>> session.logger.status("Processing file")<br>
>> <br>
>> --Eric<br>
>> <br>
>> Eric Pettersen<br>
>> UCSF Computer Graphics Lab<br>
>> <br>
>> <br>
>>> On Jul 20, 2021, at 11:28 AM, Elaine Meng via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:<br>
>>> <br>
>>> One correction, the saved attribute file should have "defattr" filename extension instead of "txt", so my examples should instead be:<br>
>>> <br>
>>> save /location/myfile.defattr attrName r:area<br>
>>> save /location/myfile.defattr attrName r:area selectedOnly true<br>
>>> <br>
>>> Sorry about that.<br>
>>> Elaine<br>
>>> <br>
>>>> On Jul 20, 2021, at 11:23 AM, Elaine Meng via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:<br>
>>>> <br>
>>>> Hi Amith,<br>
>>>> Seems like two parts to this question:<br>
>>>> (A) what are the ChimeraX commands (which could be put into a .cxc file)?<br>
>>>> (B) how to loop over multiple inputs? ...alluded to by "python loop" in your subject line... .cxc files only contain ChimeraX commands, not python.<br>
>>>> <br>
>>>> 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.<br>
>>>> <br>
>>>> Relevant ChimeraX commands are "measure sasa" to assign residue SASA values as an attribute and then "save" to write the file of attribute values.
<br>
>>>> <br>
>>>> <<a href="https://rbvi.ucsf.edu/chimerax/docs/user/commands/measure.html#sasa">https://rbvi.ucsf.edu/chimerax/docs/user/commands/measure.html#sasa</a>><br>
>>>> <<a href="https://rbvi.ucsf.edu/chimerax/docs/user/commands/save.html#attributes">https://rbvi.ucsf.edu/chimerax/docs/user/commands/save.html#attributes</a>><br>
>>>> <br>
>>>> 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<br>
>>>> <br>
>>>> measure sasa protein setAttribute true<br>
>>>> save /location/myfile.txt attrName r:area<br>
>>>> <br>
>>>> 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<br>
>>>> <br>
>>>> select /A:24-53 /B:258<br>
>>>> save /location/myfile.txt attrName r:area selectedOnly true<br>
>>>> <br>
>>>> 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.<br>
>>>> <br>
>>>> I hope this helps,<br>
>>>> Elaine<br>
>>>> -----<br>
>>>> Elaine C. Meng, Ph.D. <br>
>>>> UCSF Chimera(X) team<br>
>>>> Department of Pharmaceutical Chemistry<br>
>>>> University of California, San Francisco<br>
>>>> <br>
>>>>> On Jul 20, 2021, at 10:12 AM, Rangarajan, Amith via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:<br>
>>>>> <br>
>>>>> Hi,<br>
>>>>> 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?<br>
>>>>> please share your tips and suggestions,<br>
>>>>> thanks everyone !<br>
>>>>> warm regards,<br>
>>>>> Amith<br>
>>>> <br>
<br>
</div>
</span></font></div>
</body>
</html>