From: Eric Pettersen
Sent: Friday, May 29, 2015 11:55:18 AM (UTC-06:00) Central America
To: Thapa, Mahendra (thapamb)
Cc: chimera-users@cgl.ucsf.edu
Subject: Re: [Chimera-users] Python code problem
Hi Mahendra,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 any of those residues then the distance command will fail with the error you got, since the atom spec will only select one atom.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:
from chimera.selection import OSLSelectionsel = OSLSelection(#0.1:%d.B@CB""" %i)if len(sel.residues()) != 1:continue
--EricOn May 29, 2015, at 6:37 AM, Mahendra B Thapa <thapamb@mail.uc.edu> wrote:
_______________________________________________University of Cincinnati,OHMahendra ThapaThank you for help,That is, I am interested to use range operator in 2nd case instead of two values as in the 1st case.What could be the error this code? Only difference between two codes is: "for i in [2011,2420]:" & "for i in range(2011,2420):"This code gave the result as expected:Dear Chimera users,
The command I used wasI tried two codes (following previous posts and tutorials in chimera) in 'test.py' as follows
chimera --nogui test.py
(i)
import os
from chimera import runCommand as rc
from chimera import replyobj
rc("open " + 'test.pdb')
for i in [2011,2420]:
rc("""distance #0.2:2010.B@CB #0.1:%d.B@CB""" %i)
Executing test.py...
Opening test.pdb...
60 models opened
Distance between #0.2:2010.B@CB and #0.1:2011.B@CB: 72.346
Distance between #0.2:2010.B@CB and #0.1:2420.B@CB: 92.979
Executed test.py
(ii)
import os
from chimera import runCommand as rc
from chimera import replyobj
rc("open " + 'test.pdb')
for i in range(2011,2420):
rc("""distance #0.2:2010.B@CB #0.1:%d.B@CB""" %i)
This code gave the result as
' You selected %d.' % numSelected)
MidasError: Exactly two atoms/axes/planes must be selected. You selected 1.
Error while processing test.py:
MidasError: Exactly two atoms/axes/planes must be selected. You selected 1.
File "/opt/UCSF/Chimera64-1.5.3/share/Midas/__init__.py", line 1266, in distance
' You selected %d.' % numSelected)
Chimera-users mailing list
Chimera-users@cgl.ucsf.edu
http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users