<?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=Split_selection</id>
	<title>Split selection - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pymol.org/index.php?action=history&amp;feed=atom&amp;title=Split_selection"/>
	<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Split_selection&amp;action=history"/>
	<updated>2026-05-06T11:17:20Z</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=Split_selection&amp;diff=5553&amp;oldid=prev</id>
		<title>Pyadmin: 1 revision</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Split_selection&amp;diff=5553&amp;oldid=prev"/>
		<updated>2014-03-28T01:44: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;Given an initial selection, [[Split_selection]] will create two new selections.  One, called 'lo,' will have all the atoms with IDs lower than your input atom (actually input residue's alpha carbon); and the second selection is 'hi,' which contains the atoms with IDs higher than the initial (residue's alpha carbon) atom.&lt;br /&gt;
&amp;lt;gallery widths=320px heights=240&amp;gt;&lt;br /&gt;
Image:Sel_orig.png|The original selection&lt;br /&gt;
Image:Sel_lo.png|The lower selection&lt;br /&gt;
Image:Sel_hi.png|The higher selection&lt;br /&gt;
&amp;lt;/gallery&amp;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 get_index_list(s):&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	Given an atom selection, return the list of atom IDs in this selection&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	return map(lambda x: x.index, cmd.get_model(s).atom)&lt;br /&gt;
&lt;br /&gt;
def get_single_index(s):&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	Get the ID of the first alpha carbon in the selection, S&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	# assume CA&lt;br /&gt;
	return get_index_list( &amp;quot;n. CA and (br. %s)&amp;quot; % s)[0]&lt;br /&gt;
&lt;br /&gt;
def split_selection(s):&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	PARAMS&lt;br /&gt;
	    s&lt;br /&gt;
	        An atom selection.&lt;br /&gt;
&lt;br /&gt;
	RETURNS&lt;br /&gt;
	    None&lt;br /&gt;
&lt;br /&gt;
	SIDE EFFECTS&lt;br /&gt;
	    Creates two new selections, called lo and hi.  Lo will have all atoms in the same molecule&lt;br /&gt;
	    with atom IDs less than the alpha carbon ID in S.  Hi will have all the atoms in the same&lt;br /&gt;
	    molecule with IDs greater than the atom ID of the alpha carbon in S.&lt;br /&gt;
&lt;br /&gt;
	EXAMPLE&lt;br /&gt;
	    run /path/to/this/script/split_selection.py&lt;br /&gt;
	    fetch 1cll&lt;br /&gt;
	    select i. 79&lt;br /&gt;
	    split_selection (sele)&lt;br /&gt;
	    # now look at the 'hi' and 'lo' selections.&lt;br /&gt;
&lt;br /&gt;
	AUTHOR: Jason Vertrees, 2010.&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	l = get_index_list(&amp;quot;bm. &amp;quot; + s)&lt;br /&gt;
	m = min(l)&lt;br /&gt;
	M = max(l)&lt;br /&gt;
	# assume using alpha carbons&lt;br /&gt;
	selected_index = get_single_index( &amp;quot;n. CA and (br. sele)&amp;quot; )&lt;br /&gt;
&lt;br /&gt;
	low_sel_name = cmd.get_unused_name(&amp;quot;lo&amp;quot;)&lt;br /&gt;
	hi_sel_name  = cmd.get_unused_name(&amp;quot;hi&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
	cmd.select(low_sel_name, &amp;quot;ID %d-%d&amp;quot; % (m,selected_index-1))&lt;br /&gt;
	cmd.select(hi_sel_name, &amp;quot;ID %d-%d&amp;quot; % (selected_index+1,M))&lt;br /&gt;
	&lt;br /&gt;
cmd.extend(&amp;quot;split_selection&amp;quot;, split_selection)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
[[Script_Library]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:ObjSel_Scripts]]&lt;/div&gt;</summary>
		<author><name>Pyadmin</name></author>
	</entry>
</feed>