Code for unit cell and symmetry axis building is borrowed from scripts available at [http://pldserver1.biochem.queensu.ca/~rlc/work/pymol/ http://pldserver1.biochem.queensu.ca/~rlc/work/pymol/]. This code has been modified for use in SuperSym.

+

Code for unit cell and symmetry axis building is borrowed from scripts created by Robert Campbell available at [http://pldserver1.biochem.queensu.ca/~rlc/work/pymol/ http://pldserver1.biochem.queensu.ca/~rlc/work/pymol/]. This code has been modified for use in SuperSym.

[[FindSurfaceResidues]] is utilized for some of SuperSym's graphics generation, with some modifications.

[[FindSurfaceResidues]] is utilized for some of SuperSym's graphics generation, with some modifications.

+

+

==Using SuperSym==

+

+

To use SuperSym, copy the text of source files to corresponding .py files. Place SuperSymMenu.py in pymol/modules/pmg_tk/startup, and all other files in pymol/modules.

+

+

To use functions of SuperSym directly, without creating a drop-down menu in the PyMOL GUI, ignore SuperSymMenu.py and run the other files in PyMOL as you would for any other script.

==Source Files==

==Source Files==

Revision as of 18:09, 31 August 2009

SuperSym is a PyMOL plugin providing a large number of tools for visualization of space groups; unit cells; and symmetry axes, operators, and partners. Source code for version 1.0 is below.

Dependencies and Acknowledgments

Pre-v1.0 PyMOL may not display objects created by this plugin properly. Use at your own risk.

#original code written by Robert Campbell#modified by Stuart Ballardfromcctbximportuctbx,sgtbxfrompymol.cgoimport*frompymolimportcmdfrompymol.vfontimportplaindefset_to_zero(a):ifabs(a)<1e-10:a=0returnadefdraw_cell(obj,radius=1.0,mode=0):""" From pymol issue the "run draw_cell.py" command to load the script, then issue the "draw_cell(object,<optional radius>)" command to actually run it and create the cgo object showing the unit cell border for the space group specified by molecular object 'object'. e.g. load 1avv.pdb run draw_cell.py draw_cell 1avv 0.5 (or draw_cell('1avv',.5)) see also help(draw_cell_param) to draw the cell border for user-defined cell dimensions (i.e. not loaded from a pdb file) See also "help(draw_cell_param) to draw the cell border by specifying the unit cell parameters directly (i.e. not loaded from a pdb file). """radius=float(radius)cell_info=cmd.get_symmetry(obj)draw_cell_param(cell_info[0:6],radius,mode)defdraw_cell_param(cell_param_list,radius=1.0,mode=0):""" If you wish to draw the unit cell border for any cell without the need to load a pdb file, then do this: e.g. run draw_cell.py draw_cell_param((45.2,45.2,70.8,90.,90.,120.),0.5) to generate the cell border for this trigonal space group "p 31 2 1" with a radius of 0.5A. Labels for the origin, and A, B and C axes will appear as well. The perimeter of the cell is colored with the RGB components corresponding to the A,B,C components. """U=uctbx.unit_cell((cell_param_list))vert_000=map(set_to_zero,U.orthogonalize((0.,0.,0)))vert_100=map(set_to_zero,U.orthogonalize((1.,0.,0)))vert_010=map(set_to_zero,U.orthogonalize((0.,1.,0)))vert_001=map(set_to_zero,U.orthogonalize((0.,0.,1)))vert_110=map(set_to_zero,U.orthogonalize((1.,1.,0)))vert_011=map(set_to_zero,U.orthogonalize((0.,1.,1)))vert_101=map(set_to_zero,U.orthogonalize((1.,0.,1)))vert_111=map(set_to_zero,U.orthogonalize((1.,1.,1)))# vert_000 = map(None,U.orthogonalize((0.,0.,0)))# vert_100 = map(None,U.orthogonalize((1.,0.,0)))# vert_010 = map(None,U.orthogonalize((0.,1.,0)))# vert_001 = map(None,U.orthogonalize((0.,0.,1)))# vert_110 = map(None,U.orthogonalize((1.,1.,0)))# vert_011 = map(None,U.orthogonalize((0.,1.,1)))# vert_101 = map(None,U.orthogonalize((1.,0.,1)))# vert_111 = map(None,U.orthogonalize((1.,1.,1)))#print vert_000#CYLINDER = ['CYLINDER']#radius = [0.2]#print radiuscell=[]cell.append(CYLINDER)cell=cell+vert_000+vert_100+[radius]+[1,1,1]+[1,1,1]cell.append(CYLINDER)cell=cell+vert_000+vert_010+[radius]+[1,1,1]+[1,1,1]cell.append(CYLINDER)cell=cell+vert_000+vert_001+[radius]+[1,1,1]+[1,1,1]cell.append(CYLINDER)cell=cell+vert_100+vert_110+[radius]+[1,1,1]+[1,1,1]cell.append(CYLINDER)cell=cell+vert_100+vert_101+[radius]+[1,1,1]+[1,1,1]cell.append(CYLINDER)cell=cell+vert_010+vert_110+[radius]+[1,1,1]+[1,1,1]cell.append(CYLINDER)cell=cell+vert_010+vert_011+[radius]+[1,1,1]+[1,1,1]cell.append(CYLINDER)cell=cell+vert_001+vert_101+[radius]+[1,1,1]+[1,1,1]cell.append(CYLINDER)cell=cell+vert_001+vert_011+[radius]+[1,1,1]+[1,1,1]cell.append(CYLINDER)cell=cell+vert_110+vert_111+[radius]+[1,1,1]+[1,1,1]cell.append(CYLINDER)cell=cell+vert_101+vert_111+[radius]+[1,1,1]+[1,1,1]cell.append(CYLINDER)cell=cell+vert_011+vert_111+[radius]+[1,1,1]+[1,1,1]cell.append(SPHERE)cell=cell+vert_000+[radius]cell.append(SPHERE)cell=cell+vert_001+[radius]cell.append(SPHERE)cell=cell+vert_010+[radius]cell.append(SPHERE)cell=cell+vert_011+[radius]cell.append(SPHERE)cell=cell+vert_100+[radius]cell.append(SPHERE)cell=cell+vert_101+[radius]cell.append(SPHERE)cell=cell+vert_110+[radius]cell.append(SPHERE)cell=cell+vert_111+[radius]cmd.load_cgo(cell,"cell")#return cellifmode==1:text=[COLOR,1.0,0.0,1.0,]#wire_text(text,plain,[-5.,-5.,-1],'Origin',[[3.0,0.0,0.0],[0.0,3.0,0.0],[0.0,0.0,3.0]])#wire_text(text,plain,map(None,U.orthogonalize((1.05,0.0,0.0))),'A',[[3.0,0.0,0.0],[0.0,3.0,0.0],[0.0,0.0,3.0]])#wire_text(text,plain,map(None,U.orthogonalize((0.0,1.05,0.0))),'B',[[3.0,0.0,0.0],[0.0,3.0,0.0],[0.0,0.0,3.0]])#wire_text(text,plain,map(None,U.orthogonalize((0.0,0.0,1.05))),'C',[[3.0,0.0,0.0],[0.0,3.0,0.0],[0.0,0.0,3.0]])cyl_text(text,plain,[-5.,-5.,-1],'Origin',0.20,axes=[[3.0,0.0,0.0],[0.0,3.0,0.0],[0.0,0.0,3.0]],color=[1.0,0.0,1.0])cyl_text(text,plain,map(None,U.orthogonalize((1.05,0.0,0.0))),'A',0.20,axes=[[3.0,0.0,0.0],[0.0,3.0,0.0],[0.0,0.0,3.0]],color=[1.0,0.0,0.0])cyl_text(text,plain,map(None,U.orthogonalize((0.0,1.05,0.0))),'B',0.20,axes=[[3.0,0.0,0.0],[0.0,3.0,0.0],[0.0,0.0,3.0]],color=[0.0,1.0,0.0])cyl_text(text,plain,map(None,U.orthogonalize((0.0,0.0,1.05))),'C',0.20,axes=[[3.0,0.0,0.0],[0.0,3.0,0.0],[0.0,0.0,3.0]],color=[0.0,0.0,1.0])cmd.load_cgo(text,'text')cmd.extend("draw_cell",draw_cell)

File: draw_symops_cctbx.py

#! /usr/bin/env python# Copyright (c) 2004 Robert L. Campbellfromcctbximportuctbx,sgtbx#import string, mathfrompymol.cgoimport*frompymolimportcmdfromall_axes_newimportget_all_axesimportnumpyasN#import numarray as Nprint"Finished importing for draw_symops_cctbx.py"defset_to_zero(a):ifabs(a)<1e-10:a=0returnadefdraw_symbol(start,end,symb,color,radius=0.2):degtorad=N.pi/180.costhirty=N.cos(30.0*degtorad)sinthirty=N.sin(30.0*degtorad)symb_obj=[]ifsymb=='2'orsymb=='2^1':passelifsymb=='3'orsymb=='3^1'orsymb=='3^2':symb_obj=[BEGIN,TRIANGLES,COLOR]+colorsymb_obj.append(VERTEX)symb_obj=symb_obj+(N.array([start])+N.array([radius,0,0]))[0].tolist()symb_obj.append(VERTEX)symb_obj=symb_obj+(N.array([start])+N.array([-radius*sinthirty,radius*costhirty,0]))[0].tolist()symb_obj.append(VERTEX)symb_obj=symb_obj+(N.array([start])+N.array([-radius*sinthirty,-radius*costhirty,0]))[0].tolist()symb_obj.append(VERTEX)symb_obj=symb_obj+(N.array([end])+N.array([radius,0,0]))[0].tolist()symb_obj.append(VERTEX)symb_obj=symb_obj+(N.array([end])+N.array([-radius*sinthirty,radius*costhirty,0]))[0].tolist()symb_obj.append(VERTEX)symb_obj=symb_obj+(N.array([end])+N.array([-radius*sinthirty,-radius*costhirty,0]))[0].tolist()symb_obj.append(END)elifsymb=='4'orsymb=='4^1'orsymb=='4^2'orsymb=='4^3':symb_obj=[BEGIN,TRIANGLES,COLOR]+colorsymb_obj.append(VERTEX)symb_obj=symb_obj+(N.array([start])+N.array([radius,radius,0]))[0].tolist()symb_obj.append(VERTEX)symb_obj=symb_obj+(N.array([start])+N.array([-radius,radius,0]))[0].tolist()symb_obj.append(VERTEX)symb_obj=symb_obj+(N.array([start])+N.array([-radius,-radius,0]))[0].tolist()symb_obj.append(VERTEX)symb_obj=symb_obj+(N.array([start])+N.array([radius,radius,0]))[0].tolist()symb_obj.append(VERTEX)symb_obj=symb_obj+(N.array([start])+N.array([radius,-radius,0]))[0].tolist()symb_obj.append(VERTEX)symb_obj=symb_obj+(N.array([start])+N.array([-radius,-radius,0]))[0].tolist()symb_obj.append(VERTEX)symb_obj=symb_obj+(N.array([end])+N.array([radius,radius,0]))[0].tolist()symb_obj.append(VERTEX)symb_obj=symb_obj+(N.array([end])+N.array([-radius,radius,0]))[0].tolist()symb_obj.append(VERTEX)symb_obj=symb_obj+(N.array([end])+N.array([-radius,-radius,0]))[0].tolist()symb_obj.append(VERTEX)symb_obj=symb_obj+(N.array([end])+N.array([radius,radius,0]))[0].tolist()symb_obj.append(VERTEX)symb_obj=symb_obj+(N.array([end])+N.array([radius,-radius,0]))[0].tolist()symb_obj.append(VERTEX)symb_obj=symb_obj+(N.array([end])+N.array([-radius,-radius,0]))[0].tolist()symb_obj.append(END)elifsymb=='6'orsymb=='6^1'orsymb=='6^2'orsymb=='6^3'orsymb=='6^4'orsymb=='6^5':# hexagons still need to be created :)passreturnsymb_objdefdraw_symops(obj,radius=0.2,extension=0):""" From pymol issue the "run draw_symops_cctbx.py" command to load the script, then issue the "draw_symops(object,<optional radius>,<optional extension>)" command to actually run it and create the cgo object. e.g. load 1avv.pdb run draw_symops_cctbx.py draw_symops 1avv, 0.5, .2 or draw_symops('1avv',.5,.2) or draw_symops 1avv, radius=.5, extension=.2 The different axis types appear as different objects on the PyMOL menu so they can be turned on and off individually. See also help(draw_symops_param) to draw operators by specifying the space group and cell dimensions directly (i.e. not loaded from a pdb file) The 'extension' parameter is a fractional increase in the length of each symmetry operator axis drawn. i.e. a value of 0 is the default and a value of .2 increases the length by 20% at each end """radius=float(radius)extension=float(extension)cell_info=cmd.get_symmetry(obj)draw_symops_param(cell_info[0:6],cell_info[6],radius,extension)defdraw_symops_param(cell_param_list,sg,radius=0.2,extension=0):""" If you wish to draw the symmetry operators for any cell without the need to load a pdb file, then do this: e.g. run draw_symops_cctbx.py draw_symops_param((45.2,45.2,70.8,90.,90.,120.),'p3121',0.5,0.1) to generate the symmetry operators for this trigonal space group "p 31 2 1" of radius .5 with 10% added as an extension at each end. """radius=float(radius)extension=float(extension)U=uctbx.unit_cell((cell_param_list))#rotation axes# "2" "yellow",# "3" "orange",# "4" "mauve",# "6" "purple",#screw axes (all sub_1 axes are green)# "21" "green",# "31" "green",# "32" "lime",# "41" "green",# "42" "cyan",# "43" "iceblue",# "61" "green",# "62" "silver",# "63" "cyan",# "64" "iceblue",# "65" "blue",color={"2":[1.0,1.0,0.0],"3":[1.0,0.5,0.0],"4":[1.0,0.5,1.0],"6":[1.0,0.0,1.0],"2^1":[0.0,1.0,0.0],"3^1":[0.0,1.0,0.0],"3^2":[0.5,1.0,0.5],"4^1":[0.0,1.0,0.0],"4^2":[0.0,1.0,1.0],"4^3":[0.5,0.5,1.0],"6^1":[0.0,1.0,0.0],"6^2":[0.8,0.8,0.8],"6^3":[0.0,1.0,1.0],"6^4":[0.5,0.5,1.0],"6^5":[0.0,0.0,1.0],}sg=sg.upper()symop_axes=get_all_axes(sg,extension=extension)#CYLINDER = 'CYLINDER'ax_obj={}#vert_obj = []#debug_out = open('debug.log','w')ifsymop_axes:foriinrange(len(symop_axes)):#print symop_axes[i]start=map(set_to_zero,U.orthogonalize(map(None,symop_axes[i]['start'])))end=map(set_to_zero,U.orthogonalize(map(None,symop_axes[i]['end'])))################################################################################ Tried rounding off start and end values in order to understand why axes go # missing in the drawing, but seem to be present in the cgo. Doesn't help!# e.g. for space group 'p23' one of the 3-fold rotations is missing (0,0,0 -> x,-x,x)# changing one cell axis to something ever so slightly different recovers the axis# e.g. set cell to be (30.00001,30.,30.,90.,90.,90) and it works!# start = map(lambda x: round(x,3),U.orthogonalize(symop_axes[i]['start']))# end = map(lambda x: round(x,3),U.orthogonalize(symop_axes[i]['end']))###############################################################################color_ax=color[symop_axes[i]['symb']]symb_ax=symop_axes[i]['symb']#print "axis: ",symb_ax, start, endifax_obj.has_key(symb_ax):ax_obj[symb_ax].append(CYLINDER)else:ax_obj[symb_ax]=[CYLINDER]ax_obj[symb_ax]=ax_obj[symb_ax]+start+end+[radius]ax_obj[symb_ax]=ax_obj[symb_ax]+color[symb_ax]+color[symb_ax]ax_obj[symb_ax]=ax_obj[symb_ax]+draw_symbol(start,end,symb_ax,color[symb_ax],radius*6.)# ######################################################################################## # Debugging output to try to understand why some axes go missing in the drawing.# # They don't appear to be missing from the cgo object, though!# for xxx in ax_obj[symb_ax]:# if xxx == 9.0:# #print "\n\n",xxx# xxx = "\n\n" + str(xxx) + " "# debug_out.write(xxx)# else:# #print xxx# #xxx = "\n" + str(xxx) + " "# xxx = str(xxx) + " "# debug_out.write(xxx)# #print ax_obj[symb_ax]# debug_out.write("\n\n")# big_string = str(ax_obj)# debug_out.write(big_string)# # End of debugging output# #######################################################################################else:print"\nNo symmetry axes found for this space group: %s\n"%sgforkeyinax_obj.keys():name=sg+"_"+keycmd.load_cgo(ax_obj[key],name)#debug_out.write("\n\n" + key + "\n" + str(ax_obj[key]))#return ax_objcmd.extend("draw_symops",draw_symops)#cmd.extend("draw_symops_param",draw_symops_param)