Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help
Special pages
SBGrid Resources
SBGrid Consortium
SBGrid Data Bank
Software Webinars
PyMOL Webinar
PyMOL Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Split selection
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
= The Code = <source lang="python"> import pymol from pymol import cmd def get_index_list(s): """ Given an atom selection, return the list of atom IDs in this selection """ return map(lambda x: x.index, cmd.get_model(s).atom) def get_single_index(s): """ Get the ID of the first alpha carbon in the selection, S """ # assume CA return get_index_list( "n. CA and (br. %s)" % s)[0] def split_selection(s): """ PARAMS s An atom selection. RETURNS None SIDE EFFECTS Creates two new selections, called lo and hi. Lo will have all atoms in the same molecule with atom IDs less than the alpha carbon ID in S. Hi will have all the atoms in the same molecule with IDs greater than the atom ID of the alpha carbon in S. EXAMPLE run /path/to/this/script/split_selection.py fetch 1cll select i. 79 split_selection (sele) # now look at the 'hi' and 'lo' selections. AUTHOR: Jason Vertrees, 2010. """ l = get_index_list("bm. " + s) m = min(l) M = max(l) # assume using alpha carbons selected_index = get_single_index( "n. CA and (br. sele)" ) low_sel_name = cmd.get_unused_name("lo") hi_sel_name = cmd.get_unused_name("hi") cmd.select(low_sel_name, "ID %d-%d" % (m,selected_index-1)) cmd.select(hi_sel_name, "ID %d-%d" % (selected_index+1,M)) cmd.extend("split_selection", split_selection) </source>
Summary:
Please note that all contributions to PyMOL Wiki are considered to be released under the GNU Free Documentation License 1.2 (see
PyMOL Wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Split selection
(section)
Add topic