|
From: Schubert, C. [JRDUS] <CSC...@it...> - 2014-01-31 16:31:02
|
Hi All,
probably a question for the developers, but may not hurt to ask publicly: Is there a functionality in Pymol to list the residues in a given selection? I am looking for the equivalent to the get_chains() function. I have scripted something up, but the code is not 100% clean and not flexible enough. For large molecules the performance is not great either.
#### start script
def list_resi(obj=""):
"""
DESCRIPTION
"list_resi" prints and returns the unique residue IDs from the input
object. The object must be present in the object list
on the GUI. Selections are currently not implemented.
Chain or Segments are also not taken into account
USAGE
list_resi obj
EXAMPLES
list_resi my_prot
l = list_resi(my_prot)
"""
if ( obj == "" ):
obj="(all)"
ol = cmd.get_object_list()
if (obj in ol):
pass
else:
print "Error: Object (%s) not found" % obj
return
stored.resi_list = []
cmd.iterate(obj,"stored.resi_list.append(int(resi))")
stored.resi_list=list(set(stored.resi_list)) # make list unique
stored.resi_list.sort()
for i in range(0,len(stored.resi_list)):
print "%s," % stored.resi_list[i],
if ((i+1) % 10 == 0):
print ""
return stored.resi_list
##### End Script
Thanks for any input
Carsten
|