Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Make settings
if 'ALPHA' in settings:
planeObj.extend([ALPHA, settings['ALPHA']])
if 'COLOR' in settings:
planeObj.extend([COLOR, settings['COLOR'][0], settings['COLOR'][1], settings['COLOR'][2]])
else:
planeObj.extend([COLOR, 0.8, 0.8, 0.8]) # greyish
planeObj.extend([BEGIN, TRIANGLE_STRIP])
planeObj.append(NORMAL)
if 'INVERT' in settings:
if settings['INVERT']==True:
planeObj.extend(cpv.negate(normal))
else:
planeObj.extend(normal)
else:
planeObj.extend(normal)
for corner in [corner1, corner2, corner3, corner4, corner1]:
planeObj.append(VERTEX)
planeObj.extend(corner)
planeObj.append(END)
return planeObj
# Make settings
if 'ALPHA' in settings:
planeObj.extend([ALPHA, settings['ALPHA']])
if 'COLOR' in settings:
planeObj.extend([COLOR, settings['COLOR'][0], settings['COLOR'][1], settings['COLOR'][2]])
else:
planeObj.extend([COLOR, 0.8, 0.8, 0.8]) # greyish
planeObj.extend([BEGIN, TRIANGLE_STRIP])
planeObj.append(NORMAL)
if 'INVERT' in settings:
if settings['INVERT']==True:
planeObj.extend(cpv.negate(normal))
else:
planeObj.extend(normal)
else:
planeObj.extend(normal)
for corner in [corner1, corner2, corner3, corner4, corner1]:
planeObj.append(VERTEX)
planeObj.extend(corner)
planeObj.append(END)
return planeObj
# define vectors from points
xyz2 = cpv.sub(xyz2, xyz1)
xyz3 = cpv.sub(xyz3, xyz1)
#NB! cpv.get_system2 outputs normalized vectors [x,y,z]
xyz4 = cpv.get_system2(xyz2,xyz3)
xyz2 = xyz4[0]
xyz3 = xyz4[1]
for x in range(0,3):
for z in range(0,3):
if x==z:
continue
if xyz4[x]==xyz4[z]:
raise Exception("Illegal vector settings!")
xyz4 = cpv.negate(xyz4[2]) #overwrites original
# transform origin to corner
if mode==0:
if npoints_x>1:
xyz1 = cpv.sub(xyz1, cpv.scale(xyz2,length_x/2))
if npoints_z>1:
xyz1 = cpv.sub(xyz1, cpv.scale(xyz3,length_z/2))
#defines array lines
nlines=max([npoints_x, npoints_z])
# in case only one line max
# create an empty array for xyz entries
# this may contain more values than are actually drawn later,
# but they are needed to draw lines in each direction
grid_xyz = []
Requires python module "numpy".
SEE ALSO
helix_orientation
'''
visualize, quiet = int(visualize), int(quiet)
import numpy
stored.x = list()
cmd.iterate_state(STATE, '(%s) and name CA' % (selection),
'stored.x.append([x,y,z])')
x = numpy.array(stored.x)
U, s, Vh = numpy.linalg.svd(x - x.mean(0))
vec = cpv.normalize(Vh[0])
if cpv.dot_product(vec, x[-1] - x[0]) < 0:
vec = cpv.negate(vec)
return _common_orientation(selection, vec, visualize, quiet)
Requires python module "numpy".
SEE ALSO
helix_orientation
'''
visualize, quiet = int(visualize), int(quiet)
import numpy
stored.x = list()
cmd.iterate_state(-1, '(%s) and name CA' % (selection),
'stored.x.append([x,y,z])')
x = numpy.array(stored.x)
U,s,Vh = numpy.linalg.svd(x - x.mean(0))
vec = cpv.normalize(Vh[0])
if cpv.dot_product(vec, x[-1] - x[0]) < 0:
vec = cpv.negate(vec)
return _common_orientation(selection, vec, visualize, quiet)
coords = list()
cmd.iterate_state(state, selection,
'coords.append([x,y,z])', space=locals())
if len(coords) < 3:
print('not enough guide atoms in selection')
raise CmdException
x = numpy.array(coords)
U,s,Vh = numpy.linalg.svd(x - x.mean(0))
# normal vector of plane is 3rd principle component
vec = cpv.normalize(Vh[2])
if cpv.dot_product(vec, x[-1] - x[0]) < 0:
vec = cpv.negate(vec)
center = x.mean(0).tolist()
_common_orientation(selection, center, vec, visualize, 4.0, quiet)
# plane visualize
if visualize:
from pymol import cgo
dir1 = cpv.normalize(Vh[0])
dir2 = cpv.normalize(Vh[1])
sx = [max(i/4.0, 2.0) for i in s]
obj = [ cgo.BEGIN, cgo.TRIANGLES, cgo.COLOR, 0.5, 0.5, 0.5 ]
for vertex in [
cpv.scale(dir1, sx[0]),
cpv.scale(dir2, sx[1]),