def load(): cmd.set("valence") r = 0 list = glob("pdb/*/*") (x,y,z)=(0,0,0) start = time.time() count = 1 scale = 100.0 for file in list: cmd.load(file,str(count),quiet=1) cmd.translate([x*scale,y*scale,z*scale],object=str(count)) # cmd.disable(str(count)) atoms = cmd.count_atoms() passed = time.time()-start print "%3d structures/%5.1f sec = %8.1f atom/sec over %6d atoms"%(count,passed,atoms/passed,atoms) count = count + 1 if count>100: break x = x + 1 if x>7: x = 0 y = y + 1 if y>7: y = 0 z = z + 1 if z>9: y = 0 z = z + 1 cmd.zoom() cmd.set("sphere_mode",1) cmd.as("spheres") cmd.rebuild() cmd.set("hash_max",250)
def load(): try: r = 0 list = glob(ent_dir) list.sort() # list = [ "pdb/vq" ] for dir in list: sys.__stdout__.write("\n"+dir) sys.__stdout__.flush() for file in glob(dir+"/pdb*"): name = os.path.split(file)[-1] name = string.split(name,'.')[0] cmd.disable() cmd.load(file,name) cmd.as("cartoon",name) cmd.refresh() cmd.dss(name) cmd.refresh() time.sleep(0.1) sys.__stdout__.write(".") sys.__stdout__.flush() sys.__stdout__.write("("+str(cmd.count_atoms())+")") sys.__stdout__.flush() cmd.dss() cmd.delete('all') except: traceback.print_exc()
def load(): cmd.set("valence") r = 0 list = glob("pdb/*/*") # while list[0]!="pdb/f8/pdb1f8u": # list.pop(0) for file in list: try: cmd.delete('pdb') cmd.load(file,'pdb') cmd.set_title('pdb',1,os.path.split(file)[-1]) cmd.rewind() cmd.orient('pdb') cmd.refresh() cmd.as("ribbon") cmd.refresh() cmd.as("sticks") cmd.refresh() sys.__stderr__.write(".") sys.__stderr__.flush() n = cmd.count_states() if n>1: cmd.rewind() sys.__stderr__.write(file+"\n") sys.__stderr__.flush() for a in range(1,n+1): cmd.forward() cmd.refresh() except: traceback.print_exc()
particle.append([resi] + map(lambda x:(random()-0.5)*box_size/2,[0]*3) + # x,y,z [random()+0.5] + # r map(lambda x:(random()-0.5),[0]*3) # vx,vy,vz ) # create cloud object for part in particle: cmd.pseudoatom("cloud", resi = part[0], pos = part[1:4], vdw = part[4]) # draw spheres efficiently cmd.as("spheres") cmd.unset("cull_spheres") # position the camera cmd.zoom() cmd.zoom("center",box_size) # let there be color cmd.spectrum() # this is the main loop def simulation(): import traceback
cmd.load("$TUT/1hpv.pdb") # color by chain (aesthetics) util.cbc() # store the links as atom text_types cmd.alter("name ca",r"text_type='http://delsci.info/cgi-bin/click.cgi?residue=%s%s%s'%(resn,resi,chain)") # put the mouse into single-atom selection mode cmd.set('mouse_selection_mode',0) # just show ribbon (means we can only select labelled C-alphas) cmd.as("cartoon") # set up the labels cmd.label("name ca","'Link'") # color the labels white cmd.set("label_color", 'white') # activate the wizard cmd.set_wizard(Clickurl())
from sys import argv from pymol import cmd, util if len(argv) < 2: print "usage: " + argv[0] + "pdbfile\n" quit() pdbfile = argv[1] cmd.set('antialias', 1) cmd.set('depth_cue', 0) cmd.set('ray_opaque_background', 0) cmd.set('ray_trace_fog', 0) cmd.load(pdbfile) cmd.as('sticks', 'cross*') cmd.as('surface', 'protein') cmd.color('wheat', 'protein') cmd.orient('protein') cmd.png('mappedpdb', width=600, height=450, dpi=72, ray=1)
def centerOfMass(selection): ## assumes equal weights (best called with "and name ca" suffix) model = cmd.get_model(selection) x,y,z=0,0,0 for a in model.atom: x+= a.coord[0] y+= a.coord[1] z+= a.coord[2] return (x/len(model.atom), y/len(model.atom), z/len(model.atom)) cmd.load("/group/bioinf/Data/PDBLinks/1c7c.pdb") cmd.select("domain", "/1c7c//A/143-283/ and name ca") ## selecting a domain domainCenter=centerOfMass("domain") print "Center of mass: (%.1f,%.1f,%.1f)"% domainCenter cmd.as("cartoon", "all") cmd.show("spheres", "domain") ## Creating a sphere CGO com = [COLOR, 1.0, 1.0, 1.0, SPHERE]+list(domainCenter) + [3.0] ## white sphere with 3A radius cmd.load_cgo(com, "CoM") cmd.zoom("1c7c", 1.0) cmd.center("domain") #ah@bioinfws19:~/Projects/PyMOL$ pymol -qc centerOfMass4.py #Center of mass: (-1.0,24.5,48.2) #ah@bioinfws19:~/Projects/PyMOL$