<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);">
<span style="margin: 0px; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); scroll-behavior: auto !important;">Dear Elaine  & Eric</span>
<div style="margin: 0px; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); scroll-behavior: auto !important;">
<br style="scroll-behavior:auto !important">
</div>
<span style="margin: 0px; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); scroll-behavior: auto !important;">Thanks a lot !. i now have a better sense of how to approach this . I will update this thread soon with the results.</span><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);">
<span style="margin: 0px; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); scroll-behavior: auto !important;"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="margin: 0px; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); scroll-behavior: auto !important;"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
best</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> Eric Pettersen <pett@cgl.ucsf.edu><br>
<b>Sent:</b> Tuesday, July 20, 2021 3:50 PM<br>
<b>To:</b> ChimeraX Users Help <ChimeraX-users@cgl.ucsf.edu><br>
<b>Cc:</b> Rangarajan, Amith <Amith.Rangarajan@ucsf.edu><br>
<b>Subject:</b> Re: [chimerax-users] python loop with ChimeraX</font>
<div> </div>
</div>
<style>
<!--
.x_pfptBannerTableMSO
        {padding:0px 12px 5px 12px;
        width:100%;
        border-radius:4px;
        border-top:4px solid #90a4ae;
        background-color:#d0d8dc}
.x_pfptTitleMSO
        {color:#000000!important;
        font-family:'Arial',sans-serif!important;
        font-weight:bold!important;
        font-size:14px!important}
.x_pfptSubtitleMSO
        {font-size:12px!important;
        font-family:'Arial',sans-serif!important}
.x_pfptButtonMSO
        {padding:7.5px;
        text-decoration:none;
        font-family:'Arial',sans-serif!important;
        font-size:14px;
        line-height:40px;
        border-radius:2px}
.x_pfptPrimaryButtonMSO
        {border:1.5px solid #666666;
        color:#000000}
.x_pfptBanner
        {margin:15px 14px 30px 14px;
        padding:8px 16px 8px 16px;
        border-radius:4px;
        min-width:200px;
        background-color:#d0d8dc;
        border-top:4px solid #90a4ae}
.x_pfptBannerTitle
        {color:#000000;
        font-family:'Arial',sans-serif;
        font-size:14px;
        font-weight:bold;
        line-height:18px;
        display:block}
.x_pfptBannerSubtitle
        {color:#000000;
        font-weight:normal;
        font-family:'Arial',sans-serif;
        font-size:12px;
        line-height:18px;
        margin-top:2px;
        display:block}
.x_pfptButton
        {display:inline-block;
        font-family:'Arial',sans-serif;
        font-size:14px;
        font-weight:normal;
        border-radius:2px;
        padding:7.5px 16px;
        margin:3px 0 3px 16px;
        white-space:nowrap;
        width:fit-content}
.x_pfptPrimaryButton
        {border:1px solid #666666}
.x_pfptMessageContainer
        {display:inline-block;
        margin:0px 0px 1px 0px;
        max-width:600px}
.x_pfptButtonGroup
        {float:right;
        margin:0px 0px 0px 16px;
        text-align:right;
        width:fit-content}
.x_pfptPreheader
        {display:none!important;
        visibility:hidden;
        font-size:1px;
        line-height:1px;
        max-height:0px;
        max-width:0px;
        opacity:0;
        overflow:hidden}
-->
</style>
<div class="" style="word-wrap:break-word; line-break:after-white-space"><span class="x_pfptPreheader" style="display:none!important; visibility:hidden; font-size:1px; color:#ffffff; line-height:1px; max-height:0px; max-width:0px; opacity:0; overflow:hidden">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
</span><span style="display:none!important; visibility:hidden; font-size:1px; color:#ffffff; line-height:1px; max-height:0px; max-width:0px; opacity:0; overflow:hidden">ZjQcmQRYFpfptBannerStart</span>
<div class="x_pfptBanner" style="margin:16px 0px 16px 0px; padding:8px 16px 8px 16px; border-radius:4px; min-width:200px; background-color:#d0d8dc; border-top:4px solid #90a4ae">
<div class="x_pfptMessageContainer" style="display:inline-block; margin:0px 0px 1px 0px; max-width:600px">
<div class="x_pfptBannerTitle" style="color:#000000!important; font-family:'Arial',sans-serif!important; font-weight:bold!important; font-size:14px!important; line-height:18px; display:block">
This Message Is From an External Sender </div>
<div class="x_pfptBannerSubtitle" style="color:#000000!important; font-weight:normal!important; font-family:'Arial',sans-serif!important; font-size:12px!important; line-height:18px; margin-top:2px; display:block">
This message came from outside your organization. </div>
</div>
</div>
<span style="display:none!important; visibility:hidden; font-size:1px; color:#ffffff; line-height:1px; max-height:0px; max-width:0px; opacity:0; overflow:hidden">ZjQcmQRYFpfptBannerEnd<br>
</span>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:  <a href="https://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/basicPrimer.html" class="">Very
 Basic Chimera Programming Primer</a>
<div class=""><br class="">
</div>
<div class="">The differences are:</div>
<div class=""><br class="">
</div>
<div class="">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.</div>
<div class=""><br class="">
</div>
<div class="">2) To run a command, instead of:</div>
<div class=""><br class="">
</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span><i class="">from chimera import runCommand</i></div>
<div class=""><i class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>runCommand("color red")</i></div>
<div class=""><br class="">
</div>
<div class="">it's:</div>
<div class=""><br class="">
</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span><i class="">from chimerax.core.commands import run</i></div>
<div class=""><i class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>run(session, "color red")</i></div>
<div class=""><br class="">
</div>
<div class="">3) To issue status messages, instead of:</div>
<div class=""><br class="">
</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span><i class="">from chimera import replyobj</i></div>
<div class=""><i class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>replyobj.status("Processing file")</i></div>
<div class=""><br class="">
</div>
<div class="">it's just:</div>
<div class=""><br class="">
</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span><i class="">session.logger.status("Processing file")</i></div>
<div class=""><br class="">
</div>
<div class="">
<div class="">--Eric</div>
<div class=""><br class="">
</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>Eric Pettersen</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>UCSF Computer Graphics Lab</div>
</div>
<div class=""><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Jul 20, 2021, at 11:28 AM, Elaine Meng via ChimeraX-users <<a href="mailto:chimerax-users@cgl.ucsf.edu" class="">chimerax-users@cgl.ucsf.edu</a>> wrote:</div>
<br class="x_Apple-interchange-newline">
<div class="">
<div class="">One correction, the saved attribute file should have "defattr" filename extension instead of "txt", so my examples should instead be:<br class="">
<br class="">
save /location/myfile.defattr  attrName r:area<br class="">
save /location/myfile.defattr attrName r:area selectedOnly true<br class="">
<br class="">
Sorry about that.<br class="">
Elaine<br class="">
<br class="">
<blockquote type="cite" class="">On Jul 20, 2021, at 11:23 AM, Elaine Meng via ChimeraX-users <<a href="mailto:chimerax-users@cgl.ucsf.edu" class="">chimerax-users@cgl.ucsf.edu</a>> wrote:<br class="">
<br class="">
Hi Amith,<br class="">
Seems like two parts to this question:<br class="">
(A) what are the ChimeraX commands (which could be put into a .cxc file)?<br class="">
(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 class="">
<br class="">
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 class="">
<br class="">
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 class="">
<br class="">
<<a href="https://rbvi.ucsf.edu/chimerax/docs/user/commands/measure.html#sasa" class="">https://rbvi.ucsf.edu/chimerax/docs/user/commands/measure.html#sasa</a>><br class="">
<<a href="https://rbvi.ucsf.edu/chimerax/docs/user/commands/save.html#attributes" class="">https://rbvi.ucsf.edu/chimerax/docs/user/commands/save.html#attributes</a>><br class="">
<br class="">
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 class="">
<br class="">
measure sasa protein setAttribute true<br class="">
save /location/myfile.txt  attrName r:area<br class="">
<br class="">
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 class="">
<br class="">
select /A:24-53 /B:258<br class="">
save /location/myfile.txt  attrName r:area selectedOnly true<br class="">
<br class="">
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 class="">
<br class="">
I hope this helps,<br class="">
Elaine<br class="">
-----<br class="">
Elaine C. Meng, Ph.D.                       <br class="">
UCSF Chimera(X) team<br class="">
Department of Pharmaceutical Chemistry<br class="">
University of California, San Francisco<br class="">
<br class="">
<blockquote type="cite" class="">On Jul 20, 2021, at 10:12 AM, Rangarajan, Amith via ChimeraX-users <<a href="mailto:chimerax-users@cgl.ucsf.edu" class="">chimerax-users@cgl.ucsf.edu</a>> wrote:<br class="">
<br class="">
Hi,<br class="">
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 class="">
please share your tips and suggestions,<br class="">
thanks everyone !<br class="">
warm regards,<br class="">
Amith<br class="">
</blockquote>
<br class="">
<br class="">
_______________________________________________<br class="">
ChimeraX-users mailing list<br class="">
<a href="mailto:ChimeraX-users@cgl.ucsf.edu" class="">ChimeraX-users@cgl.ucsf.edu</a><br class="">
Manage subscription:<br class="">
https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users<br class="">
</blockquote>
<br class="">
<br class="">
_______________________________________________<br class="">
ChimeraX-users mailing list<br class="">
<a href="mailto:ChimeraX-users@cgl.ucsf.edu" class="">ChimeraX-users@cgl.ucsf.edu</a><br class="">
Manage subscription:<br class="">
https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</body>
</html>