<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pymol.org/index.php?action=history&amp;feed=atom&amp;title=Iterate_sses</id>
	<title>Iterate sses - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pymol.org/index.php?action=history&amp;feed=atom&amp;title=Iterate_sses"/>
	<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Iterate_sses&amp;action=history"/>
	<updated>2026-05-30T21:26:00Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Iterate_sses&amp;diff=8391&amp;oldid=prev</id>
		<title>Bell: 3 revisions</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Iterate_sses&amp;diff=8391&amp;oldid=prev"/>
		<updated>2014-03-28T03:06:31Z</updated>

		<summary type="html">&lt;p&gt;3 revisions&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 03:06, 28 March 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Bell</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Iterate_sses&amp;diff=7815&amp;oldid=prev</id>
		<title>Pyadmin: 1 revision</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Iterate_sses&amp;diff=7815&amp;oldid=prev"/>
		<updated>2014-03-28T02:16:16Z</updated>

		<summary type="html">&lt;p&gt;1 revision&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;A slightly more complex version of [[ss]] that allows the user to pass in a function to act on the sse list. Of course, this requires the user to know about the internals of the sse class, but since this code is all open  I doubt that matters..&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
def iterate_sses(selection, action):&lt;br /&gt;
&lt;br /&gt;
    class SSE(object):&lt;br /&gt;
&lt;br /&gt;
        def __init__(self, start, typ, sseNumber):&lt;br /&gt;
            self.start, self.typ = start, typ&lt;br /&gt;
            self.end = -1&lt;br /&gt;
            self.sseNumber = sseNumber&lt;br /&gt;
&lt;br /&gt;
        def __repr__(self):&lt;br /&gt;
            return &amp;quot;%s-%s %s&amp;quot; % (self.start, self.end, self.typ)&lt;br /&gt;
&lt;br /&gt;
    stored.pairs = []&lt;br /&gt;
    cmd.iterate(selection, &amp;quot;stored.pairs.append((resi, ss))&amp;quot;)&lt;br /&gt;
    num, currentType = stored.pairs[0]&lt;br /&gt;
&lt;br /&gt;
    sseNumber = 1&lt;br /&gt;
    sses = [SSE(num, currentType, sseNumber)]&lt;br /&gt;
    currentSSE = sses[0]&lt;br /&gt;
    for resi, ssType in stored.pairs:&lt;br /&gt;
        if ssType == currentType:&lt;br /&gt;
            currentSSE.end = resi&lt;br /&gt;
        else:&lt;br /&gt;
            sseNumber += 1&lt;br /&gt;
            sses.append(SSE(resi, ssType, sseNumber))&lt;br /&gt;
            currentSSE = sses[-1]&lt;br /&gt;
            currentType = ssType&lt;br /&gt;
&lt;br /&gt;
    for sse in sses:&lt;br /&gt;
        action(sse)&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;iterate_sses&amp;quot;, iterate_sses)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As an example, here is a function that makes a series of selections, one for each sse, called &amp;quot;H1&amp;quot;, &amp;quot;E2&amp;quot;, and so on. Use it like: &amp;quot;iterate_sses('my_protein', doSelect)&amp;quot;.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
def doSelect(sse):&lt;br /&gt;
    cmd.select(&amp;quot;%s%s&amp;quot; % (sse.typ, sse.sseNumber), &amp;quot;i. %s-%s&amp;quot; % (sse.start, sse.end))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library|Iterate SSes]]&lt;br /&gt;
[[Category:Structural_Biology_Scripts]]&lt;/div&gt;</summary>
		<author><name>Pyadmin</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Iterate_sses&amp;diff=8389&amp;oldid=prev</id>
		<title>Gilleain: same change as for the ss command.</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Iterate_sses&amp;diff=8389&amp;oldid=prev"/>
		<updated>2007-10-09T16:57:18Z</updated>

		<summary type="html">&lt;p&gt;same change as for the ss command.&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:57, 9 October 2007&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l21&quot; &gt;Line 21:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 21:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     sses = [SSE(num, currentType, sseNumber)]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     sses = [SSE(num, currentType, sseNumber)]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     currentSSE = sses[0]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     currentSSE = sses[0]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     for resi, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;ss &lt;/del&gt;in stored.pairs:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     for resi, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;ssType &lt;/ins&gt;in stored.pairs:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         if &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;ss &lt;/del&gt;== currentType:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         if &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;ssType &lt;/ins&gt;== currentType:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             currentSSE.end = resi&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             currentSSE.end = resi&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         else:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         else:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             sseNumber += 1&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             sseNumber += 1&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             sses.append(SSE(resi, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;ss&lt;/del&gt;, sseNumber))&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             sses.append(SSE(resi, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;ssType&lt;/ins&gt;, sseNumber))&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             currentSSE = sses[-1]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             currentSSE = sses[-1]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             currentType = &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;ss&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             currentType = &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;ssType&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     for sse in sses:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     for sse in sses:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Gilleain</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Iterate_sses&amp;diff=8388&amp;oldid=prev</id>
		<title>Gilleain: New page: A slightly more complex version of ss that allows the user to pass in a function to act on the sse list. Of course, this requires the user to know about the internals of the sse class,...</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Iterate_sses&amp;diff=8388&amp;oldid=prev"/>
		<updated>2007-10-09T10:25:41Z</updated>

		<summary type="html">&lt;p&gt;New page: A slightly more complex version of &lt;a href=&quot;/index.php/Ss&quot; title=&quot;Ss&quot;&gt;ss&lt;/a&gt; that allows the user to pass in a function to act on the sse list. Of course, this requires the user to know about the internals of the sse class,...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;A slightly more complex version of [[ss]] that allows the user to pass in a function to act on the sse list. Of course, this requires the user to know about the internals of the sse class, but since this code is all open  I doubt that matters..&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
def iterate_sses(selection, action):&lt;br /&gt;
&lt;br /&gt;
    class SSE(object):&lt;br /&gt;
&lt;br /&gt;
        def __init__(self, start, typ, sseNumber):&lt;br /&gt;
            self.start, self.typ = start, typ&lt;br /&gt;
            self.end = -1&lt;br /&gt;
            self.sseNumber = sseNumber&lt;br /&gt;
&lt;br /&gt;
        def __repr__(self):&lt;br /&gt;
            return &amp;quot;%s-%s %s&amp;quot; % (self.start, self.end, self.typ)&lt;br /&gt;
&lt;br /&gt;
    stored.pairs = []&lt;br /&gt;
    cmd.iterate(selection, &amp;quot;stored.pairs.append((resi, ss))&amp;quot;)&lt;br /&gt;
    num, currentType = stored.pairs[0]&lt;br /&gt;
&lt;br /&gt;
    sseNumber = 1&lt;br /&gt;
    sses = [SSE(num, currentType, sseNumber)]&lt;br /&gt;
    currentSSE = sses[0]&lt;br /&gt;
    for resi, ss in stored.pairs:&lt;br /&gt;
        if ss == currentType:&lt;br /&gt;
            currentSSE.end = resi&lt;br /&gt;
        else:&lt;br /&gt;
            sseNumber += 1&lt;br /&gt;
            sses.append(SSE(resi, ss, sseNumber))&lt;br /&gt;
            currentSSE = sses[-1]&lt;br /&gt;
            currentType = ss&lt;br /&gt;
&lt;br /&gt;
    for sse in sses:&lt;br /&gt;
        action(sse)&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;iterate_sses&amp;quot;, iterate_sses)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As an example, here is a function that makes a series of selections, one for each sse, called &amp;quot;H1&amp;quot;, &amp;quot;E2&amp;quot;, and so on. Use it like: &amp;quot;iterate_sses('my_protein', doSelect)&amp;quot;.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
def doSelect(sse):&lt;br /&gt;
    cmd.select(&amp;quot;%s%s&amp;quot; % (sse.typ, sse.sseNumber), &amp;quot;i. %s-%s&amp;quot; % (sse.start, sse.end))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Gilleain</name></author>
	</entry>
</feed>