SelectClipped: Difference between revisions

From PyMOLWiki
Jump to navigation Jump to search
(Created page with "This script selects those atoms that are == The Code == <source lang="python"> from pymol import cmd def clipped_by(at,v): x,y,z = at.coord nz = v[2]*(x-v[12])+v[5]*(y-v[1...")
 
(select_clipped command)
 
Line 1: Line 1:
This script selects those atoms that are
This script selects those atoms that are between the near and far [[clip|clipping plane]].
 
== Usage ==
 
select_clipped [name [, selection [, state]]]
 
== The Code ==
== The Code ==
<source lang="python">
<source lang="python">
Line 12: Line 17:
   v = cmd.get_view()
   v = cmd.get_view()
   return [ i.id for i in cmd.get_model(selection,state).atom if clipped_by(i,v) ]
   return [ i.id for i in cmd.get_model(selection,state).atom if clipped_by(i,v) ]
def select_clipped(name='clipped', selection='all', state=1):
    '''
DESCRIPTION
    Select atoms between clipping planes
USAGE
    select_clipped [name [, selection [, state]]]
    '''
    state = int(state)
    cmd.select(name, 'none')
    for model in cmd.get_object_list('(' + selection + ')'):
        cmd.select_list('__tmp', model, clipped('(%s) and (%s)' % (model, selection), state))
        cmd.select(name, '__tmp', merge=1)
    cmd.delete('__tmp')
cmd.extend('select_clipped', select_clipped)
</source>
</source>


To use this script save it to "clipped.py".  Then load the script from PyMOL ("run clipped.py").
To use this script save it to "clipped.py".  Then load the script from PyMOL ("run clipped.py").


Selecting those atoms that are not clipped is as easy as,
== Example ==


<source lang="python">
<source lang="python">
cmd.select_list("sele", "objName", clipped("objName"))
# for example, fetch 1cll
# for example, fetch 1cll


Line 37: Line 59:
# run the script
# run the script


cmd.select_list("1cllClipped", "1cll", clipped("1cll"))
select_clipped 1cllClipped, 1cll


# setup the view
# setup the view

Latest revision as of 11:21, 30 August 2011

This script selects those atoms that are between the near and far clipping plane.

Usage

select_clipped [name [, selection [, state]]]

The Code

from pymol import cmd

def clipped_by(at,v):
   x,y,z = at.coord
   nz = v[2]*(x-v[12])+v[5]*(y-v[13])+v[8]*(z-v[14])-v[11]
   return nz > v[15] and nz < v[16]

def clipped(selection="all",state=1):
   v = cmd.get_view()
   return [ i.id for i in cmd.get_model(selection,state).atom if clipped_by(i,v) ]

def select_clipped(name='clipped', selection='all', state=1):
    '''
DESCRIPTION

    Select atoms between clipping planes

USAGE

    select_clipped [name [, selection [, state]]]
    '''
    state = int(state)
    cmd.select(name, 'none')
    for model in cmd.get_object_list('(' + selection + ')'):
        cmd.select_list('__tmp', model, clipped('(%s) and (%s)' % (model, selection), state))
        cmd.select(name, '__tmp', merge=1)
    cmd.delete('__tmp')

cmd.extend('select_clipped', select_clipped)

To use this script save it to "clipped.py". Then load the script from PyMOL ("run clipped.py").

Example

# for example, fetch 1cll

fetch 1cll, async=0

# orient it to clip out some data

set_view (\
    -0.555155039,    0.671998382,    0.490123481,\
     0.050991829,    0.615659416,   -0.786360741,\
    -0.830182374,   -0.411559790,   -0.376052886,\
     0.000000000,    0.000000000, -188.930786133,\
    13.649702072,   25.646595001,   12.279129982,\
   172.813293457,  205.048278809,  -20.000000000 )

# run the script

select_clipped 1cllClipped, 1cll

# setup the view

orient

# remove the surface flag on these atoms

flag exfoliate, 1cllClipped

# show everything as sticks

show sticks

# show those atoms not exfoliated as surface

show surface