Difference between revisions of "Ss"
Jump to navigation
Jump to search
(New page: A command to list a summary of the secondary structure for a selection. Use like "ss my_protein" where "my_protein" is the name of the chain or structure in view. <source lang="python"> def ss(selectio...) |
|||
(4 intermediate revisions by 3 users not shown) | |||
Line 2: | Line 2: | ||
<source lang="python"> | <source lang="python"> | ||
+ | from pymol import cmd | ||
+ | from pymol import stored | ||
+ | |||
def ss(selection): | def ss(selection): | ||
Line 14: | Line 17: | ||
stored.pairs = [] | stored.pairs = [] | ||
− | cmd.iterate(selection, "stored.pairs.append((resi, ss))") | + | cmd.iterate("%s and n. ca" % selection, "stored.pairs.append((resi, ss))") |
num, currentType = stored.pairs[0] | num, currentType = stored.pairs[0] | ||
sses = [SSE(num, currentType)] | sses = [SSE(num, currentType)] | ||
currentSSE = sses[0] | currentSSE = sses[0] | ||
− | for resi, | + | for resi, ssType in stored.pairs: |
− | if | + | if ssType == currentType: |
currentSSE.end = resi | currentSSE.end = resi | ||
else: | else: | ||
− | sses.append(SSE(resi, | + | sses.append(SSE(resi, ssType)) |
currentSSE = sses[-1] | currentSSE = sses[-1] | ||
− | currentType = | + | currentType = ssType |
for sse in sses: | for sse in sses: | ||
Line 32: | Line 35: | ||
cmd.extend("ss", ss) | cmd.extend("ss", ss) | ||
</source> | </source> | ||
+ | |||
+ | [[Category:Script_Library|Secondary Structure Writer]] | ||
+ | [[Category:Structural_Biology_Scripts]] |
Latest revision as of 12:20, 21 July 2009
A command to list a summary of the secondary structure for a selection. Use like "ss my_protein" where "my_protein" is the name of the chain or structure in view.
from pymol import cmd
from pymol import stored
def ss(selection):
class SSE(object):
def __init__(self, start, typ):
self.start, self.typ = start, typ
self.end = -1
def __repr__(self):
return "%s-%s %s" % (self.start, self.end, self.typ)
stored.pairs = []
cmd.iterate("%s and n. ca" % selection, "stored.pairs.append((resi, ss))")
num, currentType = stored.pairs[0]
sses = [SSE(num, currentType)]
currentSSE = sses[0]
for resi, ssType in stored.pairs:
if ssType == currentType:
currentSSE.end = resi
else:
sses.append(SSE(resi, ssType))
currentSSE = sses[-1]
currentType = ssType
for sse in sses:
print sse
cmd.extend("ss", ss)