<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Mahendra,<div><span class="Apple-tab-span" style="white-space:pre"> </span>Oops, yep my code was missing a triple quote. Anyway, maybe you should send me your code and a test PDB file offline. Clearly the code you included below is not the code that produced the output you provided. In your code, <b>j</b> takes values in range(3429,3450), which does <i>not</i> include the value 3450 itself, yet in your output clearly <b>j</b> does have the value 3450. So you either provided the wrong script or the wrong output. I don't think anyone else on the list is interested in the details of what went wrong, so you should just mail me directly.</div><div><br></div><div>--Eric</div><div><br><div><div>On Jun 3, 2015, at 11:04 AM, Mahendra B Thapa <<a href="mailto:thapamb@mail.uc.edu">thapamb@mail.uc.edu</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div><div><div>Dear Eric<br><br></div>I had not realized that not every amino acid consisted of CB atom. Thank you for the code which worked; just want to add a very minor addition ( """ ) to the left of the code, i.e.<br><b>sel = OSLSelection("""#0.1:%d.B@CB""" %i)</b> instead of <b>sel = OSLSelection(#0.1:%d.B@CB""" %i)<br><br></b></div>I tried another code as<b><br></b>import string<br>rc("open " + 'test.pdb') # 60 models, each model has chains A,B,C<br>for i in [2196,2197]:<b><br></b> for j in range(3429,3450):<br> for <b>k</b> in ['A','B','C']:<br> sel = OSLSelection("""#0.3:%d.%s@CA""" %(j,k))<br> sol = OSLSelection("""#0.2:%d.B@CA""" %i)<b><br> </b> if ((len(sel.residues()) != 1) or (len(sel.residues()) != 1)):<br></div> continue<b><br></b><div><div class="gmail_extra"> if ((len(sol.residues()) != 1) and (len(sol.residues()) != 1)):<br></div><div class="gmail_extra"> continue<br> rc("""distance #0.2:%d.B@CA #0.3:%d.%s@CA""" %(i,j,k))<br><br></div><div class="gmail_extra">I got the output as (without any error message)<br>Distance between #0.2:2196.B@CA and #0.3:3450<b>.C</b>@CA: 104.315<br><br></div><div class="gmail_extra">The 'for' loop did not work for <b>k</b> (above) and only gave results for C only but not for A and B. <br><br></div><div class="gmail_extra">Thank you for help,<br></div><div class="gmail_extra">Mahendra Thapa<br></div><div class="gmail_extra">University of Cincinnati,OH<br></div><div class="gmail_extra"><br><br></div><div class="gmail_extra"><div class="gmail_quote">On Fri, May 29, 2015 at 1:55 PM, Thapa, Mahendra (thapamb) <span dir="ltr"><<a href="mailto:thapamb@mail.uc.edu" target="_blank">thapamb@mail.uc.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div style="word-wrap:break-word">
<b>
<div><font face="Tahoma" size="2"> </font></div>
</b>
<hr style="display:inline-block;width:98%">
<font face="Tahoma" size="2"><b>From:</b> Eric Pettersen<br>
<b>Sent:</b> Friday, May 29, 2015 11:55:18 AM (UTC-06:00) Central America<br>
<b>To:</b> Thapa, Mahendra (thapamb)<br>
<b>Cc:</b> <a href="mailto:chimera-users@cgl.ucsf.edu" target="_blank">chimera-users@cgl.ucsf.edu</a><br>
<b>Subject:</b> Re: [Chimera-users] Python code problem<br>
</font><br>
<div></div>
<div>Hi Mahendra,
<div><span style="white-space:pre-wrap"></span>In the first case, as you saw, it tries exactly two distances; the first involving :2011.B and the second involving :2420.B. In the second case it will try every distance from :2011.B through
:2419.B (note that the range command does not include the ending number in the range). This means if the structure is missing
<i>any</i> of those residues then the distance command will fail with the error you got, since the atom spec will only select one atom.</div>
<div><span style="white-space:pre-wrap"></span>So you either need to explicitly use just the residue numbers that exist, or you need to test if the residue you are about to try to use exists. So code to do that might be:</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>from chimera.selection import OSLSelection</div>
<div><span style="white-space:pre-wrap"></span>sel = OSLSelection(#0.1:%d.B@CB""" %i)</div>
<div><span style="white-space:pre-wrap"></span>if len(sel.residues()) != 1:</div>
<div><span style="white-space:pre-wrap"></span>continue</div>
<div><br>
</div>
<div>--Eric</div>
<div>
<div><br>
Eric Pettersen<br>
UCSF Computer Graphics Lab<br>
<a href="http://www.cgl.ucsf.edu/" target="_blank">http://www.cgl.ucsf.edu</a><br>
<br>
</div>
<div><div>
<div>On May 29, 2015, at 6:37 AM, Mahendra B Thapa <<a href="mailto:thapamb@mail.uc.edu" target="_blank">thapamb@mail.uc.edu</a>> wrote:</div>
<br>
</div><blockquote type="cite"><div>
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>Dear Chimera users,<br>
<br>
</div>
<div> The command I used was<br>
chimera --nogui test.py<br>
</div>
I tried two codes (following previous posts and tutorials in chimera) in 'test.py' as follows<br>
</div>
<br>
(i) <br>
import os<br>
from chimera import runCommand as rc<br>
from chimera import replyobj<br>
rc("open " + 'test.pdb')<br>
for i in [2011,2420]:<br>
rc("""distance #0.2:2010.B@CB #0.1:%d.B@CB""" %i)<br>
<br>
</div>
<b>This code gave the result as expected</b>:<br>
Executing test.py...<br>
Opening test.pdb...<br>
60 models opened<br>
Distance between #0.2:2010.B@CB and #0.1:2011.B@CB: 72.346<br>
Distance between #0.2:2010.B@CB and #0.1:2420.B@CB: 92.979<br>
Executed test.py<br>
</div>
<br>
(ii)<br>
import os<br>
from chimera import runCommand as rc<br>
from chimera import replyobj<br>
rc("open " + 'test.pdb')<br>
for i in range(2011,2420):<br>
rc("""distance #0.2:2010.B@CB #0.1:%d.B@CB""" %i)<br>
<b><br>
This code gave the result as</b><br>
' You selected %d.' % numSelected)<br>
MidasError: Exactly two atoms/axes/planes must be selected. You selected 1.<br>
Error while processing test.py:<br>
MidasError: Exactly two atoms/axes/planes must be selected. You selected 1.<br>
<br>
File "/opt/UCSF/Chimera64-1.5.3/share/Midas/__init__.py", line 1266, in distance<br>
' You selected %d.' % numSelected)<br>
<br>
</div>
What could be the error this code? Only difference between two codes is: "for<b> i in [2011,2420]:" & "for i in range(2011,2420):"<br>
</b></div>
That is, I am interested to use range operator in 2nd case instead of two values as in the 1st case.<b><br>
<br>
</b></div>
Thank you for help,<br>
</div>
Mahendra Thapa<br>
</div>
University of Cincinnati,OH<b><br>
</b>
<div><b><br>
</b>
<div><br>
</div>
</div>
</div></div>
_______________________________________________<br>
Chimera-users mailing list<br>
<a href="mailto:Chimera-users@cgl.ucsf.edu" target="_blank">Chimera-users@cgl.ucsf.edu</a><br>
<a href="http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users" target="_blank">http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users</a><br>
</blockquote>
</div>
<br>
</div>
<br>
<br>
</div>
</div>
</blockquote></div><br></div></div></div>
_______________________________________________<br>Chimera-users mailing list<br><a href="mailto:Chimera-users@cgl.ucsf.edu">Chimera-users@cgl.ucsf.edu</a><br>http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users<br></blockquote></div><br></div></body></html>