def optimize2(self): a = symgen.symgen() symorganics = [] processing = [] optimum = [] original = [] originalcount = 0 optimumcount = 0 maxcounts = [] newx = 0 newy = 0 newz = 0 nflag = 0 verbose = 0 numorg = float(len(self.organics)) count = 0 counter = 0 checkcounter = 0 file = open(self.root + 'optimize_organic.log', 'w') curres = 0 flag = 0 curror = "" currch = "" currpdb = "" hold = "" print "Optimizing individual organic/ligand symmetries - Please wait." changemade = 0 for o in self.organics: count = count + 1 counter = counter + 1 if(counter % 10 == 0): disp = float(count / numorg) * 100 # print "Optimizing individual organic symmetries - %.1f%% complete. "%disp counter = 0 if((o['res num'] == curres) and (o['res name'] == curror) and (o['chain'] == currch)): processing.append(o) hold = o else: #process data and start a new list if (flag == 1): changemade = 0 hold = o tproc = [] tproc.append(o) curres = o['res num'] curror = o['res name'] currch = o['chain'] symmorganics = a.varpass2(processing) opcount = [] for i in range(1000): opcount.append(0) best = 0 counter = 0 bestpos = 0 for i in symmorganics: checkcounter = 0 for j in i: checkcount = 0 for pdb in self.pdbs: if (pdb == currpdb): #print '---' #print "%s%s"%(o['res name'],o['res num']) checkcount = pdb.compare(j) opcount[checkcounter] = opcount[checkcounter] + checkcount checkcounter += 1 maxpos = 0 mypos = 0 maxcount = 0 for i in opcount: if(i > maxcount): maxpos = mypos maxcount = i mypos += 1 for i in symmorganics: optimum.append(i[maxpos]) pcount = 0 for i in processing: j = optimum[pcount] if maxcount == 0: file.write(str(i.pdb) + " " + i['res name'] + ' ' + i['atom name'] + " %d No Change Made\n" % i['res num']) file.write("****WARNING**** THIS ATOM MAKES NO PROTEIN CONTACTS ****WARNING****\n\n") else: if((str(j[4]) == "[0, 0, 0]" and j[3] == "x,y,z")): if(verbose): file.write(str(i.pdb) + " " + i['res name'] + ' ' + i['atom name'] + " %d No Change Made\n\n" % i['res num']) else: file.write(str(i.pdb) + " " + i['res name'] + ' ' + i['atom name'] + " %d Optimization Results" % i['res num']) file.write("\nOriginal Position: %.3f %.3f %.3f" % (i.position()[0], i.position()[1], i.position()[2])) file.write("\nOriginal Contacts: %d" % i.howclose()) file.write("\nOptimized Position: %.3f %.3f %.3f" % (j[0], j[1], j[2])) file.write("\nOptimized Symmetry UC: " + str(j[4])) file.write("\nOptimized Operator: " + j[3]) file.write("\nOptimized Contacts: %d\n\n" % maxcount) if maxcount > 0: i.optimum_update(j) pcount += 1 optimum = [] currpdb = o.pdb processing = [] processing.append(tproc[0]) else: flag = 1 optimum = [] processing = [] processing.append(o) curres = o['res num'] curror = o['res name'] currch = o['chain'] currpdb = o.pdb changemade = 0 o = hold symmorganics = a.varpass2(processing) opcount = [] for i in range(1000): opcount.append(0) for i in symmorganics: checkcounter = 0 for j in i: checkcount = 0 for pdb in self.pdbs: if (pdb == currpdb): checkcount = pdb.compare(j) opcount[checkcounter] = opcount[checkcounter] + checkcount checkcounter += 1 maxpos = 0 mypos = 0 maxcount = 0 for i in opcount: if(i > maxcount): maxpos = mypos maxcount = i mypos += 1 for i in symmorganics: optimum.append(i[maxpos]) pcount = 0 for i in processing: j = optimum[pcount] if maxcount == 0: file.write(str(i.pdb) + " " + i['res name'] + ' ' + i['atom name'] + " %d No Change Made\n" % i['res num']) file.write("****WARNING**** THIS ATOM MAKES NO PROTEIN CONTACTS ****WARNING****\n\n") else: if((str(j[4]) == "[0, 0, 0]" and j[3] == "x,y,z")): if(verbose): file.write(str(i.pdb) + " " + i['res name'] + ' ' + i['atom name'] + " %d No Change Made\n\n" % i['res num']) else: file.write(str(i.pdb) + " " + i['res name'] + ' ' + i['atom name'] + " %d Optimization Results" % i['res num']) file.write("\nOriginal Position: %.3f %.3f %.3f" % (i.position()[0], i.position()[1], i.position()[2])) file.write("\nOriginal Contacts: %d" % i.howclose()) file.write("\nOptimized Position: %.3f %.3f %.3f]" % (j[0], j[1], j[2])) file.write("\nOptimized Symmetry UC: " + str(j[4]) + ']') file.write("\nOptimized Operator: " + j[3] + ']') file.write("\nOptimized Contacts: %d\n\n" % maxcount) if maxcount > 0: i.optimum_update(j) pcount += 1 optimum = [] processing = [] file.close()
def optimize2(self): a = symgen.symgen() symorganics = [] processing = [] optimum = [] original = [] originalcount = 0 optimumcount = 0 maxcounts = [] newx = 0 newy = 0 newz = 0 nflag = 0 verbose = 0 numorg = float(len(self.organics)) count = 0 counter = 0 checkcounter = 0 file = open(self.root + 'optimize_organic.log', 'w') curres = 0 flag = 0 curror = "" currch = "" currpdb = "" hold = "" print "Optimizing individual organic/ligand symmetries - Please wait." changemade = 0 for o in self.organics: count = count + 1 counter = counter + 1 if (counter % 10 == 0): disp = float(count / numorg) * 100 # print "Optimizing individual organic symmetries - %.1f%% complete. "%disp counter = 0 if ((o['res num'] == curres) and (o['res name'] == curror) and (o['chain'] == currch)): processing.append(o) hold = o else: #process data and start a new list if (flag == 1): changemade = 0 hold = o tproc = [] tproc.append(o) curres = o['res num'] curror = o['res name'] currch = o['chain'] symmorganics = a.varpass2(processing) opcount = [] for i in range(1000): opcount.append(0) best = 0 counter = 0 bestpos = 0 for i in symmorganics: checkcounter = 0 for j in i: checkcount = 0 for pdb in self.pdbs: if (pdb == currpdb): #print '---' #print "%s%s"%(o['res name'],o['res num']) checkcount = pdb.compare(j) opcount[checkcounter] = opcount[ checkcounter] + checkcount checkcounter += 1 maxpos = 0 mypos = 0 maxcount = 0 for i in opcount: if (i > maxcount): maxpos = mypos maxcount = i mypos += 1 for i in symmorganics: optimum.append(i[maxpos]) pcount = 0 for i in processing: j = optimum[pcount] if maxcount == 0: file.write( str(i.pdb) + " " + i['res name'] + ' ' + i['atom name'] + " %d No Change Made\n" % i['res num']) file.write( "****WARNING**** THIS ATOM MAKES NO PROTEIN CONTACTS ****WARNING****\n\n" ) else: if ((str(j[4]) == "[0, 0, 0]" and j[3] == "x,y,z")): if (verbose): file.write( str(i.pdb) + " " + i['res name'] + ' ' + i['atom name'] + " %d No Change Made\n\n" % i['res num']) else: file.write( str(i.pdb) + " " + i['res name'] + ' ' + i['atom name'] + " %d Optimization Results" % i['res num']) file.write( "\nOriginal Position: %.3f %.3f %.3f" % (i.position()[0], i.position()[1], i.position()[2])) file.write("\nOriginal Contacts: %d" % i.howclose()) file.write( "\nOptimized Position: %.3f %.3f %.3f" % (j[0], j[1], j[2])) file.write("\nOptimized Symmetry UC: " + str(j[4])) file.write("\nOptimized Operator: " + j[3]) file.write("\nOptimized Contacts: %d\n\n" % maxcount) if maxcount > 0: i.optimum_update(j) pcount += 1 optimum = [] currpdb = o.pdb processing = [] processing.append(tproc[0]) else: flag = 1 optimum = [] processing = [] processing.append(o) curres = o['res num'] curror = o['res name'] currch = o['chain'] currpdb = o.pdb changemade = 0 o = hold symmorganics = a.varpass2(processing) opcount = [] for i in range(1000): opcount.append(0) for i in symmorganics: checkcounter = 0 for j in i: checkcount = 0 for pdb in self.pdbs: if (pdb == currpdb): checkcount = pdb.compare(j) opcount[checkcounter] = opcount[checkcounter] + checkcount checkcounter += 1 maxpos = 0 mypos = 0 maxcount = 0 for i in opcount: if (i > maxcount): maxpos = mypos maxcount = i mypos += 1 for i in symmorganics: optimum.append(i[maxpos]) pcount = 0 for i in processing: j = optimum[pcount] if maxcount == 0: file.write( str(i.pdb) + " " + i['res name'] + ' ' + i['atom name'] + " %d No Change Made\n" % i['res num']) file.write( "****WARNING**** THIS ATOM MAKES NO PROTEIN CONTACTS ****WARNING****\n\n" ) else: if ((str(j[4]) == "[0, 0, 0]" and j[3] == "x,y,z")): if (verbose): file.write( str(i.pdb) + " " + i['res name'] + ' ' + i['atom name'] + " %d No Change Made\n\n" % i['res num']) else: file.write( str(i.pdb) + " " + i['res name'] + ' ' + i['atom name'] + " %d Optimization Results" % i['res num']) file.write( "\nOriginal Position: %.3f %.3f %.3f" % (i.position()[0], i.position()[1], i.position()[2])) file.write("\nOriginal Contacts: %d" % i.howclose()) file.write("\nOptimized Position: %.3f %.3f %.3f]" % (j[0], j[1], j[2])) file.write("\nOptimized Symmetry UC: " + str(j[4]) + ']') file.write("\nOptimized Operator: " + j[3] + ']') file.write("\nOptimized Contacts: %d\n\n" % maxcount) if maxcount > 0: i.optimum_update(j) pcount += 1 optimum = [] processing = [] file.close()
def __init__(self, pdb_filenames, root, err=1): self.pdbs = [] totalnum = 0 for filename in pdb_filenames: self.pdbs.append(PDB(filename, root + filename.split('/')[-1],watercheck=1)) self.pdbs.sort(key=str) for i, pdb in enumerate(self.pdbs): pdb.number = i pdb.shortname = pdb.filename.split('/')[-1] totalnum = i self.waters = [] self.aa = [] self.organics = [] self.wList = [] self.max_x = -1000.2 self.max_y = -1000.3 self.max_z = -1000.4 self.min_x = 1000.2 self.min_y = 1000.3 self.min_z = 1000.4 self.rx = 0 self.ry = 0 self.rz = 0 self.lx = 0 self.ly = 0 self.lz = 0 self.cutoff = 5 shortest_distance = ('', Infinity) for pdb in self.pdbs: pdb.create_cell_table() for atom in pdb: if(atom['type'] == "ATOM" or atom['type'] == "HETATM"): if(atom['res name'] in water_names): self.waters.append(atom) if(atom['res name'] in protein_names): self.aa.append(atom) if(atom['res name'] in organic_names): self.organics.append(atom) #Create Water Table flag = 0 waters = [] #define boundaries for atom in self.waters: if(float(atom['x']) > self.max_x): self.max_x = atom['x'] if(float(atom['y']) > self.max_y): self.max_y = atom['y'] if(float(atom['z']) > self.max_z): self.max_z = atom['z'] if(float(atom['x']) < self.min_x): self.min_x = atom['x'] if(float(atom['y']) < self.min_y): self.min_y = atom['y'] if(float(atom['z']) < self.min_z): self.min_z = atom['z'] #define length of system self.max_x = self.max_x + self.cutoff self.max_y = self.max_y + self.cutoff self.max_z = self.max_z + self.cutoff self.min_x = self.min_x-self.cutoff self.min_y = self.min_y-self.cutoff self.min_z = self.min_z-self.cutoff self.rx = self.max_x-self.min_x self.ry = self.max_y-self.min_y self.rz = self.max_z-self.min_z #define how many cells per direction self.lx = math.ceil(self.rx / self.cutoff) self.ly = math.ceil(self.ry / self.cutoff) self.lz = math.ceil(self.rz / self.cutoff) #create and populate cell list numcells = self.lx * self.ly * self.lz cList = [] for i in xrange(int(numcells)): cList.append([]) flag = 0 for atom in self.waters: cx = math.floor((-self.min_x + atom['x']) / self.cutoff) cy = math.floor((-self.min_y + atom['y']) / self.cutoff) cz = math.floor((-self.min_z + atom['z']) / self.cutoff) cID = cx * self.ly * self.lz + cy * self.lz + cz cList[int(cID)].append(atom) self.wList = cList #End Water Table count = 0 numwater = float(len(self.waters)) numorg = len(self.organics) debug = 0 if(debug == 0): #print "Calculating nearby contacts for waters." for w in self.waters: count = count + 1 for pdb in self.pdbs: if (pdb == w.pdb): w.setclose(pdb.compare(w.position())) for o in self.organics: for pdb in self.pdbs: if (pdb == o.pdb): o.setclose(pdb.compare(o.position())) self.root = root + self.stamp if(not os.path.exists(self.root)): os.makedirs(self.root) self.master = Analyzer.Cluster_List() self.master_org = Analyzer.Ocluster_List() self.master_path = self.root + 'master.html' self.orgmaster_path = self.root + 'org.html' self.err = self.start_err = 1.0 self.orgerr = 1.0 self.centers = []
def __init__(self, pdb_filenames, root, err=1): self.pdbs = [] totalnum = 0 for filename in pdb_filenames: self.pdbs.append( PDB(filename, root + filename.split('/')[-1], watercheck=1)) self.pdbs.sort(key=str) for i, pdb in enumerate(self.pdbs): pdb.number = i pdb.shortname = pdb.filename.split('/')[-1] totalnum = i self.waters = [] self.aa = [] self.organics = [] self.wList = [] self.max_x = -1000.2 self.max_y = -1000.3 self.max_z = -1000.4 self.min_x = 1000.2 self.min_y = 1000.3 self.min_z = 1000.4 self.rx = 0 self.ry = 0 self.rz = 0 self.lx = 0 self.ly = 0 self.lz = 0 self.cutoff = 5 shortest_distance = ('', Infinity) for pdb in self.pdbs: pdb.create_cell_table() for atom in pdb: if (atom['type'] == "ATOM" or atom['type'] == "HETATM"): if (atom['res name'] in water_names): self.waters.append(atom) if (atom['res name'] in protein_names): self.aa.append(atom) if (atom['res name'] in organic_names): self.organics.append(atom) #Create Water Table flag = 0 waters = [] #define boundaries for atom in self.waters: if (float(atom['x']) > self.max_x): self.max_x = atom['x'] if (float(atom['y']) > self.max_y): self.max_y = atom['y'] if (float(atom['z']) > self.max_z): self.max_z = atom['z'] if (float(atom['x']) < self.min_x): self.min_x = atom['x'] if (float(atom['y']) < self.min_y): self.min_y = atom['y'] if (float(atom['z']) < self.min_z): self.min_z = atom['z'] #define length of system self.max_x = self.max_x + self.cutoff self.max_y = self.max_y + self.cutoff self.max_z = self.max_z + self.cutoff self.min_x = self.min_x - self.cutoff self.min_y = self.min_y - self.cutoff self.min_z = self.min_z - self.cutoff self.rx = self.max_x - self.min_x self.ry = self.max_y - self.min_y self.rz = self.max_z - self.min_z #define how many cells per direction self.lx = math.ceil(self.rx / self.cutoff) self.ly = math.ceil(self.ry / self.cutoff) self.lz = math.ceil(self.rz / self.cutoff) #create and populate cell list numcells = self.lx * self.ly * self.lz cList = [] for i in xrange(int(numcells)): cList.append([]) flag = 0 for atom in self.waters: cx = math.floor((-self.min_x + atom['x']) / self.cutoff) cy = math.floor((-self.min_y + atom['y']) / self.cutoff) cz = math.floor((-self.min_z + atom['z']) / self.cutoff) cID = cx * self.ly * self.lz + cy * self.lz + cz cList[int(cID)].append(atom) self.wList = cList #End Water Table count = 0 numwater = float(len(self.waters)) numorg = len(self.organics) debug = 0 if (debug == 0): #print "Calculating nearby contacts for waters." for w in self.waters: count = count + 1 for pdb in self.pdbs: if (pdb == w.pdb): w.setclose(pdb.compare(w.position())) for o in self.organics: for pdb in self.pdbs: if (pdb == o.pdb): o.setclose(pdb.compare(o.position())) self.root = root + self.stamp if (not os.path.exists(self.root)): os.makedirs(self.root) self.master = Analyzer.Cluster_List() self.master_org = Analyzer.Ocluster_List() self.master_path = self.root + 'master.html' self.orgmaster_path = self.root + 'org.html' self.err = self.start_err = 1.0 self.orgerr = 1.0 self.centers = []