<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<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);">
Shubham,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
session.models is a manager that keeps track of all the models in your session. You'll want to get a specific atomic structure from session.models. There's a couple ways to do this, but here's two:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace;"># list all models that are atomic structures</span><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace;">from chimerax.atomic import AtomicStructure</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace;">session.models.list(type=AtomicStructure)</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace;"># iterate through all models</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace;">for m in session.models:</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace;"> print(m.name, m.atomspec)</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
With either of these, you'll have to pick out which model you want. <br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
You should also be able to use the AtomicStructures list that was returned from your first 'open' command. As far as I know, the extra coordinate sets should be added to that structure after you open the trajectory file.<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Best,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Tony<br>
</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> ChimeraX-users <chimerax-users-bounces@cgl.ucsf.edu> on behalf of Shubham Devesh Ramgoolam via ChimeraX-users <chimerax-users@cgl.ucsf.edu><br>
<b>Sent:</b> Thursday, May 26, 2022 11:17 AM<br>
<b>To:</b> ChimeraX Users Help <chimerax-users@cgl.ucsf.edu><br>
<b>Subject:</b> Re: [chimerax-users] Coordset command not working in nogui mode</font>
<div> </div>
</div>
<style>
<!--
@font-face
{font-family:Helvetica}
@font-face
{font-family:"Cambria Math"}
@font-face
{font-family:Calibri}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif}
a:link, span.x_MsoHyperlink
{color:blue;
text-decoration:underline}
span.x_apple-converted-space
{}
.x_MsoChpDefault
{}
@page WordSection1
{margin:1.0in 1.0in 1.0in 1.0in}
div.x_WordSection1
{}
-->
</style>
<div lang="EN-US" link="blue" vlink="#954F72" style="word-wrap:break-word"><font color="BA0C2F">[EXTERNAL SENDER - PROCEED CAUTIOUSLY]</font><br>
<br>
<div>
<div class="x_WordSection1">
<p class="x_MsoNormal">Hi Eric,</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">The ‘wait 1’ command is very helpful. Thank you so much!</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">I have also tried the other method but it is not working for me.</p>
<p class="x_MsoNormal"></p>
<p class="x_MsoNormal">{Some background: My topology file was in prmtop format while my coordinate file was in dcd format. So, I opened both files in chimera and then saved the trajectory as a pdb. I am now using a combination of the pdb file and the dcd coordinate
file in chimeraX.}</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">This is what I got from the Python Shell of ChimeraX:</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">run(session, 'open '+ r'C:\Users\Shubham\Desktop\SK_Lab\myfile.pdb')</p>
<p class="x_MsoNormal">Out[3]: [<chimerax.atomic.structure.AtomicStructure at 0x2ef81670040>]</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">run(session, 'open ' + r'C:\Users\Shubham\Desktop\mycoord.dcd' + ' structureModel #1')</p>
<p class="x_MsoNormal">Out[4]: []</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">s = session.models</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">s</p>
<p class="x_MsoNormal">Out[6]: <chimerax.core.models.Models at 0x2efc7fece50></p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">s.coordset_ids</p>
<p class="x_MsoNormal">---------------------------------------------------------------------------</p>
<p class="x_MsoNormal">AttributeError Traceback (most recent call last)</p>
<p class="x_MsoNormal">~\AppData\Local\Temp/ipykernel_9612/1923568490.py in <module></p>
<p class="x_MsoNormal">----> 1 s.coordset_ids</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">AttributeError: 'Models' object has no attribute 'coordset_ids'</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">My goal with this is to get a way to obtain the total number of frames available for the trajectory.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">My chimeraX version 1.5.dev202205200152 (2022-05-20).</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Regards,</p>
<p class="x_MsoNormal">Shubham</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986">
Mail</a> for Windows</p>
<p class="x_MsoNormal"> </p>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_MsoNormal" style="border:none; padding:0in"><b>From: </b><a href="mailto:pett@cgl.ucsf.edu">Eric Pettersen</a><br>
<b>Sent: </b>Tuesday, May 24, 2022 22:15<br>
<b>To: </b><a href="mailto:sdramgoolam@uwaterloo.ca">Shubham Devesh Ramgoolam</a><br>
<b>Cc: </b><a href="mailto:chimerax-users@cgl.ucsf.edu">chimerax-users@cgl.ucsf.edu</a><br>
<b>Subject: </b>Re: [chimerax-users] Coordset command not working in nogui mode</p>
</div>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Hi Shubham,</p>
<div>
<p class="x_MsoNormal">Since the "coordset" command sets up playback of coordinate frames, it doesn't actually do anything until a frame is drawn, which is why in nogui mode nothing changes, and why you have to "create a delay" in GUI mode. You can force a
frame to get drawn with the "wait 1" command, which will get your script working in both modes.</p>
</div>
<div>
<p class="x_MsoNormal">Alternatively, if you have the structure model in a variable (i.e. from the list of models returned by the 'open' command, or culled from session.models), you can change the coordset directly,
<i>e.g.</i>:</p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal"># if the structure model is in the 's' variable</p>
</div>
<div>
<p class="x_MsoNormal">for cid in s.coordset_ids:</p>
</div>
<div>
<p class="x_MsoNormal">s.active_coordset_id = cid</p>
</div>
<div>
<p class="x_MsoNormal"># do whatever you need to do with this coordset</p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<div>
<p class="x_MsoNormal">--Eric</p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal">Eric Pettersen</p>
</div>
<div>
<p class="x_MsoNormal">UCSF Computer Graphics Lab</p>
</div>
</div>
<div>
<p class="x_MsoNormal"> </p>
<div>
<p class="x_MsoNormal"><br>
<br>
</p>
<blockquote style="margin-top:5.0pt; margin-bottom:5.0pt">
<div>
<p class="x_MsoNormal">On May 24, 2022, at 1:22 AM, Shubham Devesh Ramgoolam via ChimeraX-users <<a href="mailto:chimerax-users@cgl.ucsf.edu">chimerax-users@cgl.ucsf.edu</a>> wrote:</p>
</div>
<p class="x_MsoNormal"> </p>
<div>
<div>
<p class="x_MsoNormal">Hi all,</p>
</div>
<div>
<p class="x_MsoNormal">I hope you are doing well.</p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal">I have a python script for measuring the distance between aromatic rings of specific residues for different frames of a trajectory.</p>
</div>
<div>
<p class="x_MsoNormal">To measure the distance, I am first defining centroids at the center of aromatic rings and then use the command distance. This process is repeated for each frame to be analyzed.</p>
</div>
<div>
<p class="x_MsoNormal">To navigate between frames, I am using the command ‘coordset #1 {desired frame}’.</p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal">When executing the script in no gui mode, the centroids are always defined with respect to the residue’s location in frame 1 even though the command coordset has changed the frame.</p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal">In gui mode, the script only works if a delay is created between changing the frame and defining the new centroids.</p>
</div>
<div>
<p class="x_MsoNormal">I introduced that delay by asking for a dummy user input (I ran the script from python Shell):</p>
</div>
<div>
<p class="x_MsoNormal" style="text-indent:.5in">run(session, 'coordset #1 ' + {new_frame})</p>
</div>
<div>
<p class="x_MsoNormal" style="text-indent:.5in">y = input('dummy')</p>
</div>
<div>
<p class="x_MsoNormal" style="text-indent:.5in">run (session, 'define centroid /A:8 & aromatic-ring radius 0.3 color yellow mass false name d1’)</p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal">My chimeraX version: 1.4rc202205060510 (2022-05-06)</p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal">Should I be using a different command for changing frames of trajectories when in nogui mode?</p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal">Regards,</p>
</div>
<div>
<p class="x_MsoNormal">Shubham</p>
</div>
<p class="x_MsoNormal"> <span class="x_apple-converted-space"> </span></p>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal">Sent from<span class="x_apple-converted-space"> </span><a href="https://go.microsoft.com/fwlink/?LinkId=550986">Mail</a><span class="x_apple-converted-space"> </span>for Windows</p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<p class="x_MsoNormal"><span style="font-size:9.0pt; font-family:"Helvetica",sans-serif">_______________________________________________<br>
ChimeraX-users mailing list<br>
</span><a href="mailto:ChimeraX-users@cgl.ucsf.edu"><span style="font-size:9.0pt; font-family:"Helvetica",sans-serif">ChimeraX-users@cgl.ucsf.edu</span></a><span style="font-size:9.0pt; font-family:"Helvetica",sans-serif"><br>
Manage subscription:<br>
</span><a href="https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users"><span style="font-size:9.0pt; font-family:"Helvetica",sans-serif">https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users</span></a></p>
</div>
</blockquote>
</div>
</div>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"> </p>
</div>
</div>
</div>
</body>
</html>