PyMOL scripting. How to select the last residue? #358
-
Hello PyMOLers. How to select, say, the last residue of chain C? Thank you. Ivan |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Does it mean that the last residue may have a residue id smaller than the previous residue? That sounds not very conventional.
myspace = {"res_ids": set()}
cmd.iterate("chain C and not het", "res_ids.add(resv)", space=myspace)
my_res_id = max(myspace["res_ids"])
cmd.select("my_terminal_res", f"resi {my_res_id}")
myspace = {"res_ids": set()}
cmd.iterate("chain C and name OXT and not het", "res_ids.add((resi, resn, chain))", space=myspace)
my_res_id = myspace["res_ids"].pop()
cmd.select("my_terminal_res", "resi {0} and resn {1} and chain {2}".format(*my_res_id))
|
Beta Was this translation helpful? Give feedback.
-
There is a
I would also add
|
Beta Was this translation helpful? Give feedback.
There is a
last
operator.I would also add
guide
andpresent
to make sure it's a polymer residue and has coordinates in the current state:See https://pymolwiki.org/index.php/Selection_Algebra