def pymolrc(): """ startup settings, always applicable """ # multithreading cmd.set('max_threads', psutil.cpu_count()) # color space cmd.space('pymol') # environment and color cmd.bg_color('white') cmd.set('depth_cue', 'off') cmd.set('fog', 'off') # nicer visualization cmd.set('valence', 'on') cmd.set('cartoon_side_chain_helper', 'on') cmd.set('cartoon_highlight_color', 'grey50') cmd.set('sphere_mode', '9') # make sure trajectories are only loaded once defer_builds_mode is 3 def load_traj(*args, **kwargs): cmd.set('defer_builds_mode', 3) cmd.sync() cmd.load_traj(*args, **kwargs) cmd.extend('load_traj', load_traj)
def visualize_in_pymol(args,outfolder,clusters,interactions,pdb,cut,freq): #(args,outfolder,clusters,interactions,pdb,cut,freq)=input_args #print(cut) #return pymol.finish_launching() cmd.reinitialize() cmd.load(pdb) cmd.hide("everything") # cmd.show("ribbon") cmd.show("cartoon") # Create bindings and selections, and color them bond_connections(clusters, interactions) selections = select_clusters(clusters) colors = color_selections(selections) print(colors) # colors = color_selections([sele]) #cmd.color("gray70") #cmd.set("sphere_scale",0.75) cmd.space("cmyk") #cmd.set("ray_shadow","off") #cmd.bg_color("white") sele = "chain A and resi 131 and not name H*" cmd.show("sticks",sele) cmd.util.cnc(sele) #cmd.center("chain A") cmd.deselect() ### cut below here and paste into script ### cmd.set_view ([\ 0.185403526, -0.784912288, -0.591205537,\ -0.726189077, 0.295874894, -0.620551527,\ 0.662004888, 0.544381559, -0.515144050,\ -0.001714554, -0.001769811, -125.023078918,\ 30.330446243, 78.181671143, 146.038742065,\ 98.763908386, 151.776306152, -20.000000000] ) outfile="{}cluster{}-{}.png".format(outfolder,cut,freq) if args.ray or args.generate_all: cmd.save(outfile) ### cut above here and paste into script ### # Show clusters if args.show[0] is None: show_cluster(clusters) else: shw = [int(c) for c in args.show[0].split(',')] for c in args.show[0]: show_cluster(clusters[c - 1]) cmd.save(outfile) cmd.quit()
def cspace_switch(tag): if tag == 'PyMOL': cmd.space('pymol') elif tag == 'Publications': cmd.space('rgb') else: cmd.space('cmyk')
def cspace_switch(tag): if tag == 'PyMOL': cmd.space('pymol') elif tag == 'Publications': cmd.space('rgb') else: cmd.space('cmyk')
def main(): from argparse import ArgumentParser from sys import argv, stdin parser = ArgumentParser( description="Display Wordom PSN analysis clusters in PyMOL.") parser.add_argument( "-c", nargs=1, default=[None], metavar="float", help="Cutoff to use (must be present in AVGfile)" + ", default=Use lowest found") parser.add_argument( "-f", nargs=1, default='50.0', metavar=float, help="frequencey Cutoff to use (must be present in AVGfile)") parser.add_argument( "-show", nargs=1, default=[None], metavar="int[,int[...]]", help="Show specified clusters") parser.add_argument( "-ray", action='store_true', help="raytrace and save fig") parser.add_argument( "-overwrite", action='store_true', help="overwrite if fig already exists") parser.add_argument( "-generate_all", action='store_true', help="generate raytraced figs for all cutoffs and frequences") parser.add_argument( "avg", nargs=1, metavar="AVGfile", type=str, help="Wordom PSN avg file") parser.add_argument( "pdb", nargs=1, metavar="PDBfile", type=str,help="PDB file to draw") args = parser.parse_args() # Finish pymol launch # pymol.finish_launching() # cmd.feedback("disable","all","actions") # cmd.feedback("disable","all","results") # Set variables here pdb = args.pdb[0] avg = args.avg[0] cut = args.c[0] freq= float(args.f[0]) shw = args.show[0] ray = args.ray or args.generate_all outfolder=os.path.abspath(avg) outfile = "{}cluster{}-{}.png".format(outfolder, cut, freq) if not args.overwrite and os.path.exists(outfile): print("\n{} already exist.\nUse -overwrite if you want to overwrite the existing file.\n".format(outfile)) sys.exit() interactions = {} clusters_all = {} with open(avg, 'r') as infile: interactions = read_avg_strength(infile) #print(interactions) #sys.exit() infile.seek(0) clusters_all = read_avg_clusters(infile) #print(clusters) #sys.exit() # print("Hello") #sys.exit(1) # Select the cutoff #with open("cutoffs", 'wb') as f: # pickle.dump(list(clusters.keys()), f) if cut is not None: # If provided cut = float(cut) else: # Default cutoffs = list(clusters_all.keys()) cutoffs.sort() cut = cutoffs[0] cuts_to_sweep=[cut] freq_to_sweep=[freq] if args.generate_all: cuts_to_sweep=clusters_all.keys() freq_to_sweep=clusters_all[cut].keys() todo=[] for cut_ in cuts_to_sweep: for freq_ in freq_to_sweep: print("{} {}".format(cut_,freq_)) todo.append((args,outfolder,clusters_all[cut_][freq_],interactions,pdb,cut_,freq_)) #print(len(todo)) #sys.exit() #pool = Pool(processes=8) #pool.map(visualize_in_pymol,todo) #print(todo) #visualize_in_pymol((todo)) visualize_in_pymol(args,outfolder,clusters_all[cut][freq],interactions,pdb,cut,freq) #for cut_ in cuts_to_sweep: # for freq_ in freq_to_sweep: if 1==0: # Select clusters print("Running for {} {}".format(cut_,freq_)) # clusters_freq = clusters_all[cut_] # print(clusters_freq) clusters = clusters_all[cut_][freq_] #print(type(clusters_freq)) #print(clusters_freq.keys()) #with open("freq", 'wb') as f: # pickle.dump(list(clusters_freq.keys()), f) #print(type(freq)) #clusters = clusters_freq[80.0] # print(clusters_freq) # print(interactions) #ys.exit() # print(clusters) cmd.reinitialize() cmd.load(pdb) cmd.hide("everything") # cmd.show("ribbon") cmd.show("cartoon") # Create bindings and selections, and color them bond_connections(clusters, interactions) selections = select_clusters(clusters) colors = color_selections(selections) print(colors) # colors = color_selections([sele]) #cmd.color("gray70") #cmd.set("sphere_scale",0.75) cmd.space("cmyk") #cmd.set("ray_shadow","off") #cmd.bg_color("white") sele = "chain A and resi 131 and not name H*" cmd.show("sticks",sele) cmd.util.cnc(sele) #cmd.center("chain A") cmd.deselect() ### cut below here and paste into script ### cmd.set_view ([\ 0.185403526, -0.784912288, -0.591205537,\ -0.726189077, 0.295874894, -0.620551527,\ 0.662004888, 0.544381559, -0.515144050,\ -0.001714554, -0.001769811, -125.023078918,\ 30.330446243, 78.181671143, 146.038742065,\ 98.763908386, 151.776306152, -20.000000000] ) outfile = "{}cluster{}-{}.png".format(outfolder, cut, freq) if args.ray: cmd.save(outfile) ### cut above here and paste into script ### # Show clusters if shw is None: show_cluster(clusters) else: shw = [int(c) for c in shw.split(',')] for c in shw: show_cluster(clusters[c - 1]) cmd.save(outfile) cmd.quit()
def testSpace(self): cmd.space('pymol', 0.5) cmd.space('cmyk', 0.7) cmd.space('rgb')
# workspace settings cmd.bg_color("white") cmd.set("ray_opaque_background", "off") cmd.set("orthoscopic", 0) cmd.set("transparency", 0.5) cmd.set("dash_gap", 0) cmd.set("ray_trace_mode", 1) cmd.set("ray_texture", 2) cmd.set("antialias", 3) cmd.set("ambient", 0.5) cmd.set("spec_count", 5) cmd.set("shininess", 50) cmd.set("specular", 1) cmd.set("reflect", .1) cmd.space("cmyk") @cmd.extend def BallnStick(): cmd.color("gray30", "elem C") cmd.set("dash_gap", 0.01) cmd.set("dash_radius", 0.035) cmd.set("surface_quality", 2) cmd.set("surface_type", 4) #cmd.set("spec_reflect", 0) cmd.set("depth_cue", "off") preset.ball_and_stick(mode=1) # From https://github.com/rmera/ncipy/blob/master/nci.py
def testSpace(self): cmd.space('pymol', 0.5) cmd.space('cmyk', 0.7) cmd.space('rgb')
cmd.disable("surface") cmd.disable("protein") cmd.show("cartoon") cmd.set("cartoon_fancy_helices", 1) cmd.spectrum("count", selection="(protein)&e. c") #preset.publication("protein") cmd.show("spheres", "surface") cmd.clip("atoms", 5, "all") cmd.select("prot_int", "protein w. 5 of surface") cmd.disable('prot_int') cmd.select("surf_int", "surface w. 5 of protein") cmd.disable('surf_int') cmd.hide("everything", "surface") cmd.show("spheres", "surf_int") cmd.show("sticks", "((byres (prot_int))&(!(n;c,o,h|(n. n&!r. pro))))") cmd.space('cmyk') cmd.bg_color('black') cmd.select("BackBone", "name c+ca+o+n") cmd.select("SC_Carbon", "elem c and not BackBone") cmd.color("grey60", "SC_Carbon") cmd.disable('SC_Carbon') ############## OSTEOCALCIN STUFF ############### cmd.color("red", "name OE11") cmd.color("red", "name OE12") cmd.color("red", "name OE21") cmd.color("red", "name OE22") cmd.remove("resn cys and name hg") cmd.show("sticks", "resn cys and not BackBone") cmd.show("sticks", "resn cys and name CA+HA") ########################################### cmd.create("ProtObj", "protein")