I am script-plowing through PDB files and extracting unique chain identifiers only for "polymers" using PyMOL's polymer selection. Right now my code is a kind of brute force thing like this:
for a in cmd.index("justpolys"):
q_sel = "%s`%d"%a
cmd.iterate(q_sel, "stored.qry_info = (chain,resn,resi,name)")
#cmd.iterate_state(1,q_sel, "stored.qry_xyz = (x,y,z)")
# Track any unique chains by adding to polymer_chains list if not already there
# first reformat to get rid of flanking ' marks
if thischain not in polymer_chains:
This works, but is quite slow as it iterates over every atom in every pdb just to get out the chain so it is quite redundant.
Is there any way to iterate in a 'chain by chain' fashion? This q_sel stuff is recycled from something Warren suggested for a different purpose years ago, and I only have a loose idea of how that is interacting with the cmd.index part. Maybe there's a way to get just the chain from the get-go instead of all the individual atoms? Any reminders on that one or better method suggestions?