def rcomp(): """RNA like in papers ;-) Similar to rc() but this time it colors each (and every) structure in different colour. Great on viewing-comparing superimposed structures. """ cmd.hide("sticks", "all") cmd.hide("lines", "all") cmd.show("cartoon", "all") cmd.set("cartoon_ring_mode", 3) cmd.set("cartoon_ring_finder", 2) cmd.set("cartoon_ladder_mode", 2) cmd.set("cartoon_ring_transparency", 0.30) obj_list = cmd.get_names('objects') colours = ['red', 'green', 'blue', 'yellow', 'violet', 'cyan', \ 'salmon', 'lime', 'pink', 'slate', 'magenta', 'orange', 'marine', \ 'olive', 'purple', 'teal', 'forest', 'firebrick', 'chocolate', \ 'wheat', 'white', 'grey' ] ncolours = len(colours) # Loop over objects i = 0 for obj in obj_list: print(" ", obj, colours[i]) cmd.color(colours[i], obj) i = i+1 if(i == ncolours): i = 0
def pretty_protein(sele="(all)"): """DESCRIPTION This is my default display. It displays the protein as cartoon, but highlights ligands and ions as sticks or spheres. USAGE pretty_protein [selection] AUTHOR Spencer Bliven """ cmd.hide("lines",sele) cmd.hide("everything","( %s ) and solvent"%sele) cmd.show("cartoon",sele) # disulfides cmd.show("sticks","( %s ) and (cys/ca+cb+sg) and byres (cys/sg and bound_to cys/sg)"%sele) # ligands cmd.show("sticks","( %s ) and hetatm and not solvent and not hydrogen and not resn MSE"%sele) # metals cmd.show("spheres","( %s ) and not elem c+n+o+h+s and not resn MSE"%sele) # color carbon by chain & others by element util.cbc(sele) util.cnc(sele)
def RenderImage(files, index, reference, OutDir): """This function issues commands to pymol. Alter these commands to change what the final output looks like. Note that 'reference' is a reference structure that allows you to align everything to that structure""" cmd.do('reinitialize') cmd.do('set_color lblue= [0.86 , 1.00 , 1.00]') for i,f in enumerate(files): cmd.load(f, 'Structure%d'%i) cmd.load(f, 'Overlay') cmd.load(reference, 'Reference') cmd.hide('all') cmd.do('dss') cmd.do('bg white') cmd.do('show cartoon, Overlay') cmd.fit('Overlay', 'Reference') cmd.fit('Structure0', 'Reference') for i in range(len(files)): cmd.do('show cartoon, Structure%d'%i) cmd.fit('Structure%d'%i, 'Structure0') cmd.do('color lblue, Structure%d'%i) cmd.do('set cartoon_transparency, 0.5, Structure%d'%i) cmd.do('spectrum count, rainbow, Overlay') cmd.do('translate [0,0,10], Overlay') cmd.do('ray') cmd.do('png %s/State%d'% (OutDir, index)) return
def testShow(self): cmd.fragment('ala') self.assertEqual(cmd.count_atoms('rep sticks'), 0) cmd.show('sticks') self.assertEqual(cmd.count_atoms('rep sticks'), 10) cmd.hide('lines', 'not elem C') self.assertEqual(cmd.count_atoms('rep lines'), 3)
def DNA_selections(display='all'): bbatoms = 'name C2\*+C3\*+C4\*+C5\*+P+O3\*+O4\*+O5\*+O1P+O2P+H1\*+1H2\*+2H2\*+H3\*+H4\*+1H5\*+2H5\*+c2\'+c3\'+c4\'+c5\'+o3\'+o4\'+o5\'+op2+op1+h1\'+1h2\'+2h2\'+h3\'+h4\'+1h5\'+2h5\'' waters = 'n. wo6+wn7+wn6+wn4+wo4 or r. hoh' cmd.select('DNA', 'r. g+a+c+t+gua+ade+cyt+thy+da+dc+dg+dt+5mc',enable=0) cmd.select('notDNA','not DNA',enable=0) cmd.select('DNAbases','DNA and not %s' % bbatoms ,enable=0) cmd.select('DNAbb','DNA and %s' % bbatoms ,enable=0) cmd.select('sc_base','byres notDNA w. 7 of DNAbases',enable=0) cmd.select('sc_base','sc_base and not n. c+n+o',enable=0) cmd.select('dna_h2o','%s w. 3.6 of DNAbases' %waters ,enable=0) cmd.set('sphere_transparency','0.5'); cmd.color('marine','dna_h2o') cmd.do('selectPolarProtons') # color_by_chains() cmd.color('gray','e. c') cmd.select('pbb','notDNA and n. c+n+ca',enable=0) if display != 'none': cmd.label('n. c1\*+c1\' and DNA','\'%s%s(%s)\' % (chain,resi,resn)') cmd.set('label_color','white') if display == 'all': # display things cmd.show('sticks','DNAbases or sc_base') cmd.show('ribbon','DNAbb') cmd.show('cartoon','notDNA') cmd.show('spheres','dna_h2o') cmd.hide('everything','e. h and not polar_protons')
def damdisplay(sel, color='white', transparency=0.5): '''set visualization of dummy atom models''' #cmd.hide(representation="nonbonded", selection = sel); cmd.hide(representation="everything", selection = sel); cmd.color(color, selection = sel); cmd.set("transparency", transparency, selection = sel); cmd.show(representation="surface", selection = sel);
def colorize(): cmd.hide('(not (name C+CA+N+O))') cmd.spectrum('b', 'red_yellow_green', minimum='-1.0', maximum='1.0') cmd.select('missing', 'b = -2.0') cmd.color('white', 'missing') cmd.delete('missing')
def show_interface(obj1, obj2, threshold=5.0): inter = get_interface(obj1, obj2, threshold) cmd.hide('everything', inter) cmd.show('cartoon', inter) cmd.show('surface', inter) cmd.show('sticks', inter + ' and not name c+o+n+ca ') cmd.set('transparency', 0.3, inter)
def loadBR(pdb, saveName=None, color=None): if not saveName: saveName = pdb.split('.')[0] cmd.load(pdb, saveName) if color: cmd.color(color, saveName) cmd.hide("lines") cmd.hide("nonbonded") # cmd.show("cartoon") cmd.show("ribbon") cmd.set("cartoon_transparency", 0.7) keyResidues = ["ASPA0085", "ARGA0082", "GLUA0194", "GLUA0204", "LYSA0216", "RET", "ASPA0212"] for eachRes in keyResidues: # retinal's residue sequence id can vary in different pdbs. selection = "" if eachRes == "RET": selection = "resn ret" else: selection = parseResidue(eachRes) selection += " and not name c+o+n" cmd.show("sticks", selection) util.cbag(selection)
def resicolor(selection='all'): '''USAGE: resicolor <selection> colors all or the given selection with arbitrary coloring scheme. ''' cmd.select ('calcium','resn ca or resn cal') cmd.select ('acid','resn asp or resn glu or resn cgu') cmd.select ('basic','resn arg or resn lys or resn his') cmd.select ('nonpolar','resn met or resn phe or resn pro or resn trp or resn val or resn leu or resn ile or resn ala') cmd.select ('polar','resn ser or resn thr or resn asn or resn gln or resn tyr') cmd.select ('cys','resn cys or resn cyx') cmd.select ('backbone','name ca or name n or name c or name o') cmd.select ('none') print selection code={'acid' : 'red' , 'basic' : 'blue' , 'nonpolar': 'orange' , 'polar' : 'green' , 'cys' : 'yellow'} cmd.select ('none') for elem in code: line='color '+code[elem]+','+elem+'&'+selection print line cmd.do (line) word='color white,backbone &'+selection print word cmd.do (word) #Used to be in code, but looks like #dictionnaries are accessed at random cmd.hide ('everything','resn HOH')
def DisplaySphere(self): try: # Display the Sphere cmd.delete(self.SphereDisplay) cmd.refresh() except: pass try: cmd.pseudoatom(self.SphereDisplay, pos=self.SphereView.Center, vdw=self.SphereView.Radius, state=self.State) cmd.refresh() cmd.color('oxygen', self.SphereDisplay) cmd.refresh() cmd.hide('everything', self.SphereDisplay) cmd.refresh() cmd.show('spheres', self.SphereDisplay) cmd.refresh() except: self.ErrorCode = 1 return self.ErrorCode
def rj(): """ rhiju's residue-level favorite coloring of proteins """ cmd.bg_color( "white" ) AllObj=cmd.get_names("all") for x in AllObj: #print(AllObj[0],x) print x cmd.show( "cartoon", x ) #cmd.hide( "line", x ) cmd.show( "line", x ) cmd.color( "gray", x+" and resn trp+phe+ala+val+leu+ile+pro+met" ) cmd.color( "orange", x+" and resn gly" ) cmd.color( "red", x+" and resn asp+glu" ) cmd.color( "blue", x+" and resn lys+arg+his" ) cmd.color( "purple", x+" and resn cys" ) cmd.color( "forest", x+" and resn tyr+thr+ser+gln+asn" ) #cmd.spectrum( "resi", "rainbow", x+" and name CA" ) cmd.show( "sticks", x +" and not elem H and not name C+N+O" ) cmd.show( "sticks", x +" and resn PRO and name N" ) cmd.hide( "sticks", x + " and name NR+CR+CS+CP+CQ" ) cmd.show( "sticks", x + " and not elem H and neighbor name NR+CQ+CR+CS+CP" ) cmd.set( "cartoon_rect_length", 0.75 ) cmd.set( "cartoon_rect_width", 0.1 ) cmd.set( "cartoon_oval_length", 0.6 ) cmd.set( "cartoon_oval_width", 0.2 )
def rc( selection = "all" ): """ tube coloring for large RNA comparisons """ cmd.bg_color( "white" ) cmd.hide( 'everything',selection ) cmd.color( 'red','resn rG+G+DG and '+selection ) cmd.color( 'forest','resn rC+C+DC and '+selection) cmd.color( 'orange','resn rA+A+DA and '+selection) cmd.color( 'blue','resn rU+U+DT+BRU and '+selection) cmd.select( 'backbone', " (name o1p+o2p+o3p+p+op1+op2+'c1*'+'c2*'+'c3*'+'c5*'+'o2*'+'o3*'+'o4*'+'o5*'+'c1*'+'c2*'+'c3*'+'c4*'+'o2*'+'o4*'+c1'+c2'+c3'+c5'+o2'+o3'+o4'+o5'+c1'+c2'+c3'+c4'+o2'+o4') and (not name c1+c2+c3+c4+c5+o2+o3+o4+o5) ") #for x in AllObj: #print x cmd.show( "cartoon", selection ) cmd.spectrum( "resi", "rainbow", selection+" and backbone" ) cmd.cartoon( "tube", "backbone and "+selection ) cmd.set( "cartoon_ring_mode", 0 ) cmd.set( "cartoon_ring_transparency", 0.0 ) cmd.set( "cartoon_tube_radius", 1.0 ) cmd.color( 'red','resn rG+G and name n1+c6+o6+c5+c4+n7+c8+n9+n3+c2+n1+n2 and '+selection) cmd.color( 'forest','resn rC+C and name n1+c2+o2+n3+c4+n4+c5+c6 and '+selection) cmd.color( 'orange','resn rA+A and name n1+c6+n6+c5+n7+c8+n9+c4+n3+c2 and '+selection) cmd.color( 'blue','resn rU+U and name n3+c4+o4+c5+c6+n1+c2+o2 and '+selection) cmd.delete('backbone')
def rd(): """ rhiju's favorite coloring of proteins and generic molecules side chains are all-heavy-atom and colored CPK, backbone is rainbow cartoon from N to C terminus. """ cmd.bg_color( "white" ) AllObj=cmd.get_names("all") for x in AllObj: #print(AllObj[0],x) print x cmd.show( "cartoon", x ) cmd.hide( "line", x ) cmd.color( "white", x+" and elem C" ) cmd.color( "blue", x+" and elem N" ) cmd.color( "red", x+" and elem O" ) cmd.color( "yellow", x+" and elem S" ) cmd.spectrum( "resi", "rainbow", x+" and name CA+C" ) cmd.show( "sticks", x +" and not elem H and not name C+N+O" ) cmd.show( "sticks", x +" and resn PRO and name N" ) cmd.show( "sticks", x + " and name NR+CR+CS+CP+CQ" ) cmd.show( "sticks", x + " and not elem H and neighbor name NR+CQ+CR+CS+CP" ) cmd.show( "sticks", x + " and not elem H and neighbor neighbor name NR+CQ+CR+CS+CP" ) cmd.set( "cartoon_oval_width", 0.1 ) cmd.set( "cartoon_oval_length", 0.5 )
def rx(): """ rhiju's favorite coloring of proteins, more details -- no cartoon; heavy backbone """ cmd.bg_color( "white" ) AllObj=cmd.get_names("all") for x in AllObj: #print(AllObj[0],x) print x cmd.hide( "line", x ) cmd.color( "white", x+" and elem C" ) cmd.color( "blue", x+" and elem N" ) cmd.color( "red", x+" and elem O" ) cmd.color( "yellow", x+" and elem S" ) cmd.spectrum( "resi", "rainbow", x+" and name CA+C" ) #cmd.show( "sticks", x +" and not elem H and not name C+N+O" ) cmd.select('backbone','name o+c+ca+n') cmd.show('sticks','not elem H') if not x.count( 'BACKBONE' ): cmd.create( x+"_BACKBONE", x+" and not element H and backbone" ) cmd.set('stick_radius', '0.5', "*BACKBONE" )
def chain_contact(): def chain_contact_loop(c,skip,chainPullList): d = 0 l = c + 1 while len(chainPullList) > l and (26-d) >= 0: cmd.select('chain_contact','%s w. 5 of %s'%(chainPullList[d],chainPullList[c+1]),enable=0,quiet=1,merge=1) cmd.select('chain_contact','%s w. 5 of %s'%(chainPullList[c+1],chainPullList[d]),enable=0,quiet=1,merge=1) d += 1 l += 1 while d == (c+1) or d in skip: d += 1 glb.update() cmd.hide('everything') cmd.show('mesh', 'all') cmd.color('gray40', 'all') objects = cmd.get_names('all') chainPullList = [] for i in cmd.get_chains(quiet=1): chainPullList.append('Chain-'+i) if len(chainPullList) < 2: showinfo('Notice','There needs to be two or more chains to run this functions.') return False c = 0 skip = [] while c < (len(chainPullList)-1) and c < 26: skip.append(c+1) chain_contact_loop(c,skip,chainPullList) c += 1 glb.procolor('chain_contact','mesh','cpk',None) cmd.delete('chain_contact') return chainPullList
def mesh_ribbon(): cmd.hide('everything') glb.update() cmd.map_new('map', "gaussian", "0.75", 'all') glb.procolor(None,show_all=('lines','ribbon'),color_all='red') cmd.isomesh('map1', 'map', '1') cmd.color('purple','map1')
def rpcLabel(pos, labelText, id='lab1', color=(1, 1, 1)): """ create a text label Arguments: pos: a 3 tuple with the position of the label text: a string with the label color: a 3 tuple with the color of the label. (1,1,1) is white id: (OPTIONAL) the name of the object to be created NOTE: at the moment this is, how you say, a hack """ x, y, z = pos text = """ Atom 1 0 0 0 0 0 0 0 0 0999 V2000 % 10.4f% 10.4f%10.4f C 0 0 0 0 0 0 0 0 0 0 0 0 M END""" % (x, y, z) cmd.read_molstr(text, id) cmd.label("%s" % (id), '"%s"' % labelText) cmd.hide("nonbonded", id) cmd.set_color("%s-color" % id, color) cmd.color("%s-color" % id, id) return 1
def surface_view(surface = None): ''' Show the surface of the molecule in different representations ''' glb.update() util.cbc() cmd.hide('all') if surface == 'dot': cmd.set('dot_density',1) cmd.show('lines','all') cmd.show('dots','all') elif surface == 'mesh': cmd.set('mesh_quality',3) cmd.show('stick','all') cmd.show('mesh','all') elif surface == 'sphere': cmd.set('sphere_scale',0.5,'all') cmd.show('spheres','all') cmd.show('surface','all') cmd.set('transparency',0.5,'all') elif surface == 'stick': cmd.show('stick','all') cmd.show('surface','all') cmd.set('transparency',0.5,'all') elif surface == 'toon': cmd.set('cartoon_smooth_loops', 0) cmd.show('cartoon','all') cmd.show('surface','all') cmd.set('transparency',0.5,'all') else: cmd.show('surface','all')
def cleanup(): cmd.hide("(solvent and (all))") cmd.show("sticks","((byres (all))&n;ca,c,n,o,h)") cmd.show("lines","((byres (all))&(!(n;c,o,h|(n. n&!r. pro))))") cmd.hide("(all and hydro)") #cmd.set('cartoon_transparency','0.25') cmd.show("cartoon" ,"all")
def sculpt(self,cleanup=0): if not cleanup: cmd.set("suspend_updates",1,quiet=1) cmd.disable() cmd.delete("sculpt") cmd.set("sphere_scale","1.0") cmd.set("sphere_mode",5) cmd.load("$PYMOL_DATA/demo/pept.pdb","sculpt") cmd.hide("lines","sculpt") # cmd.show("sticks","sculpt") cmd.show("spheres","sculpt") # cmd.set("sphere_transparency","0.75","sculpt") # cmd.set("sphere_color","grey","sculpt") cmd.frame(1) cmd.set("auto_sculpt",1) cmd.set("sculpting",1) cmd.sculpt_activate("sculpt") cmd.set("sculpting_cycles","100") cmd.do("edit_mode") cmd.set("valence","0.05") cmd.set("suspend_updates",0,quiet=0) cmd.sculpt_iterate("sculpt") cmd.alter_state(1,"sculpt","x=x*1.5;y=y*0.1;z=z*1.5") cmd.zoom() cmd.unpick() else: cmd.set("valence","0") cmd.set("sculpting",0) cmd.set("auto_sculpt",0) cmd.delete("sculpt") cmd.mouse()
def get_dehydrons(): cmd.delete('dehydrons') cmd.delete('DH_pairs') cmd.hide() angle = float(angle_value.get()) cutoff = float(dist_cutoff_value.get()) desolv = float(desolv_sphere.get()) min_wrappers = float(min_value.get()) selection = 'name n or name o and not resn hoh' hb = cmd.find_pairs("((byres "+selection+") and n. n)","((byres "+selection+") and n. o)",mode=1,cutoff=cutoff,angle=angle) # sort the list for easier reading hb.sort(lambda x,y:(cmp(x[0][1],y[0][1]))) print "------------------------------------------------\n----------------dehydron Results-----------------\n------------------------------------------------\n Donor | Aceptor | \nChain Residue | Chain Residue | # dehydrons" sel = [] wra = 0 for pairs in hb: cmd.iterate("%s and index %s" % (pairs[0][0], pairs[0][1]), 'stored.nitro = chain, resi, resn') # extracts the nitrogen cmd.iterate("%s and index %s" % (pairs[1][0], pairs[1][1]), 'stored.oxy = chain, resi, resn') # extracts the oxygen wrappers = cmd.select('wrap', '(((chain %s and name ca and resi %s) around %f) or ((chain %s and name ca and resi %s) around %f)) and (not ((neighbor name n*+o*) or (name n*+o*+h*)))' % (stored.nitro[0], stored.nitro[1], desolv, stored.oxy[0], stored.oxy[1], desolv)) #Identifies the putative dehydrons if wrappers < min_wrappers: wra = 1 cmd.distance('Dehydrons',"%s and index %s" % (pairs[0][0],pairs[0][1]),"%s and index %s" % (pairs[1][0],pairs[1][1])) print ' %s%7s%5d | %s%7s%5d |%7s' % (stored.nitro[0], stored.nitro[2], int(stored.nitro[1]), stored.oxy[0], stored.oxy[2], int(stored.oxy[1]), wrappers) if stored.nitro[1] not in sel: sel.append(stored.nitro[1]) if stored.oxy[1] not in sel: sel.append(stored.oxy[1]) if wra == 1: cmd.select('DH_pairs', 'resi %s' % ('+').join(sel)) cmd.show('lines', 'DH_pairs') cmd.disable('DH_pairs') cmd.hide('labels') cmd.delete('wrap') cmd.show('cartoon') cmd.show('dashes')
def selectApolarProtons( name = None, hideother = False ): if name is None: name = "apolar_protons" polh = selectPolarProtons() cmd.select( name, 'symbol h and not %s' % polh ) # cmd.delete( polh ) # but why not keep it? if hideother: cmd.hide( 'everything', 'e. h and not %s' % name ) return name
def initial_representations(): """Configure the initial representations for the protein and the ligand""" cmd.hide('everything', 'all') cmd.show('cartoon', 'all') cmd.select('ligand', 'resn NFT') cmd.deselect() cmd.show("sticks", "ligand")
def save_surface(arg1): cmd.disable() cmd.enable(arg1) cmd.hide("everything", arg1) cmd.show("surface", arg1) cmd.save("%s.obj" % arg1, arg1) cmd.enable()
def fatslim_apl_prot(): global REF_BEAD setup() FILENAME = BILAYER_PROT REF_BEAD = BILAYER_PROT_REF # Load file cmd.load("%s.pdb" % FILENAME) main_obj = "%s" % FILENAME cmd.disable(main_obj) traj = load_trajectory("%s.gro" % FILENAME, "%s.ndx" % FILENAME) traj.initialize() frame = traj[0] draw_pbc_box(main_obj) cmd.create("protein", "resi 1-160") cmd.hide("lines", "protein") cmd.color("yellow", "protein") cmd.show("cartoon", "protein") cmd.show("surface", "protein") cmd.set("transparency", 0.5, "protein") cmd.set("surface_color", "yelloworange", "protein") # Show leaflets show_leaflets(frame) # Show stuff related to APL show_apl(frame) print("Bilayer with protein loaded!")
def hideUnoccupiedWater(fileName, threshold=-1.0): cmd.hide("lines") cmd.show("cartoon") cmd.set("cartoon_transparency", 0.8) keyResidues = ["ASPA0085", "ARGA0082", "GLUA0194"] for eachRes in keyResidues: showResidue(eachRes) cmd.set("sphere_scale", 0.4) keptWaters = [] for eachLine in open(fileName): if not eachLine.startswith("HOHDM"): continue fields = eachLine.split() confName = fields[0] occ = float(fields[1]) if occ > float(threshold): continue else: keptWaters.append(confName[:3] + confName[5:10]) print "number of kept waters: ", len(keptWaters) cmd.hide("everything", "resn HOH") for eachWat in keptWaters: chainId = eachWat[3] seq = int(eachWat[4:]) cmd.show("spheres", "resn HOH and chain " + chainId + " and resi " + str(seq))
def testFun(filePath): import networkx as nx cmd.delete("all") cmd.fetch("1C3W") cmd.hide("lines", "all") cmd.show("cartoon", "1C3W") cmd.color("green", "all") #------------------------------ cmd.color("yellow", "resi 194 and resn GLU") #------------------------------- cmd.show("sticks", "resi 194 and resn GLU") highlightRes("GLUA0194", color="yellow") highlightRes("GLUA0204", color="yellow") g = loadHbTxt(filePath) allNodes = nx.node_connected_component(g, "GLUA0194") #=========================================================================== # print allNodes #=========================================================================== accRes = {} for line in open("/Users/xzhu/sibyl/BR/1C3W/hydro/def/raw/acc.res"): fields = line.split() resString = fields[1] + fields[2] acc = float(fields[4]) accRes[resString] = acc colorThreshold = 0.02 for eachResidue in accRes.keys(): if accRes[eachResidue] > colorThreshold: if eachResidue in allNodes: print eachResidue highlightRes(eachResidue)
def testExportStyle(self): cmd.fab('ACDEF', 'm1') cmd.hide() cmd.show('cartoon', 'resi 1-3') cmd.show('lines', 'resn CYS') cmd.show('sticks', 'resn ASP+PHE') cmd.show('spheres', 'resn GLU') cmd.set('stick_ball', 1, 'resn PHE') cmd.set('stick_ball_ratio', 1.5, 'm1') testlabel = 'Hello "World"' cmd.label('name SG', repr(testlabel)) with testing.mktemp('.mae') as filename: cmd.save(filename) cmd.delete('*') cmd.load(filename, 'm2') g_labels = [] cmd.iterate('name SG', 'g_labels.append(label)', space=locals()) cmd.alter('*', 'b = 1 if s.stick_ball else 0') self._assertCountEqual('rep cartoon & guide', 'resi 1-3 & guide') self._assertCountEqual('rep lines', 'resn CYS', delta=1) self._assertCountEqual('rep sticks', 'resn ASP+PHE') self._assertCountEqual('rep spheres', 'resn GLU') self._assertCountEqual('b > 0.5', 'resn PHE') self.assertTrue(cmd.get_setting_float('stick_ball_ratio', 'm2') > 1.1) self.assertEqual(g_labels[0], testlabel)
def na(): cmd.view('v', 'store'); object = cmd.get_names()[0] pdbid = object[0:4] chainid = object[4:5] cmd.fetch(pdbid) cmd.select("design_na","%s and chain %s"%(object,"B")) cmd.select("native_na","%s and chain %s"%(pdbid,chainid)) cmd.select("other_na","%s and not chain %s"%(pdbid,chainid)) cmd.hide("everything","other") cmd.hide('(resn HOH)') cmd.super("design_na","native_na") cmd.select("none") cmd.orient(object) cmd.system("rm %s.pdb"%(pdbid)); cmd.view('v', 'recall')
dirpath = tempfile.mkdtemp() zip_dir = 'out.zip' with zipfile.ZipFile(zip_dir) as hs_zip: hs_zip.extractall(dirpath) cmd.load(join(dirpath,"protein.pdb"), "protein") cmd.show("cartoon", "protein") if dirpath: f = join(dirpath, "label_threshold_10.mol2") else: f = "label_threshold_10.mol2" cmd.load(f, 'label_threshold_10') cmd.hide('everything', 'label_threshold_10') cmd.label("label_threshold_10", "name") cmd.set("label_font_id", 7) cmd.set("label_size", -0.4) if dirpath: f = join(dirpath, "label_threshold_14.mol2") else: f = "label_threshold_14.mol2" cmd.load(f, 'label_threshold_14') cmd.hide('everything', 'label_threshold_14') cmd.label("label_threshold_14", "name") cmd.set("label_font_id", 7) cmd.set("label_size", -0.4)
dirpath = tempfile.mkdtemp() zip_dir = 'out.zip' with zipfile.ZipFile(zip_dir) as hs_zip: hs_zip.extractall(dirpath) cmd.load(join(dirpath, "protein.pdb"), "protein") cmd.show("cartoon", "protein") if dirpath: f = join(dirpath, "label_threshold_10.mol2") else: f = "label_threshold_10.mol2" cmd.load(f, 'label_threshold_10') cmd.hide('everything', 'label_threshold_10') cmd.label("label_threshold_10", "name") cmd.set("label_font_id", 7) cmd.set("label_size", -0.4) if dirpath: f = join(dirpath, "label_threshold_14.mol2") else: f = "label_threshold_14.mol2" cmd.load(f, 'label_threshold_14') cmd.hide('everything', 'label_threshold_14') cmd.label("label_threshold_14", "name") cmd.set("label_font_id", 7) cmd.set("label_size", -0.4)
resi_list_neut_part = resi_list_neut_part[:-1] # remove extra + print(resi_list_neut_part) # stabilizing part resi_list_stab_part = '' for item in range(len(res_pos_stab)): resi_list_stab_part += str(res_pos_stab[item]) + '+' resi_list_stab_part = resi_list_stab_part[:-1] # remove extra + print(resi_list_stab_part) cmd.load(pdb_path, pdb_name) cmd.bg_color('white') # cmd.zoom() # cmd.orient() cmd.hide('everything', pdb_name) cmd.show('cartoon', pdb_name) cmd.color('grey90', pdb_name) try: cmd.create('HCM_part', 'resi ' + resi_list_HCM_part) cmd.select('HCM_ca', 'bycalpha HCM_part') cmd.show('sphere', 'HCM_ca') cmd.color('greencyan', 'HCM_part') except CmdException: print('no HCM mutation') try: cmd.create('DCM_part', 'resi ' + resi_list_DCM_part) cmd.select('DCM_ca', 'bycalpha DCM_part') cmd.show('sphere', 'DCM_ca')
def hide_Labels(self): cmd.hide('labels', self.LigDisplay)
def do_library(self): cmd = self.cmd pymol = cmd._pymol suspend_undo = self.cmd.get("suspend_undo") cmd.set("suspend_undo", 1, updates=0) if not ((cmd.count_atoms("(%s) and name N" % src_sele) == 1) and (cmd.count_atoms("(%s) and name C" % src_sele) == 1) and (cmd.count_atoms("(%s) and name O" % src_sele) == 1)): self.clear() return 1 cmd.feedback("push") cmd.feedback("disable", "selector", "everythin") cmd.feedback("disable", "editor", "actions") self.prompt = ['Loading rotamers...'] self.bump_scores = [] state_best = 0 pymol.stored.name = 'residue' cmd.iterate("first (%s)" % src_sele, 'stored.name=model+"/"+segi+"/"+chain+"/"+resn+"`"+resi') self.res_text = pymol.stored.name cmd.select("_seeker_hilight", src_sele) auto_zoom = cmd.get_setting_text('auto_zoom') cmd.set('auto_zoom', "0", quiet=1) cmd.frame(0) cmd.delete(frag_name) if self.auto_center: cmd.center(src_sele, animate=-1) self.lib_mode = self.mode if self.lib_mode == "current": pymol.stored.resn = "" cmd.iterate("(%s & name CA)" % src_sele, "stored.resn=resn") rot_type = _rot_type_xref.get(pymol.stored.resn, pymol.stored.resn) if (self.c_cap != 'none') or (self.n_cap != 'none') or (self.hyd != 'auto'): self.lib_mode = rot_type # force fragment-based load else: cmd.create(frag_name, src_sele, 1, 1) if self.c_cap == 'open': cmd.remove("%s and name OXT" % frag_name) if self.lib_mode != 'current': rot_type = self.lib_mode frag_type = self.lib_mode if (self.n_cap == 'posi') and (frag_type[0:3] != 'NT_'): if not (cmd.count_atoms( "elem C & !(%s) & (bto. (name N & (%s))) &! resn ACE" % (src_sele, src_sele))): # use N-terminal fragment frag_type = "NT_" + frag_type if (self.c_cap == 'nega') and (frag_type[0:3] != 'CT_'): if not (cmd.count_atoms( "elem N & !(%s) & (bto. (name C & (%s))) & !resn NME+NHH" % (src_sele, src_sele))): # use C-terminal fragment frag_type = "CT_" + frag_type if rot_type[0:3] in ['NT_', 'CT_']: rot_type = rot_type[3:] rot_type = _rot_type_xref.get(rot_type, rot_type) cmd.fragment(frag_type.lower(), frag_name, origin=0) # trim off hydrogens if (self.hyd == 'none'): cmd.remove("(" + frag_name + " and hydro)") elif (self.hyd == 'auto'): if cmd.count_atoms("(" + src_sele + ") and hydro") == 0: cmd.remove("(" + frag_name + " and hydro)") # copy identifying information cmd.alter("?%s & name CA" % src_sele, "stored.identifiers = (segi, chain, resi, ss, color)", space=self.space) cmd.alter("?%s" % frag_name, "(segi, chain, resi, ss) = stored.identifiers[:4]", space=self.space) # move the fragment if ((cmd.count_atoms("(%s & name CB)" % frag_name) == 1) and (cmd.count_atoms("(%s & name CB)" % src_sele) == 1)): cmd.pair_fit( "(%s & name CA)" % frag_name, "(%s & name CA)" % src_sele, "(%s & name CB)" % frag_name, "(%s & name CB)" % src_sele, "(%s & name C)" % frag_name, "(%s & name C)" % src_sele, "(%s & name N)" % frag_name, "(%s & name N)" % src_sele) else: cmd.pair_fit("(%s & name CA)" % frag_name, "(%s & name CA)" % src_sele, "(%s & name C)" % frag_name, "(%s & name C)" % src_sele, "(%s & name N)" % frag_name, "(%s & name N)" % src_sele) # fix the carbonyl position... cmd.iterate_state(1, "(%s & name O)" % src_sele, "stored.list=[x,y,z]") cmd.alter_state(1, "(%s & name O)" % frag_name, "(x,y,z)=stored.list") if cmd.count_atoms("(%s & name OXT)" % src_sele): cmd.iterate_state(1, "(%s & name OXT)" % src_sele, "stored.list=[x,y,z]") cmd.alter_state(1, "(%s & name OXT)" % frag_name, "(x,y,z)=stored.list") elif cmd.count_atoms("(%s & name OXT)" % frag_name): # place OXT if no template exists angle = cmd.get_dihedral("(%s & name N)" % frag_name, "(%s & name CA)" % frag_name, "(%s & name C)" % frag_name, "(%s & name O)" % frag_name) cmd.protect("(%s & name O)" % frag_name) cmd.set_dihedral("(%s & name N)" % frag_name, "(%s & name CA)" % frag_name, "(%s & name C)" % frag_name, "(%s & name OXT)" % frag_name, 180.0 + angle) cmd.deprotect(frag_name) # fix the hydrogen position (if any) if cmd.count_atoms("(hydro and bound_to (name N & (%s)))" % frag_name) == 1: if cmd.count_atoms("(hydro and bound_to (name N & (%s)))" % src_sele) == 1: cmd.iterate_state( 1, "(hydro and bound_to (name N & (%s)))" % src_sele, "stored.list=[x,y,z]") cmd.alter_state( 1, "(hydro and bound_to (name N & (%s)))" % frag_name, "(x,y,z)=stored.list") elif cmd.select( tmp_sele1, "(name C & bound_to (%s and elem N))" % src_sele) == 1: # position hydro based on location of the carbonyl angle = cmd.get_dihedral("(%s & name C)" % frag_name, "(%s & name CA)" % frag_name, "(%s & name N)" % frag_name, tmp_sele1) cmd.set_dihedral("(%s & name C)" % frag_name, "(%s & name CA)" % frag_name, "(%s & name N)" % frag_name, "(%s & name H)" % frag_name, 180.0 + angle) cmd.delete(tmp_sele1) # add c-cap (if appropriate) if self.c_cap in ['amin', 'nmet']: if not cmd.count_atoms( "elem N & !(%s) & (bto. (name C & (%s))) & !resn NME+NHH" % (src_sele, src_sele)): if cmd.count_atoms("name C & (%s)" % (frag_name)) == 1: if self.c_cap == 'amin': editor.attach_amino_acid( "name C & (%s)" % (frag_name), 'nhh') elif self.c_cap == 'nmet': editor.attach_amino_acid( "name C & (%s)" % (frag_name), 'nme') if cmd.count_atoms( "hydro & bound_to (name N & bound_to (name C & (%s)))" % frag_name): cmd.h_fix("name N & bound_to (name C & (%s))" % frag_name) # trim hydrogens if (self.hyd == 'none'): cmd.remove("(" + frag_name + " and hydro)") elif (self.hyd == 'auto'): if cmd.count_atoms("(" + src_sele + ") and hydro") == 0: cmd.remove("(" + frag_name + " and hydro)") # add n-cap (if appropriate) if self.n_cap in ['acet']: if not cmd.count_atoms( "elem C & !(%s) & (bto. (name N & (%s))) & !resn ACE " % (src_sele, src_sele)): if cmd.count_atoms("name N & (%s)" % (frag_name)) == 1: if self.n_cap == 'acet': editor.attach_amino_acid( "name N & (%s)" % (frag_name), 'ace') if cmd.count_atoms( "hydro & bound_to (name N & bound_to (name C & (%s)))" % frag_name): cmd.h_fix("name N & (%s)" % frag_name) # trim hydrogens if (self.hyd == 'none'): cmd.remove("(" + frag_name + " and hydro)") elif (self.hyd == 'auto'): if cmd.count_atoms("(" + src_sele + ") and hydro") == 0: cmd.remove("(" + frag_name + " and hydro)") cartoon = (cmd.count_atoms("(%s & name CA & rep cartoon)" % src_sele) > 0) sticks = (cmd.count_atoms("(%s & name CA & rep sticks)" % src_sele) > 0) cmd.delete(obj_name) key = rot_type lib = None if self.dep == 'dep': try: result = cmd.phi_psi("%s" % src_sele) if len(result) == 1: (phi, psi) = list(result.values())[0] (phi, psi) = (int(10 * round(phi / 10)), int(10 * (round(psi / 10)))) key = (rot_type, phi, psi) if key not in self.dep_library: (phi, psi) = (int(20 * round(phi / 20)), int(20 * (round(psi / 20)))) key = (rot_type, phi, psi) if key not in self.dep_library: (phi, psi) = (int(60 * round(phi / 60)), int(60 * (round(psi / 60)))) key = (rot_type, phi, psi) lib = self.dep_library.get(key, None) except: pass if lib == None: key = rot_type lib = self.ind_library.get(key, None) if (lib != None) and self.dep == 'dep': print( ' Mutagenesis: no phi/psi, using backbone-independent rotamers.' ) if lib != None: state = 1 for a in lib: cmd.create(obj_name, frag_name, 1, state) if state == 1: cmd.select(mut_sele, "(byres (%s like %s))" % (obj_name, src_sele)) if rot_type == 'PRO': cmd.unbond("(%s & name N)" % mut_sele, "(%s & name CD)" % mut_sele) for b in a.keys(): if b != 'FREQ': cmd.set_dihedral("(%s & n;%s)" % (mut_sele, b[0]), "(%s & n;%s)" % (mut_sele, b[1]), "(%s & n;%s)" % (mut_sele, b[2]), "(%s & n;%s)" % (mut_sele, b[3]), a[b], state=state) else: cmd.set_title(obj_name, state, "%1.1f%%" % (a[b] * 100)) if rot_type == 'PRO': cmd.bond("(%s & name N)" % mut_sele, "(%s & name CD)" % mut_sele) state = state + 1 cmd.delete(frag_name) print(" Mutagenesis: %d rotamers loaded." % len(lib)) if self.bump_check: cmd.delete(bump_name) cmd.create( bump_name, "(((byobj %s) within 6 of (%s and not name N+C+CA+O+H+HA)) and (not (%s)))|(%s)" % (src_sele, mut_sele, src_sele, mut_sele), singletons=1) cmd.color("gray50", bump_name + " and elem C") cmd.set("seq_view", 0, bump_name, quiet=1) cmd.hide("everything", bump_name) if ((cmd.select( tmp_sele1, "(name N & (%s in (neighbor %s)))" % (bump_name, src_sele)) == 1) and (cmd.select( tmp_sele2, "(name C & (%s in %s))" % (bump_name, mut_sele)) == 1)): cmd.bond(tmp_sele1, tmp_sele2) if ((cmd.select( tmp_sele1, "(name C & (%s in (neighbor %s)))" % (bump_name, src_sele)) == 1) and (cmd.select( tmp_sele2, "(name N & (%s in %s))" % (bump_name, mut_sele)) == 1)): cmd.bond(tmp_sele1, tmp_sele2) cmd.delete(tmp_sele1) cmd.delete(tmp_sele2) cmd.protect( "%s and not (%s in (%s and not name N+C+CA+O+H+HA))" % (bump_name, bump_name, mut_sele)) cmd.sculpt_activate(bump_name) cmd.show("cgo", bump_name) # draw the bumps cmd.set("sculpt_vdw_vis_mode", 1, bump_name) state = 1 score_best = 1e6 for a in lib: score = cmd.sculpt_iterate(bump_name, state, 1) self.bump_scores.append(score) if score < score_best: state_best = state score_best = score state = state + 1 cmd.delete(mut_sele) else: cmd.create(obj_name, frag_name, 1, 1) print(" Mutagenesis: no rotamers found in library.") cmd.set("seq_view", 0, obj_name, quiet=1) pymol.util.cbaw(obj_name) cmd.hide("(" + obj_name + ")") cmd.show(self.rep, obj_name) cmd.show('lines', obj_name) #neighbor always show lines if cartoon: cmd.show("cartoon", obj_name) if sticks: cmd.show("sticks", obj_name) cmd.set('auto_zoom', auto_zoom, quiet=1) cmd.delete(frag_name) cmd.frame(state_best) cmd.unpick() cmd.set("suspend_undo", suspend_undo, updates=0) cmd.feedback("pop")
from pymol import cmd, stored cmd.load( "/Users/meghan/Documents/PhD/GitProjects/v6_2018_Network/CompStrDefns/CompPDBs/4XNL.pdb" ) cmd.hide("everything", "all") cmd.color("wheat", "all") cmd.select("Astrand0", "resi 43-54 & chain A ") cmd.color("white", "Astrand0") cmd.select("Astrand1", "resi 66-79 & chain A ") cmd.color("red", "Astrand1") cmd.select("Astrand2", "resi 85-96 & chain A ") cmd.color("orange", "Astrand2") cmd.select("Astrand3", "resi 123-135 & chain A ") cmd.color("purple", "Astrand3") cmd.select("Astrand4", "resi 145-150 & chain A ") cmd.color("yellow", "Astrand4") cmd.select("Astrand5", "resi 166-172 & chain A ") cmd.color("green", "Astrand5") cmd.select("Astrand6", "resi 178-185 & chain A ") cmd.color("cyan", "Astrand6") cmd.select("Astrand7", "resi 205-215 & chain A ") cmd.color("blue", "Astrand7") cmd.select("Astrand8", "resi 219-229 & chain A ")
def modevectors(first_obj_frame, last_obj_frame, first_state=1, last_state=1, outname="modevectors", head=1.0, tail=0.3, head_length=1.5, headrgb="1.0,1.0,1.0", tailrgb="1.0,1.0,1.0", cutoff=4.0, skip=0, cut=0.5, atom="CA", stat="show", factor=1.0, notail=0): """ Authors Sean Law & Srinivasa Michigan State University slaw_(at)_msu_dot_edu Editor Sacha Yee USAGE While in PyMOL Parameter Preset Type Description first_obj_frame Undefined String Object name of the first structure. The mode vector will propagate from this structure. Defined by user. last_obj_frame Undefined String Object name of the last structure. The mode vector (arrow head) will end at this structure. Defined by user. first_state 1 Integer Defines state of first object last_state 1 Integer Defines state of last object outname modevectors String Name of object to store mode vectors in. head 1.0 Float Radius for the circular base of the arrow head (cone) tail 0.3 Float Radius for the cylinder of the arrow tail (cylinder) head_length 1.5 Float Length of the arrow head (from the base of the cone to the tip of cone) head_rgb 1.0,1.0,1.0 String RGB colour for the arrow head. tail_rgb 1.0,1.0,1.0 String RGB colour for the arrow tail. cutoff 4.0 Float Skips mode vectors that do not meet the cutoff distance (in Angstroms). skip 0 Integer Denotes how many atoms to skip. No arrows will be created for skipped atoms. cut 0.0 Float Truncates all arrow tail lengths (without disturbing the arrow head) (in Angstroms). atom CA String Designates the atom to derive mode vectors from. stat show String Keeps track and prints statistics (total modevectors, skipped, cutoff). factor 1.0 Float Multiplies each mode vector length by a specified factor. Values between 0 and 1 will decrease the relative mode vector length. Values greater than 1 will increase the relative mode vector length. notail 0 Integer Hides tails and only uses cones (porcupine plot) """ framefirst = cmd.get_model(first_obj_frame, first_state) framelast = cmd.get_model(last_obj_frame, last_state) objectname = outname factor = float(factor) arrow_head_radius = float(head) arrow_tail_radius = float(tail) arrow_head_length = float(head_length) cutoff = float(cutoff) skip = int(skip) cut = float(cut) atomtype = atom.strip('"[]()') objectname = objectname.strip('"[]()') headrgb = headrgb.strip('" []()') tailrgb = tailrgb.strip('" []()') hr, hg, hb = list(map(float, headrgb.split(','))) tr, tg, tb = list(map(float, tailrgb.split(','))) version = cmd.get_version()[1] arrow = [] arrowhead = [] arrowtail = [] x1 = [] y1 = [] z1 = [] x2 = [] y2 = [] z2 = [] exit_flag = False ############################################################## # # # Define an object called "tail" and store the tail and a # # circular base of the triangle in this object. # # # ############################################################## skipcount = 0 skipcounter = 0 keepcounter = 0 atom_lookup = {} for atom in framefirst.atom: if atom.name == atomtype: if skipcount == skip: x1.append(atom.coord[0]) y1.append(atom.coord[1]) z1.append(atom.coord[2]) ########################################## # # # Set atom_lookup for a specific atom # # equal to ONE for the first input set. # # This dictionary will be used as a # # reference for the second set. # # # ########################################## current_atom = "CHAIN " + atom.chain + " RESID "\ + atom.resi + " RESTYPE "\ + atom.resn +\ " ATMNUM " + str(atom.index) # print current_atom atom_lookup['current_atom'] = 1 skipcount = 0 keepcounter += 1 else: # print skipcount skipcount += 1 skipcounter += 1 skipcount = 0 for atom in framelast.atom: if atom.name == atomtype: if skipcount == skip: x2.append(atom.coord[0]) y2.append(atom.coord[1]) z2.append(atom.coord[2]) ######################################### # # # Get atom information from second set # # and compare with first set. All # # atoms from this second set MUST be # # found in the first set! Otherwise, # # the script will exit with an error # # since modevectors can only be created # # by calculating values from identical # # sources. # # # ######################################### current_atom = "CHAIN " + atom.chain + " RESID "\ + atom.resi + " RESTYPE "\ + atom.resn +\ " ATMNUM " + str(atom.index) # print current_atom if 'current_atom' not in atom_lookup: print("\nError: " + current_atom + " from \""\ + last_obj_frame +\ " \"is not found in \"" + first_obj_frame + "\".") print("\nPlease check your input and/or selections and try again.") exit_flag = True break skipcount = 0 else: skipcount += 1 if exit_flag == 1: ########################################### # # # Exit script because an atom cannot be # # found in both input files # # # ########################################### return cutoff_counter = 0 # Track number of atoms failing to meet the cutoff ################################################### # # # Check that the two selections/PDB files contain # # the same number of atoms. # # # ################################################### if len(x2) != len(x1): print("\nError: \"" + first_obj_frame +\ "\" and \"" + last_obj_frame +\ "\" contain different number of residue/atoms.") print("\nPlease check your input and/or selections and try again.") return else: # Continue with representing modevectors! ######################################### # # # Delete old selection or object if it # # exists so that it can be overwritten # # # ######################################### save_view = cmd.get_view(output=1, quiet=1) cmd.delete(objectname) cmd.hide(representation="everything", selection=first_obj_frame) cmd.hide(representation="everything", selection=last_obj_frame) ################################################### # # # Begin drawing arrow tails # # # ################################################### arrowtail = [] for mv in range(len(x1)): vectorx = x2[mv] - x1[mv] vectory = y2[mv] - y1[mv] vectorz = z2[mv] - z1[mv] length = sqrt(vectorx ** 2 + vectory ** 2 + vectorz ** 2) if length < cutoff: cutoff_counter += 1 continue t = 1.0 - (cut / length) x2[mv] = x1[mv] + factor * t * vectorx y2[mv] = y1[mv] + factor * t * vectory z2[mv] = z1[mv] + factor * t * vectorz vectorx = x2[mv] - x1[mv] vectory = y2[mv] - y1[mv] vectorz = z2[mv] - z1[mv] length = sqrt(vectorx ** 2 + vectory ** 2 + vectorz ** 2) d = arrow_head_length # Distance from arrow tip to arrow base t = 1.0 - (d / length) if notail: t = 0 tail = [ # Tail of cylinder CYLINDER, x1[mv], y1[mv], z1[mv]\ , x1[mv] + (t + 0.01) * vectorx, y1[mv] + (t + 0.01) * vectory, z1[mv] + (t + 0.01) * vectorz\ , arrow_tail_radius, tr, tg, tb, tr, tg, tb # Radius and RGB for each cylinder tail ] if notail == 0: arrow.extend(tail) x = x1[mv] + t * vectorx y = y1[mv] + t * vectory z = z1[mv] + t * vectorz dx = x2[mv] - x dy = y2[mv] - y dz = z2[mv] - z seg = d / 100 intfactor = int(factor) if version < 1.1: # Version >= 1.1 has cone primitive for i in range(100, 0, -1): # i=100 is tip of cone print(i) t1 = seg * i t2 = seg * (i + 1) radius = arrow_head_radius * (1.0 - i / (100.0)) # Radius of each disc that forms cone head = [ CYLINDER, x + t2 * dx, y + t2 * dy, z + t2 * dz\ , x + t1 * dx, y + t1 * dy, z + t1 * dz\ , radius, hr, hg, hb, hr, hg, hb # Radius and RGB for slice of arrow head ] arrow.extend(head) else: head = [ CONE, x, y, z, x + d * dx, y + d * dy, z + d * dz, arrow_head_radius, 0.0, hr, hg, hb, hr, hg, hb, 1.0, 1.0] arrow.extend(head) ############################################################## # # # Load the entire object into PyMOL # # # # Print statistics if requested by user # # # ############################################################## if stat == "show": natoms = skipcounter + keepcounter print("\nTotal number of atoms = " + str(natoms)) print("Atoms skipped = " + str(skipcounter)) if keepcounter - cutoff_counter > 0: print("Atoms counted = " + str(keepcounter - cutoff_counter) + " (see PyMOL object \"" + objectname + "\")") else: print("Atoms counted = " + str(keepcounter - cutoff_counter) + " (Empty CGO object not loaded)") print("Atoms cutoff = " + str(cutoff_counter)) # Note that cutoff occurs AFTER skipping! if keepcounter - cutoff_counter > 0: cmd.delete(objectname) cmd.load_cgo(arrow, objectname) # Ray tracing an empty object will cause a segmentation fault. No arrows = Do not display in PyMOL!!! cmd.show(representation="cartoon", selection=first_obj_frame) if (first_obj_frame != last_obj_frame): cmd.show(representation="cartoon", selection=last_obj_frame) cmd.hide(representation="cartoon", selection=last_obj_frame) cmd.bg_color(color="black") cmd.set_view(save_view) return