This is a read-only mirror of pymolwiki.org
SelectClipped
Jump to navigation
Jump to search
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