<?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=ToGroup</id>
	<title>ToGroup - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pymol.org/index.php?action=history&amp;feed=atom&amp;title=ToGroup"/>
	<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=ToGroup&amp;action=history"/>
	<updated>2026-08-25T16:01:13Z</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=ToGroup&amp;diff=11731&amp;oldid=prev</id>
		<title>Bell: 1 revision</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=ToGroup&amp;diff=11731&amp;oldid=prev"/>
		<updated>2014-04-08T04:32:37Z</updated>

		<summary type="html">&lt;p&gt;1 revision&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 04:32, 8 April 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=ToGroup&amp;diff=11730&amp;oldid=prev</id>
		<title>Desastre: Add script repo entry</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=ToGroup&amp;diff=11730&amp;oldid=prev"/>
		<updated>2014-04-05T16:03:21Z</updated>

		<summary type="html">&lt;p&gt;Add script repo entry&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:03, 5 April 2014&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-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{Infobox script-repo&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|type      = script&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|filename  = togroup.py&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|author    = [[User:Inchoate|Jason Vertrees]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|license   = -&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;}}&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;div&gt;= Overview =&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;= Overview =&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;[[toGroup]] will convert a multistate object into a group of single-state objects.  ''Be warned, by default it deletes your original object (since it's extracting a copy).&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;[[toGroup]] will convert a multistate object into a group of single-state objects.  ''Be warned, by default it deletes your original object (since it's extracting a copy).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Desastre</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=ToGroup&amp;diff=10560&amp;oldid=prev</id>
		<title>Bell: 2 revisions</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=ToGroup&amp;diff=10560&amp;oldid=prev"/>
		<updated>2014-03-28T04:07:08Z</updated>

		<summary type="html">&lt;p&gt;2 revisions&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Overview =&lt;br /&gt;
[[toGroup]] will convert a multistate object into a group of single-state objects.  ''Be warned, by default it deletes your original object (since it's extracting a copy).&lt;br /&gt;
&lt;br /&gt;
PyMOL does a great job at handling multistate objects and grouping them together.  One thing that I found myself doing over and over again was &lt;br /&gt;
* loading a multistate object (say a PDBQT file with 100 ligand poses)&lt;br /&gt;
* splitting that object into all 100 states, with some given prefix&lt;br /&gt;
* then grouping them into their own group&lt;br /&gt;
* and then finally removing the original.&lt;br /&gt;
&lt;br /&gt;
This became tedious, so I automated that with this script.&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# A multistate object (20 NMR states)&lt;br /&gt;
fetch 1nmr&lt;br /&gt;
&lt;br /&gt;
# Create the group called,  &amp;quot;nmrEnsemble&amp;quot;&lt;br /&gt;
# from '1nmr' and name all the new states state1,&lt;br /&gt;
# state2, state3, etc.&lt;br /&gt;
toGroup nmrEnsemble, 1nmr, prefix=state&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= The Code =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import pymol&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
&lt;br /&gt;
def toGroup(groupName,sel,prefix=&amp;quot;&amp;quot;,delOrig=True):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    DESCRIPTION&lt;br /&gt;
    toGroup will take a multistate object and extract it&lt;br /&gt;
    to a group with N objects all in state #1.  It essentially&lt;br /&gt;
    performs the following:&lt;br /&gt;
&lt;br /&gt;
    split_states myObj, prefix=somePrefix&lt;br /&gt;
    group newGroup, somePrefix*&lt;br /&gt;
    delete myObj&lt;br /&gt;
&lt;br /&gt;
    PARAMETERS:&lt;br /&gt;
    &lt;br /&gt;
    groupName (string)&lt;br /&gt;
        The name of the group to create&lt;br /&gt;
&lt;br /&gt;
    sel (string)&lt;br /&gt;
        The name of the selection/object from which&lt;br /&gt;
        to make the group&lt;br /&gt;
&lt;br /&gt;
    prefix (string)&lt;br /&gt;
        The prefix of the names of each of split states.&lt;br /&gt;
        For example, if your prefix is ''obj'' and is in&lt;br /&gt;
        states 1 through 100 then the states will be labeled&lt;br /&gt;
        obj1, obj2, obj3, ..., obj100.&lt;br /&gt;
&lt;br /&gt;
    delOrig (string/boolean)&lt;br /&gt;
        If true then delete the original selection, otherwise not.&lt;br /&gt;
&lt;br /&gt;
    RETURN&lt;br /&gt;
&lt;br /&gt;
    Nothing, it makes a new group.&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    if prefix==&amp;quot;&amp;quot;:&lt;br /&gt;
        prefix=&amp;quot;grouped&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    cmd.split_states(sel, prefix=prefix)&lt;br /&gt;
    cmd.group(groupName,prefix+&amp;quot;*&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    if delOrig:&lt;br /&gt;
        cmd.delete(sel)&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;toGroup&amp;quot;, toGroup)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
[[group]], [[saveGroup]], [[select]], [[Category:States]], [[split_states]], [[delete]], [[extend]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:ObjSel_Scripts]]&lt;/div&gt;</summary>
		<author><name>Bell</name></author>
	</entry>
</feed>