def main(): try: parser = argparse.ArgumentParser(description='Structurally match 1 or more query protein structures to a specified PDB entry via Pychimera and UCSF Chimera.') parser.add_argument( '-p', '--pdb', action='store', help='The 4 character PDB ID for the reference structure to match against.') parser.add_argument( '-s', '--subjects', nargs='+', help='A folder of PDB files to match to the reference structure.') parser.add_argument( '-o', '--outdir', action='store', help='Output directory for RMSD and session files.') args = parser.parse_args() except: print("An exception occured with argument parsing. Check your provided options.") sys.exit(1) #TODO: add a switch for a reference PDB provided directly in case of a custom PDB. # Get reference structure from PDB print("\n") print("Beginning Chimera:") print("------------------") chimera.openModels.open(args.pdb,type="PDB") print("Opened reference structure: " + args.pdb) # Open model structures dirname = os.path.dirname(os.path.abspath(args.subjects[0])) for model in args.subjects: chimera.openModels.open(model, type="PDB") print("Successfully opened model: " + model) print("\n") print("Calculating RMSD (this may take a while):") print("-----------------------------------------") all_models = chimera.openModels.list(modelTypes=[chimera.Molecule]) ref = all_models[0] sims = all_models[1:] for atoms1, atoms2, rmsd, fullRmsd in match(CP_BEST, [ref, sims], defaults[MATRIX], "nw", defaults[GAP_OPEN], defaults[GAP_EXTEND]): ref_mol = atoms2[0].molecule sim_mol = atoms1[0].molecule print(ref_mol.name + "\t" + sim_mol.name + "\t" + str(rmsd)) with open("{}_RMSDs.tsv".format(os.path.join(dirname,os.path.basename(dirname))), 'w') as rmsd_fh: rmsd_fh.write(ref_mol.name + '\t' + sim_mol.name + '\t' + str(rmsd)) rc('save {0}_session.py'.format(os.path.join(dirname,os.path.basename(dirname)))) print('Session saved.') chimera.closeSession() rc('stop now') print('Chimera exited. Results are stored in:' + dirname) sys.exit(0)
def getComplex(fn): ## change HIE to HIS after tleap process and remove ACE and NHE ## Original change CYX to be CYS, not necessary for propka3.1 inpdb = fn + "_protein_proc8.pdb" outpdb1 = fn + "_protein_proc8_noCYX.pdb" cmd1 = """sed 's/HIE/HIS/g;s/HID/HIS/g;s/HIP/HIS/g;/ACE/d;/NHE/d' """ + inpdb + " > " + outpdb1 os.system(cmd1) ## read in ligand mol2, fix the atom naming by convert to ac ## then convert back to mol2 ## atom type should be sybyl since Chimera cannot recognize gaff ## (Dont use PDB, it will make mistake of element) inmol2 = fn + "_ligand.mol2" outmol2 = fn + "_ligand_fixed.mol2" outac = fn + "_ligand_fixed.ac" cmd = "antechamber -fi mol2 -fo ac -i " + inmol2 + " -o " + outac + " -at sybyl -dr no" os.system(cmd) cmd = "antechamber -fi ac -fo mol2 -i " + outac + " -o " + outmol2 + " -at sybyl -dr no" os.system(cmd) ## get complex of protein and ligand## outpdb2 = fn + "_complex_proc9.pdb" rc("open " + outpdb1) rc("open " + outmol2) rc("combine #0,1 modelID #2") rc("write format pdb #2 " + outpdb2) rc("close all")
def write_RTMatrices(self): """This is writing text files that will be used by Chimera to superpose the tatget with a hit - saved in the hit's folder""" for hit in self.third_filter_pdbs: my_path = os.path.abspath(os.curdir)+ "/hit_" + hit if not os.path.isdir(my_path): os.makedirs(my_path) os.chdir(my_path) matrix_file = 'RTMatrix_'+self.target_pdb.text+'_'+self.target_chain.text+'_against_'+hit+'.txt' f = open(matrix_file,'wb') # opening the model so know the numbering of models model1 = chimera.openModels.open(hit,type="PDB") if len(model1) == 1: f.write('Model 1.0') else: f.write('Model 1.1') # if there are more than 1 model (as in NMR structures, take the first one) rc('~open #1') for values in self.RTMatrices[hit]: f.write('\n\t') for val in values: f.write(str(val)+' ') f.close() # moving back up the directory os.chdir("..")
def define_tleap_topology(self, mol): """ Produce tleap topology from chimera input considering file format compatibility. Parameters ---------- mol: chimera.Molecule Chimera input mol Returns ------- ext: str Tleap topology input file extension tleap_topology_path: str Topology of chimera system used as tleap input for bonds and position. """ ext = None # Saving model if hasattr(mol, 'openedAs'): ext = mol.openedAs[1] if not ext: ext = 'pdb' if self.gui.var_rebuild_hydrogens.get(): rc('del element.H') input_name = '{}.{}'.format(self.gui.var_outputname.get(), ext) tleap_topology_path = os.path.join(self.tempdir, input_name) rc('write format {} {}.{} {}'.format(ext.lower(), mol.id, mol.subid, tleap_topology_path)) return ext.lower(), tleap_topology_path
def main(): directory = sys.argv[1] ligand = sys.argv[2] os.chdir(directory) replyobj.status("Processing " + ligand) # show what file we're working on rc("open " + ligand + ".pdb") rc("addcharge all") rc("write format mol2 0 " + ligand + ".mol2") rc("close all") rc("stop now") return
def addGly(fn, gapinch, delres): inpdb = fn + "_protein_proc4.pdb" outpdb = fn + "_protein_proc5.pdb" rc("open " + inpdb) gapid = [int(i) for i in gapinch] for i in gapid: cmd = "addaa gly," + str(i) + "A :" + str(i) rc(cmd) if len(delres) > 0: for i in delres: cmd = "del :" + str(int(i)) rc(cmd) rc("write format pdb #0 " + outpdb) rc("del #0")
def generate_surface(): """ Generates a surface onto the currently-loaded protein in Chimera. If a surface cannot be generated, return an exception. Arguments: None Requires: A protein must be opened in Chimera ( e.g. 'runCommand("open " + file_name))' must have already run It is also recommended that the loaded protein has already been cleaned with clean_protein() Returns: Void Effect: Attempts to split the current protein and then generates a surface for each part of the protein """ # Clear the reply log first r, r_text = read_reply_log() r.Clear() # Select and split the protein rc("select protein") rc("split") # Generate the surface # Note: allComponents false excludes bubbles from surface computation rc("surface allComponents false") # Check surface for computation failure r, r_text = read_reply_log() if "connected surface components" not in r_text: rc("close all") raise Exception("Surface computation failed; {}".format(r_text))
def show_residue(self, event, n, index): """Color selected residue Args: n, residue index in cif file index, residue index started from 0 """ # display the selected residues self.selected_residues.append( n) # append select residue to selected container command = 'select ' for s in self.selected_residues: command += ':' + str(s) + '.' + self.current_chain self.residue_labels[index].config(bg="SlateGray3", relief="sunken") rc(command) rc('color red sel') # display selectee residues and labeled residues in Chimera window command = 'select ' for r in self.color_labels: r = self.residues[r] command += ':' + str(r[0]) + '.' + self.current_chain for s in self.selected_residues: command += ':' + str(s) + '.' + self.current_chain rc(command) rc('show sel')
def open_target_in_Chimera(self): """Opens the target chain in chimera.""" rc("~open all") self.model0 = chimera.openModels.open(self.target_pdb.text,type="PDB") rc("sel #0:." + self.target_chain.text.lower()) rc("select invert sel") rc("delete sel")
def model(tmpl8, loops): # open template structure, and generate sequence rc('open ' + tmpl8) rc('sequence #0; wait') # MAV objects fmav = findMAVs() template = fmav[0] temp_seq = template.seqs[0] seq_name = tmpl8.split('/')[-1] # run modeller on alignment kw = {'licenseKey': 'MODELIRANJE'} ModellerBase.model(template, temp_seq, openModels.list(modelTypes=[Molecule]), '10', 1, 1, 0, veryFast=0, loopInfo=('', loops), **kw)
def open_mrc(dir, thresh=0.1): density_names = glob.glob(dir+"*.mrc") for d in density_names: model_num = d.replace(".mrc","").replace("med","").replace(cluster_dir,"") #print(model_num) replyobj.status("Processing " + d) # show what file we're working on rc("open " + model_num + " " + d ) rc("col " +colors["Med"+model_num][0] + " #" + model_num) if thresh == "byVol": volume = str(float(colors["Med"+model_num][2]) * 1.21) rc("vol #" + model_num + " encloseVolume " + volume) else: rc("vol #" + model_num + " level " + str(thresh)) rc("focus")
def display_pdb(pdb, trans): rc("open #0 " + pdb) for prot, dat in colors.iteritems(): model = prot.replace("Med","") if dat[1]: rc("transparency " + str(trans) + " #" + model) rc("col " + dat[0] + " #0:." + dat[1]) try: rc("ribscale med #0") except: print("Ribbon style not found")
def hfind(folder_path, done_list, pdb_list, hbout_path): # run let_chimera_hfind.py for the folder_path # after checking completed files for ciffile in os.listdir(folder_path): if '.cif' not in ciffile or ciffile[0:4] in done_list: continue if ciffile[0:4] + '.pdb' in pdb_list: rc("open " + pdb_path + ciffile[0:4] + '.pdb') else: rc("open " + folder_path + ciffile) output_file = hbout_path + ciffile.replace('cif', 'hb2') # ---------------------------------------------------------- # create copies in 5A around #0, find hbonds, and then # (later) choose bonds including #0 # ---------------------------------------------------------- rc("cryst #0 5 copies true") # create copies in 5A around model #0 rc("hbonds showDist true intraMol false intraRes false saveFile " + output_file) rc("close all")
def update(self): self.current_chain = self.variable.get() # udpate selected chain self.residue_labels = None self.selected_residues = None rc('preset apply interactive 1') rc('color blue') rc('~show') rc('~sel') self.clear_chain() # remove all residue buttons in frame2 self.add_residues() # add residue buttons for selected chain self.display_labels() self.add_table()
def test_include_dummies(element, file, charge, geom, dummies_xyz, Model=Model): # Right Values ANGLE = { 'tetrahedral': [ 60, ], 'square planar': [90, 45], 'square pyramid': [90, 45], 'octahedron': [90, 60, 45], } # Create metal instance metal, metal_class = create_metal_class(element=element, charge=charge, geom=geom, file=file) # Initialize variables metal_class.dummies_xyz = dummies_xyz Model.geometry = geom # Func to test Model.include_dummies(metal_class) # Selecting the included atoms number_of_dummies = len(dummies_xyz) atoms_to_select = ','.join( ['D' + str(i) for i in range(1, number_of_dummies + 1)]) rc("sel ::" + str(metal.residue.type) + '@' + atoms_to_select) dummies = chimera.selection.currentAtoms() # Eval Angles between them depending geometry for i in range(0, number_of_dummies - 2): angle = chimera.angle(dummies[i].labelCoord(), dummies[i + 1].labelCoord(), dummies[i + 2].labelCoord()) assert (int(round(angle)) in ANGLE[geom]) # Eval Bonds between Dummy&Metal center for i in range(0, number_of_dummies): bond = chimera.distance(dummies[i].labelCoord(), metal.labelCoord()) assert (abs(bond - 0.9) < 0.001)
def checkAllNoPowerfit(monomer_file,N,map_file, fits_dir): tupArr=get_principal_axes(map_file) symAxis= tupArr[0] center= tupArr[1] results=[] for nameFile in os.listdir(fits_dir): print nameFile for nameFile in os.listdir(fits_dir): if nameFile[:3]=="fit": numID=nameFile[4:-4] rc("close all") rotation,translation= cyclic_shift(monomer_file,nameFile,fits_dir,N,symAxis,center) score=get_score(map_file,N,3) results.append([numID,score, rotation, translation]) #sort the fits according to its score, so that the best score is first(place 0) sortedResults= sorted(results, key= lambda item:item[1], reverse= True) rc("close all") output(sortedResults) print "Done"
def get_principal_axes(map_file): """ Recives a map file, returns it's three axes and the center of it. The return value is: [axis 1, axis 2, axis 3, center] Each component is a tuple of three numbers """ rc("open "+map_file) rc("measure inertia #0") saveReplyLog("log.txt") log= open("log.txt", 'r') for line in log: if "v1" in line: lineVec1=line.split() elif "v2" in line: lineVec2=line.split() elif "v3" in line: lineVec3=line.split() elif "center" in line: centerLine=line.split() break rc("close all") for i in range(2,5): lineVec1[i]=float(lineVec1[i]) lineVec2[i]=float(lineVec2[i]) lineVec3[i]=float(lineVec3[i]) centerLine[i]=float(centerLine[i]) vec1= (lineVec1[2], lineVec1[3], lineVec1[4]) vec2= (lineVec2[2], lineVec2[3], lineVec2[4]) vec3= (lineVec3[2], lineVec3[3], lineVec3[4]) centerTup= (centerLine[2], centerLine[3], centerLine[4]) return [vec1, vec2, vec3, centerTup]
def model(trgt, tmpl8, od): # open target sequence rc('open ' + trgt) # open template structure, and generate sequence rc('open ' + tmpl8) rc('sequence #0') # MAV objects fmav = findMAVs() target, template = fmav tar_seq = target.seqs[0] temp_seq = copy(template.seqs[0]) seq_name = tmpl8.split('/')[-1] # align sequences # get template secondary structure matrix nb = Pmw.NoteBook() structPage = nb.add("From Structure") ssParams = SSParams(structPage, template.prefs) kw = {'ssMatrix': ssParams.getMatrix()} # generalize these vars later. tired of hacking rn. # match target fasta sequence to template pdb sequence target.alignSeq(temp_seq, displayName=seq_name, matrix=template.prefs[MATRIX], gapOpenStrand=-18.0, scoreGap=-1, scoreGapOpen=-12, gapOpenHelix=-18.0, gapOpenOther=-6.0, gapChar='.', guideSeqs=None, ssFraction=0.3, **kw) # run modeller on alignment kw = {'licenseKey': 'MODELIRANJE'} ModellerBase.model(target, tar_seq, openModels.list(modelTypes=[Molecule]), '5', 1, 1, 0, veryFast=0, **kw)
def main(monomer_file,N,map_file): # rc("cd /home/ofri/stroctura") #(axis,center)=get_principal_axes(map_file,N) tupArr=get_principal_axes(map_file,N) symAxis= tupArr[0] center= tupArr[1] # powerfit_results=get_powerfit_results(map_file,3,monomer_file) fitsDirPath= monomer_file[:-4]+"PF" #fitsDirPath= "4DYCPF" results=[] for nameFile in os.listdir(fitsDirPath): if nameFile[:3]=="fit": numID=nameFile[4:-4] rc("close all") rc("cd "+ fitsDirPath) cyclic_shift(nameFile,N,symAxis,center) #fileProtein= "/cycledFits/"+numID+".pdb" rc("cd ..") score=get_score(map_file,N,10) results.append([numID,score]) #sort the fits according to its score, so that the best score is first(place 0) sorted(results, key= lambda item:item[1], reverse= True) print results
def open_mrc(dir, thresh=0.1): density_names = glob.glob(dir+"*.mrc") for model_num,d in enumerate(density_names): print "A" model_name = d.replace(".mrc","").replace("med","").replace(dir,"") print "B" print(d) print "C" replyobj.status("Processing " + d) # show what file we're working on print "D" rc("open " + d ) print "E" rc("col " +colors[model_name][0] + " #" + str(model_num)) print "F" if thresh == "byVol": volume = str(float(colors[model_name][2]) * 1.21) rc("vol #" + str(model_num) + " encloseVolume " + volume) else: rc("vol #" + str(model_num) + " level " + str(thresh)) rc("focus")
def Apply(self): sim_data = NBSimulationData() # initialize simulation data object sim_data.load_all_sim_data_plus(self.top_file, self.dat_file) # convert ox simulation data to pdb format pdb_str = get_pdb_str(sim_data) model_num = self.get_model_num() self.ox_simdata_by_model_num[model_num] = sim_data com_list = get_chimera_commands(sim_data, model_num) ts = self.make_timestamp() base_filename = self.make_base_filename(model_num, ts) base_of_op = self.get_dir_name() # (where to store tmp files on windows?) if sys.platform.startswith('linux'): base_filename = os.path.join(base_of_op, base_filename) pdb_filename = base_filename + '.pdb' pdb = open(pdb_filename, 'w') pdb.write(pdb_str) pdb.close() com_filename = base_filename + '.com' com_file = open(com_filename, 'w') for c in com_list: print >> com_file, c com_file.close() from chimera import runCommand as rc rc("open " + pdb_filename) rc("open " + com_filename)
def main(): """Calculate secondary structure proportions via Pychimera -> Chimera -> DSSP""" args = get_args() #### Calculating #### if args.outfile is None: args.outfile = os.path.splitext(args.infile)[0] + '.ss' chimera.openModels.open(args.infile, type="PDB") print( 'Secondary Structure Proportions (AA Length | Helix % | Sheet % | Other %)' ) with open(args.outfile, "w") as outputFile: for mol in openModels.list(modelTypes=[Molecule]): helix_fract = len([r for r in mol.residues if r.isHelix]) / float( len(mol.residues)) sheet_fract = len([r for r in mol.residues if r.isSheet]) / float( len(mol.residues)) other_fract = (1 - (helix_fract + sheet_fract)) helix_perc = helix_fract * 100 sheet_perc = sheet_fract * 100 other_perc = other_fract * 100 if not args.exact: helix_perc = int(round(helix_perc)) sheet_perc = int(round(sheet_perc)) other_perc = int(round(other_perc)) print(args.infile + "\t" + str(len(mol.residues)) + "\t" + str(helix_perc) + "\t" + str(sheet_perc) + "\t" + str(other_perc)) outputFile.write(args.infile + "\t" + str(len(mol.residues)) + '\t' + str(helix_perc) + "\t" + str(sheet_perc) + "\t" + str(other_perc) + "\n") chimera.closeSession() print("Chimera exited. All done. All results are in: " + args.outfile) rc('stop now') sys.exit(0)
def cyclic_shift(monomer_file,N,symetry_axis = (0,0,1) ,symetry_center = (0,0,0)): os.system("mkdir cycledFits") for i in range(N): print monomer_file rc("open " + monomer_file) if i == 0: continue command = get_turn_command(i*360/N,symetry_axis,symetry_center,i) if DEBUG: print command rc(command) #FIX filePath= "after"+monomer_file rc("combine #0,#1 close 1") print "write format pdb #"+ str(N) + " " + filePath rc("write format pdb #"+ str(N) + " " + filePath) #saves the protein to the new folder with appropriate name
def main(monomer_file,N,map_file): tupArr=get_principal_axes(map_file,N) symAxis= tupArr[0] center= tupArr[1] powerfit_results=get_powerfit_results(map_file,3,monomer_file) fitsDirPath= monomer_file[:-4]+"PF" results=[] for nameFile in os.listdir(fitsDirPath): if nameFile[:3]=="fit": numID=nameFile[4:-4] rc("close all") rotation,translation= cyclic_shift(monomer_file,nameFile,fits_dir,N,symAxis,center) score=get_score(map_file,N,3) results.append([numID,score, rotation, translation]) #should be zAngle,yAngle,xAngle=mat2angles(rotation) #results.append([numID,score, [xAngle,yAngle,zAngle], translation]) #sort the fits according to its score, so that the best score is first(place 0) sortedResults= sorted(results, key= lambda item:item[1], reverse= True) rc("close all") output(sortedResults) print "Done"
def runSegment(map_file): """Segments the map from the given path and saves the results in the directory segmentationsDir. """ chimeraMap = VolumeViewer.open_volume_file(map_file)[0] #opens the map dialog = SD.Volume_Segmentation_Dialog() #creates a segmentor object trsh = dialog.Segment() #segments the map #code for saving the results dmap = dialog.SegmentationMap() smod = dialog.CurrentSegmentation() regs = smod.selected_regions() if len(regs)==0 : regs = smod.regions dir = os.path.dirname ( dmap.data.path ) fprefix = os.path.splitext ( dmap.name ) [0] fname = fprefix + "_region_%d.mrc" path = "segmentationsDir/"+fname os.system("rm -r segmentationsDir ; mkdir segmentationsDir") for reg in regs : #save each result in a different file dialog.SaveRegsToMRC ( [reg], dmap, path % (reg.rid,) ) #end of code for saving the results rc("close all")
def run_chimera(pose_path, outpath, id_list): # ---------------------------------------------------------- # import # ---------------------------------------------------------- import os from chimera import runCommand as rc # ---------------------------------------------------------- # constants # ------------------hbb---------------------------------------- path = '/Users/tkimura/Desktop/t3_mnt/zdock/' # ---------------------------------------------------------- # make a done_list and to_do_list # ---------------------------------------------------------- done_list = [] for dir in os.listdir(outpath): if len(os.listdir(outpath + dir)) > 3590: done_list.append(dir) # ---------------------------------------------------------- # main # ---------------------------------------------------------- os.chdir(path) for dir in os.listdir(pose_path): if dir in done_list or dir not in id_list: continue for file in os.listdir(pose_path + dir): rc("open " + pose_path + dir + '/' + file) output_file = outpath + dir + '/' + file.replace('pdb', 'hb2') if not os.path.isdir(outpath + dir): os.mkdir(outpath + dir) try: rc("hbonds namingStyle simples showDist true intraMol false intraRes false saveFile " + output_file) rc("close all") except ValueError as e: print('VALUEERROR!!!!!!!!!!!') print(e) except TypeError: print('TypeError!!!!') rc("close all")
def get_score(map_file, N, density): #We make a density map out of the structure of the protein we made in cycle_shift rc("molmap #"+ str(N) + " " + str(density)) rc("open " + str(map_file)) rc("measure correlation #0 #" +str(N)) #Assumption: the cycled protein map is model #0 and the map we just opened is model #1 #again, reading from reply log saveReplyLog("log.txt") log= open("log.txt", 'r') for line in log: if "Correlation" in line: corrLine=line.split() ind= corrLine.index("=") score= float((corrLine[ind+1])[:-1]) score*=1000 #in order to make the score nicer than a number between -1 to 1. return score
def get_score(map_file, N, density): """ Given a map, the number of symm and the density, computes and returns the correlation between the original map and the current tested model. Assums that the current model is open. """ rc("molmap #"+str(N)+" " + str(density)) rc("open " + str(map_file)) rc("measure correlation #0 #"+str(N)) #Assumption: the cycled protein map is model #0 and the map we just opened is model #1 #again, reading from reply log saveReplyLog("log.txt") log= open("log.txt", 'r') for line in log: if "Correlation" in line: corrLine=line.split() ind= corrLine.index("=") score= float((corrLine[ind+1])[:-1]) score*=1000 #in order to make the score nicer than a number between -1 to 1. return score
def get_principal_axes(map_file): rc("open "+map_file) rc("measure inertia #0") saveReplyLog("log.txt") log= open("log.txt", 'r') for line in log: if "v3" in line: symVec=line.split() elif "center" in line: centerLine=line.split() break rc("close all") for i in range(2,5): symVec[i]=float(symVec[i]) centerLine[i]=float(centerLine[i]) vecTup= (symVec[2], symVec[3], symVec[4]) centerTup= (centerLine[2], centerLine[3], centerLine[4]) return [vecTup, centerTup] #array of the two tupples
def main(monomer_file,N,map_file,density, scoreThrd = 900): #close previous models and clear reply log rc("close all") clearReplyLog() #calculates symm axes and center tupArr=get_principal_axes(map_file) axes=tupArr[0:3] center= tupArr[3] #all closed #gets segmentation runSegment(map_file) #all closed tempScore=[0,0,0] results=[] fitToSegment(monomer_file) fits_dir="fitDir" for fits in os.listdir(fits_dir): if fits[-4:]!=".pdb": continue numID=fits for i in range (3): cyclic_shift(fits,fits_dir,N,axes[i],center,i+1) tempScore[i]=get_score(map_file,N,density) rc("close all") maxIndex=numpy.argmax(tempScore) rotationsMat,translationArray= cyclicForOutput(monomer_file,fits,fits_dir,N,axes[maxIndex],center) results.append([numID,tempScore[maxIndex], rotationsMat, translationArray, maxIndex]) if tempScore[maxIndex] >= scoreThrd: break #sort the fits according to its score, so that the best score is first(place 0) sortedResults= sorted(results, key= lambda item:item[1], reverse= True) rc("close session") output(sortedResults) print "Done"
else: res = 8 resstr = str(res) cmd = "x3d2stl -c -r "+resstr +" -o "+root_name +".stl" +" < " +root_name +".x3d" os.system( cmd ) # rc("export format stl " + root_name) os.chdir(".") # open the file try: PubChem_code except NameError: input_name, ext = os.path.splitext(infile) rc("open " + infile) else: input_name = PubChem_code rc("open " + infile) # Setup the lighting rc("windowsize 512 512") rc("background solid white") rc("lighting mode three-point") rc("lighting brightness 1.0") rc("lighting contrast 0.85") rc("lighting ratio 2.25") rc("lighting sharpness 62") rc("lighting reflectivity 0.3") rc("lighting key direction 0 0 1") rc("lighting fill direction 0.8 0.3 .2")
import os from chimera import runCommand as rc from chimera import replyobj, openModels, Molecule from WriteMol2 import writeMol2 os.chdir(".") rc("open /gpcr/users/daranda/doctorat/GPCR_simulations/Ligands/97Y/97Y.mol2") rc("delete element.H") rc("addh") rc("setattr m name 97Y") writeMol2( openModels.list(modelTypes=[Molecule]), "/gpcr/users/daranda/doctorat/GPCR_simulations/Ligands/97Y/97Y.mol2")
original_map = 'emdbID:' + emdb_id fitted_coords = 'pdbID:' + pdb_id ## output filenames # blurred map blurred_map = 'emd_' + emdb_id + '_blurred.mrc' # map from all fitted coordinates fitted_coords_map = 'emd_' + emdb_id + '_from_pdb.mrc' # map from fitted protein coordinates fitted_coords_map_protein = 'emd_' + emdb_id + '_from_pdb_prot.mrc' # map from fitted nucleic acid coordinates fitted_coords_map_na = 'emd_' + emdb_id + '_from_pdb_na.mrc' ### Chimera commands # note that #0 etc refer to model IDs and must be kept consistent rc("open 0 %s" % (original_map)) # chimera defaults to step 4, which confuses the later onGrid rc("volume #0 step 1") ## NB could use "step" to get smaller map file, or use "vop resample" which interpolates ## rather than selecting data points print("Map downloaded, now blurring") ### blur/sharpen map # Go into Chimera # Use Gaussian blurring in Chimera with e.g. sd 1.0 # (Volume Viewer -> Tools -> Volume Filter) # beta-gal tested with unblurred and blurred maps, and latter slightly better # no robust way of estimating required blurring rc("vop gaussian #0 sd %f modelId 5" % (sd_blurring)) rc("volume #5 save %s" % (blurred_map))
import os from chimera import runCommand as rc from chimera import replyobj,openModels,Molecule from WriteMol2 import writeMol2 os.chdir(".") rc("open /gpcr/users/daranda/doctorat/GPCR_simulations/Ligands/A4R/A4R.mol2") rc("addh") rc("setattr m name A4R") writeMol2(openModels.list(modelTypes=[Molecule]), "/gpcr/users/daranda/doctorat/GPCR_simulations/Ligands/A4R/A4R.mol2")
os.environ['AMBERHOME'] = '/Users/alexeyshaytan/soft/amber12' # change to folder with data files seq_i='ATCAATATCCACCTGCAGATACTACCAAAAGTGTATTTGGAAACTGCTCCATCAAGAGGCATGTTCAGCTGGAATCCAGCTGAACATGCCTTTTGATGGAGCAGTTTCCAAATACACTTTTGGTAGTATCTGCAGGTGGATATTGAT' #Position of the last base on I strand that is curled in DNA for str_post in range(-15,70): #str_post=-1 str_seq=seq_i[73-18:str_post+73+1] os.system('./gen_dna.x %s dna.pdb'%str_seq) rc('open 1kx5.pdb') rc('delete #0:HOH') rc('delete #0:CL') rc('delete #0:-73-%d.I,%d-73.J'%(str_post-1,(str_post-1)*(-1))) rc('delete #0:MN') rc('open dna.pdb') rc('resrenumber -18 #1:.I') rc('resrenumber %d #1:.J'%(str_post*(-1))) rc('write format pdb #1 dna.pdb') rc('open 2o5i_renum.pdb') rc('delete #2:HOH') rc('delete #2:MN') rc('delete #2:ZN.J')
import os from chimera import runCommand as rc from chimera import replyobj, openModels, Molecule from WriteMol2 import writeMol2 os.chdir(".") rc("open /gpcr/users/daranda/doctorat/GPCR_simulations/toppar/mod_residues/9DK/9DK.pdb" ) rc("delete element.H") rc("addh") rc("setattr m name '9DK'") writeMol2( openModels.list(modelTypes=[Molecule]), "/gpcr/users/daranda/doctorat/GPCR_simulations/toppar/mod_residues/9DK/9DK_chim.mol2" )
def highlightMutation(filename, protein_num, hbond, namesel): import csv # read a csv file f = open(filename, 'rU') data = csv.reader(f) # List: (list(pdbId), list(residue #), list(label) (the value) pdbIdL = [] residueL = [] labelL = [] # add elements to the lists and the set for row in data: pdbIdL.append(row[2]) residueL.append(row[7]) labelL.append(row[4]) # Set: pick all the unique values pdbIds = sorted(set(pdbIdL), key=pdbIdL.index) # clean up the data pdbIds.remove('PDB ID') pdbIdL.remove('PDB ID') residueL.remove('PDB seq number') labelL.remove('mutation') dataSet = [pdbIdL, residueL, labelL] f.close() numbers = [] for i in range(len(list(dataSet))): numbers.append(0) for item in dataSet[0]: if item == list(pdbIds)[i]: numbers[i] += 1 # execute chimera commands from chimera import runCommand as rc rc('close all') # openc = 'open biounitID:' + list(pdbIds)[protein_num] + ".1" openc = "open " + list(pdbIds)[protein_num] rc(openc) rc('~display; ribbon; background solid black; color #c71caaaa84bd,r') colorc = [] labelc = [] nameselc = [] selectString = "sel:" #labelc2 = [] # which index to start slicing from? def start(p): start = 0 for i in range(p): start += numbers[i] return start begin = start(protein_num) end = begin + numbers[protein_num] for i in range(begin, end): resNum = dataSet[1][i] label = dataSet[2][i] # label2 = "" # for c in label: # from Ilabel import * # letter = Character(letter, c, fontName='Sans Serif', size=50) # label2.append(letter) # labelc2.append(('setattr r label "' + label2 + '" :' + resNum) colorc.append('color red :' + resNum) labelc.append('setattr r label "' + label + '" :' + resNum) nameselc.append('sel: ' + resNum + '; namesel ' + label) if i == end - 1: selectString += resNum else: selectString += resNum + "," # clear all the named selections for i in range(len(dataSet[2])): try: rc("~namesel " + dataSet[2][i]) except: pass # execution of the commands for i in range(len(colorc)): rc(colorc[i]) rc(labelc[i]) if namesel == 1: rc(nameselc[i]) # show any H-bonds to mutant positions rc(selectString) if hbond == 1: rc('hbond selRestrict any reveal true') rc('color byelement') rc('focus') rc('~sel')
import os from chimera import runCommand as rc from chimera import replyobj, openModels, Molecule from WriteMol2 import writeMol2 os.chdir(".") rc("open /gpcr/users/daranda/doctorat/GPCR_simulations/Ligands/8EM/8EM.mol2") rc("addh") rc("setattr m name 8EM") writeMol2( openModels.list(modelTypes=[Molecule]), "/gpcr/users/daranda/doctorat/GPCR_simulations/Ligands/8EM/8EM.mol2")
from BuildStructure import placePeptide from chimera import runCommand as rc aa = "H" # Build a sequence placePeptide(aa, [(-50, 70)] * len(aa), model="peptide") # Add hydrogens automatically rc("addh") # Align so the CA-CB bond is going into the page rc("align @CA @N") rc("set fieldOfView 14.5227") rc("set scale 1.0") rc("set projection orthographic") rc("windowsize 800 600") # Color and highlight rc("color grey") rc("repr stick") rc("shape sphere radius 0.5 center @CA color red") rc("shape sphere radius 0.5 center @C color blue") rc("shape sphere radius 0.5 center @N color green") rc("shape sphere radius 0.5 center @CA color orange") # Save rc("copy file HIS-omega.png supersample 3") # rc("close all")
###################################################################################################################################### if __name__ == "__main__": args = cmdlineparse() from chimera import runCommand as rc from chimera.selection import currentResidues resname_states_dict = {"GLU": ["GLU", "GLH"], "ASP": ["ASP", "ASH"]} if args.FLIP_COOH: resname_states_dict["GLU"] = ["GLU", "GLH1", "GLH2"] resname_states_dict["ASP"] = ["ASP", "ASH1", "ASH2"] rc("open %s" % args.RECEPTOR) # load the receptor rc("open %s" % args.LIGAND) # load the ligand if args.DOCKPREP: import chimera from Addions import initiateAddions from DockPrep import prep from AddCharge import estimateFormalCharge models = chimera.openModels.list(modelTypes=[chimera.Molecule]) print( "Preparing receptor for docking and calculating ligand AM1 charges (may be slow)." ) prep(models, nogui=True, method='am1') # Select the residues to be protonated if args.RADIUS > 0:
#------------------------------------------- #Written by Guangfeng Zhou #Dr.Voelz Lab #Chemistry Department #Temple University #October,25,2012 #------------------------------------------- import os, sys import chimera from chimera import runCommand as rc for i in range(100): xyz = 'outputs/%d.xyz' % i pdb = xyz.replace('.xyz', '.pdb') rc("open %s" % xyz) rc("write format pdb 0 %s" % pdb) rc("close 0")
def export_scene(root): root_name = input_name + "-" + root png_name = root_name + ".png" rc("copy file " + png_name + " width 512 height 512 supersample 3") rc("export format x3d " + root_name) os.chdir(".") # open the file try: PDBcode except NameError: rc("open " + infile) input_name, ext = os.path.splitext(infile) else: try: fetch_name = "biounitID:" + PDBcode + ".1" rc("open " + fetch_name) except: try: fetch_name = "cifID:" + PDBcode rc("open " + fetch_name) #Next 3 lines for getting rid of multiple NMR structures numSubmodels = len(openModels.list(modelTypes=[Molecule])) if numSubmodels > 1: rc("close #0.2-" + str(numSubmodels)) except: fetch_name = "pdbID:" + PDBcode
#!/usr/bin/env python # -*- coding: UTF-8 -*- import os from chimera import * from chimera import runCommand as rc from chimera.tkgui import saveReplyLog as rl path = "C:/Users/pukma/Desktop/DOCKING/11A_neuraminidase_a/0_RMSD" ref = '1a4q' model = 'pose2' ligand = 'DPC' os.chdir(path + '/') currentPose = 0 replyobj.status("Processing " + model + ".pdb") rc("open #0 " + ref + ".pdb") rc("open #1 " + model + ".pdb") rc("matchmaker #0 #1 ") RMSD = rc("rmsd #1:" + ligand + " #0:" + ligand) rl('I.txt')
def export_wrl(root): root_name = input_name + "-" + root rc("export format vrml " + root_name)
def processFiles(abname,pdb,ab_dx,imagedir,rootdir): # base_dir = os.getcwd() # files = os.listdir(base_dir) # for x in files: # --ff=AMBER --apbs-input --nodebump --verbose #subprocess.call(["pdb2pqr","--ff","AMBER","--apbs-input","--nodebump",x,x[:-4]+'.pqr']) #subprocess.call(["apbs",x[:-4]+'.in']) # Chimera commands to color by electrostatic potential # surface # scolor #0 volume #2 perPixel true offset 1.4 cmap -5,red:0,white:5,blue # colorkey .8,.04 .98,.05 -5 red 0 white 5 blue #if x[-4:] == '.pdb': #ab = base_dir+'/'+x #ab_dx = base_dir+'/'+x[:-4]+'.pqr.dx' replyobj.status("Beginning to process ab") rc("open " + pdb) rc("open " + ab_dx) rc("surface") rc("color darkgrey") rc("set dcColor black") rc("background solid white") rc("scolor #0 volume #1 perPixel true offset 1.4 cmap -5,red:0,white:5,blue") #rc("colorkey 0.8,0.4 0.98,0.05 -5 red 0 white 5 blue") rc("colorkey 0.8,0.08 0.98,0.05 -5 red 0 white 5 blue") rc("turn 0,0,1 -75") rc("windowsize 1050 700") rc("focus") png_name = abname+"_left.png" replyobj.status("Writing PNG file") rc("cd "+imagedir) rc("copy file "+png_name+" supersample 3") rc("turn 0,1,0 190") rc("focus") png_name = abname+"_right.png" replyobj.status("Writing PNG file") rc("copy file "+png_name+" supersample 3") rc("turn 1,0,0 90") rc("focus") png_name = abname+"_top.png" replyobj.status("Writing PNG file") rc("copy file "+png_name+" supersample 3") rc("reset") rc("close session") replyobj.status("Closing session") rc("close all") replyobj.status("Finished processing...exiting") sys.exit()
def show_em(em_file): rc("open #100 " + em_file) rc("vol #100 level 0.35 style mesh")
if colorType == "wg": min_color = "white" max_color = "green" if colorType == "wo": min_color = "white" max_color = "orange" mid_color = "" mid_value = "" if attr == "delta" or attr == "deltaKL": mid_color = "white" mid_value = (float(min_value) + float(max_value)) / 2 rep_key = "" mol = chimera.openModels.open(pdb_file)[0] # Opens molecule rc("open md:%s.meta" % (rID)) # Run Preliminary Chimera Commands rc("windowsize 1500 1080") rc("lighting reflectivity 0") rc("lighting brightness .85") rc("lighting sharpness 10") rc("center #%s:.A" % (model)) rc("scale 0.4") rc("~ribbon") #rc("~surface") rc("~display") rc("background solid black") if rep == "surface": rc("surface #%s" % (model)) rep_key = "s"
def view2_rotate(view2_matrix): rc("matrixset " + view2_matrix) rc("focus")
#!/usr/bin/env python # -*- coding: UTF-8 -*- import os from chimera import * from chimera import runCommand as rc from chimera.tkgui import saveReplyLog as rl ref = 'OHT' best_score = 'pose9' ligand = 'OHT' rc("open #0 " + ref + ".pdb") rc("open #1 " + best_score + ".pdb") #rc("matchmaker #0 #1 ") rc('match #0 #1') RMSD = rc("rmsd #1:LIG #0:" + ligand)
def save_img(file_name): rc("windowsize 1024 768") rc("focus") rc("copy file " + file_name + ".png" + " width 3072" + " height 2304" + " supersample 3" + " raytrace")
import os from chimera import runCommand as rc from chimera import replyobj, openModels, Molecule from WriteMol2 import writeMol2 os.chdir(".") rc("open /gpcr/users/daranda/doctorat/GPCR_simulations/Ligands/SNP/SNP.mol2") rc("addh") rc("setattr m name SNP") writeMol2( openModels.list(modelTypes=[Molecule]), "/gpcr/users/daranda/doctorat/GPCR_simulations/Ligands/SNP/SNP.mol2")
def set_background(background): rc("background solid " + background)
def write_protonated_structure(protonations): global residues, args id2state = {} pdb = args.RECEPTOR.replace(".pdb", "") for rstate in protonations: state, resid = rstate.split('_') id2state[resid] = state if args.FLIP_COOH: state = state.replace("1", "a").replace("2", "b") pdb += "_%s%s" % (state, resid.replace(".", "")) pdb += ".pdb" # Alter the protonation states ASH_GLH_rstates = [] for r in residues: try: r.type = id2state[str(r.id)][:3] # works for both ASH and ASH1 if id2state[str(r.id)][:3] in ["ASH", "GLH"]: ASH_GLH_rstates.append((str(r.id), id2state[str(r.id)])) except KeyError: continue if args.FLIP_COOH: for resid, state in ASH_GLH_rstates: if state == 'GLH1': # rename the atoms, because by default proton goes to O[DE]2 but we want it in O[DE]1 rc("setattr a name XX :%s@OE1" % resid) rc("setattr a name OE1 :%s@OE2" % resid) rc("setattr a name OE2 :%s@XX" % resid) if state == 'ASH1': # rename the atoms, because by default proton goes to O[DE]2 but we want it in O[DE]1 rc("setattr a name XX :%s@OD1" % resid) rc("setattr a name OD1 :%s@OD2" % resid) rc("setattr a name OD2 :%s@XX" % resid) # Write the structure rc("del H") rc("addh") if args.DOCKPREP: # prepend net charges to the pdb file pdb = pdb.replace(".pdb", "_complex.pdb") rc("combine #0,1 name complex modelId 2") rc("write format pdb #2 %s" % pdb) rc("delete #2") models = chimera.openModels.list(modelTypes=[chimera.Molecule]) rc( "addcharge std spec #0" ) # re-add ff14SB charges to the protonated receptor only (the ligand protonation did not change) rec_charge = estimateFormalCharge(models[0].atoms) lig_charge = estimateFormalCharge(models[1].atoms) # Neutralize system net_charge = rec_charge + lig_charge if net_charge < 0: initiateAddions(q, "Na+", "neutralize", chimera.replyobj.status) elif net_charge > 0: initiateAddions(models, "Cl-", "neutralize", chimera.replyobj.status) with open(pdb, "r+") as f: s = f.read() f.seek(0) f.write("# receptor net charge = %i\n# ligand net charge = %i\n" % (-lig_charge, lig_charge)) # after system neutralization f.write(s) else: rc("write format pdb #0 %s" % pdb) if args.FLIP_COOH: # restore the original O[DE] names for resid, state in ASH_GLH_rstates: if state == 'GLH1': # rename the atoms, because by default proton goes to O[DE]2 but we want it in O[DE]1 rc("setattr a name XX :%s@OE1" % resid) rc("setattr a name OE1 :%s@OE2" % resid) rc("setattr a name OE2 :%s@XX" % resid) if state == 'ASH1': # rename the atoms, because by default proton goes to O[DE]2 but we want it in O[DE]1 rc("setattr a name XX :%s@OD1" % resid) rc("setattr a name OD1 :%s@OD2" % resid) rc("setattr a name OD2 :%s@XX" % resid)
else: assert False, "unhandled options" def export_scene(root): root_name = input_name + "-" + root png_name = root_name + ".png" rc("copy file " + png_name + " width 512 height 512 supersample 3") rc("export format x3d " + root_name) os.chdir(".") # open the file try: EMDBcode except NameError: rc("open " + infile) input_name, ext = os.path.splitext(infile) else: fetch_name = "emdbID:" + EMDBcode rc("open " + fetch_name) input_name = EMDBcode # Setup the lighting rc("windowsize 512 512") rc("background solid white") rc("lighting mode three-point") rc("lighting brightness 1.0") rc("lighting contrast 0.85") rc("lighting ratio 2.25") rc("lighting sharpness 62") rc("lighting reflectivity 0.3")
distances = {'H3':{},'H4':{},'H2A':{},'H2B':{}} # holds the distance information distheads = {'H3':[],'H4':[],'H2A':[],'H2B':[]} # holds the header information for distances ### Chimera commands ############################################################################ ### opens PDB molecule and stores atom, bond, residue info pdb = chimera.openModels.open('1kx5.pdb') mol = pdb[0] atomlist = mol.atoms bondlist = mol.bonds reslist = mol.residues ### Cosmetics of the nucleosome structure rc('col cornflower blue :.A-H') rc('~disp solvent') rc('~disp ions') rc('nuc side ladder :.I-J') print 'Sites to include in distance analysis' print 'Histone\tResidue\tMutations' ### Measures distances for each mutation for _hist in protmutcount: _chains = hist2chain[_hist.upper()] # chain of current histone for _aa in range(len(protmutcount[_hist])): # current amino acid _muts = protmutcount[_hist][_aa] # current number of mutations if _muts < cutoffs[_hist]: continue # skips residues with mutations fewer than cutoff _aa += 1 if _hist == 'H2B': _aapdb = _aa - 3 # corrects for -3 numbering in H2B for 1kx5 structure else: _aapdb = _aa
def callChimeraGP120(pri_epitope,sec_epitope,fn,dirname,rootdir): base_dir = os.getcwd() trimer = rootdir+'/gp120CPHmodel_trimer.pdb' monomer = rootdir+'/gp120_CPHModel.pdb' print "trimer path= ",trimer print "monomer path= ",monomer print "pri_epitope = ",pri_epitope print "sec_epitope = ",sec_epitope # Create 1st trimer image replyobj.status("Processing trimer") # show what file we're working on rc("open " + trimer) rc("preset apply publication 3") # make everything look nice rc("turn 0,0,1 15") # tweak the rotation a bit rc("focus") # center/zoom rc("split #0") # split model into individually addressable sub models rc("surf") # generate surface rc("color dark gray") rc("surftransp 70") # make the surface a little bit see-through rc("focus") # readjust zoom # Color epitopes if pri_epitope != 'No Result' and pri_epitope != '': print "@@@@@@@@@@ cmd = color red #0.1 :",pri_epitope rc("color red #0.1 :"+pri_epitope) rc("color red #0.2 :"+pri_epitope) rc("color red #0.3 :"+pri_epitope) if sec_epitope != 'No Result' and sec_epitope != '': print "@@@@@@@@@@ cmd = color blue #0.1 :",sec_epitope rc("color blue #0.1 :"+sec_epitope) rc("color blue #0.2 :"+sec_epitope) rc("color blue #0.3 :"+sec_epitope) # save image to a file that ends in .png rather than .pdb rc("cd "+dirname) rc("windowsize 1050 700") # 2100 1400 png_name = fn + ".trimer-top.png" rc("copy file " + png_name + " supersample 3") # Rotate trimer for second image rc("turn 0,1,0 90") rc("turn 0,0,1 90") rc("turn 0,1,0 30") rc("~modeldisp #0.3") # hide the third molec rc("focus") rc("color light blue #0.1") # color one chain light blue for contrast if pri_epitope != 'No Result' and pri_epitope != '': rc("color red #0.1 :"+pri_epitope) if sec_epitope != 'No Result' and sec_epitope != '': rc("color blue #0.1 :"+sec_epitope) png_name = fn+".trimer-side.png" rc("windowsize 1050 700") rc("copy file " + png_name + " supersample 3") rc("reset") rc("close session") # Open monomer model rc("open "+monomer) rc("turn 1,0,0 125") rc("preset apply publication 3") # make everything look nice rc('color tan') rc("surface") rc("surftransp 70") rc("focus") if pri_epitope != 'No Result' and pri_epitope != '': rc("color red #0 :"+pri_epitope) if sec_epitope != 'No Result' and sec_epitope != '': rc("color blue #0 :"+sec_epitope) png_name = fn+".front-side.png" rc("windowsize 1050 700") rc("copy file " + png_name + " supersample 3") rc("turn 0,1,0 180") png_name = fn+".back-side.png" rc("windowsize 1050 700") rc("copy file " + png_name + " supersample 3") rc("reset") rc("close all") return
def export_scene(root): root_name = input_name + "-" + root png_name = root_name + ".png" rc("copy file " + png_name + " width 512 height 512 supersample 3") rc("export format x3d " + root_name)
def callChimeraGP41(pri_epitope,sec_epitope,fn,dirname,rootdir): base_dir = os.getcwd() trimer = rootdir+'/gp41_cphtrimer.pdb' monomer = rootdir+'/gp41_cphmodel.pdb' print "trimer path= ",trimer print "monomer path= ",monomer print "pri_epitope = ",pri_epitope print "sec_epitope = ",sec_epitope # Create 1st trimer image replyobj.status("Processing trimer") # show what file we're working on rc("open " + trimer) rc("windowsize 1050 700") # 2100 1400 rc("preset apply publication 3") # make everything look nice rc("turn 0,1,0 90") # tweak the rotation a bit rc("surf") # generate surface rc("focus") rc("color tan") rc("surftransp 60") # make the surface a little bit see-through rc("scale 0.70") # Fit into window rc("ribcolor rosy brown #0.1") # rosey brown rc("ribcolor dark khaki #0.2") # dark khaki # Color epitopes combo='' if pri_epitope != 'No Result' and pri_epitope != '': print "@@@@@@@@@@ cmd = color red #0.1 :",pri_epitope rc("color red #0.1 :"+pri_epitope) rc("color red #0.2 :"+pri_epitope) rc("color red #0.3 :"+pri_epitope) combo += pri_epitope+',' if sec_epitope != 'No Result' and sec_epitope != '': print "@@@@@@@@@@ cmd = color blue #0.1 :",sec_epitope rc("color blue #0.1 :"+sec_epitope) rc("color blue #0.2 :"+sec_epitope) rc("color blue #0.3 :"+sec_epitope) combo += sec_epitope+"," combo = combo[:-1] # Show ball & stick for epitopes rc("show #0.1 :"+combo) rc("show #0.2 :"+combo) rc("show #0.3 :"+combo) rc("represent bs #0.1 :"+combo) rc("represent bs #0.2 :"+combo) rc("represent bs #0.3 :"+combo) # save image to a file that ends in .png rather than .pdb rc("cd "+dirname) png_name = fn + ".trimer-side.png" rc("copy file " + png_name + " supersample 3") # Rotate trimer for second image rc("turn 0,1,0 90") png_name = fn+".trimer-top.png" rc("copy file " + png_name + " supersample 3") rc("reset") rc("close session") # Open monomer model rc("open "+monomer) rc("surface") rc("turn 0,0,1 -115") rc("turn 0,1,0 90") rc("scale 0.70") rc("preset apply publication 3") # make everything look nice rc('color tan') rc("surftransp 60") combo = '' if pri_epitope != 'No Result' and pri_epitope != '': rc("color red #0 :"+pri_epitope) combo += pri_epitope+',' if sec_epitope != 'No Result' and sec_epitope != '': rc("color blue #0 :"+sec_epitope) combo += sec_epitope+',' combo = combo[:-1] # Show ball & stick for epitopes rc("show #0 :"+combo) rc("represent bs #0 :"+combo) png_name = fn+".front-side.png" rc("windowsize 1050 700") rc("copy file " + png_name + " supersample 3") rc("turn 0,1,0 180") png_name = fn+".back-side.png" rc("windowsize 1050 700") rc("copy file " + png_name + " supersample 3") rc("reset") rc("close all") return