def main(): if len(sys.argv) != 7: # if no input print "ERORR:" print "syntex: dx-combine_grids.py gist-Eww-dens.dx 1 gist-gO.dx 1 0.0 temp" print "v[i] = w1*v1[i] + w2*v2[i] + c3" return infile1 = sys.argv[1] weight1 = float(sys.argv[2]) infile2 = sys.argv[3] weight2 = float(sys.argv[4]) const3 = float(sys.argv[5]) outfile = sys.argv[6] xn1, yn1, zn1, dx1, dy1, dz1, origin1, values1 = dxlib.read_in_dx_file( infile1) xn2, yn2, zn2, dx2, dy2, dz2, origin2, values2 = dxlib.read_in_dx_file( infile2) new_values = dxlib.combine_values(outfile + '.dat', xn1, yn1, zn1, dx1, dy1, dz1, origin1, values1, weight1, xn2, yn2, zn2, dx2, dy2, dz2, origin2, values2, weight2, const3) dxlib.write_out_dx_file(outfile + '.dx', xn1, yn1, zn1, dx1, dy1, dz1, origin1, new_values)
def main(): if len(sys.argv) != 4: # if no input print "ERORR:" print "this script caluculates the difference grid and the second norm over the grid. " print "syntex: dx-compare_2norm.py gist-Eww-dens.dx gist-gO.dx diff_grid" return infile1 = sys.argv[1] infile2 = sys.argv[2] outfile = sys.argv[3] weight1 = 1 weight2 = -1 const3 = 0 xn1, yn1, zn1, dx1, dy1, dz1, origin1, values1 = dxlib.read_in_dx_file( infile1) xn2, yn2, zn2, dx2, dy2, dz2, origin2, values2 = dxlib.read_in_dx_file( infile2) # caluclate the differents grid new_values = dxlib.combine_values(outfile + '.dat', xn1, yn1, zn1, dx1, dy1, dz1, origin1, values1, weight1, xn2, yn2, zn2, dx2, dy2, dz2, origin2, values2, weight2, const3) dxlib.write_out_dx_file(outfile + '.dx', xn1, yn1, zn1, dx1, dy1, dz1, origin1, new_values) norm = square_root_sum_of_squares(new_values) print "norm = ", norm
def main(): if len(sys.argv) != 4: # if no input print "ERORR:" print "syntex: dx-gist_precalculate_sphere.py infile sphradius outfileprefix" return infile1 = sys.argv[1] sphradius = float(sys.argv[2]) outfile = sys.argv[3] print infile1 print sphradius print outfile #exit() xn1, yn1, zn1, dx1, dy1, dz1, origin1, values1 = dxlib.read_in_dx_file( infile1) write_pdb_threshold(outfile + 'old.pdb', xn1, yn1, zn1, values1, origin1, dx1, dy1, dz1) new_xn, new_yn, new_zn, new_origin, nvalues = pre_compute( outfile + '.dat', xn1, yn1, zn1, dx1, dy1, dz1, origin1, values1, sphradius) dxlib.write_out_dx_file(outfile + '.dx', new_xn, new_yn, new_zn, dx1, dy1, dz1, new_origin, nvalues) write_pdb_threshold(outfile + 'new.pdb', new_xn, new_yn, new_zn, nvalues, new_origin, dx1, dy1, dz1)
def main(): if len(sys.argv) != 6: # if no input print "ERORR:" print "syntex: dx-gist_precalculate_sphere.py infile sphradius divider pad_radius outfileprefix" return infile1 = sys.argv[1] sphradius = float(sys.argv[2]) divider = float(sys.argv[3]) pad_radius = float(sys.argv[4]) outfile = sys.argv[5] if (pad_radius < sphradius): print "warning pap_radius (%f) is less than sphradius (%f).\n" % ( pad_radius, sphradius) print "This might cause boundary problems.\n" print infile1 print sphradius print outfile #exit() xn1, yn1, zn1, dx1, dy1, dz1, origin1, values1 = dxlib.read_in_dx_file( infile1) #write_pdb_threshold(outfile+'old.pdb',xn1,yn1,zn1,values1,origin1,dx1,dy1,dz1) new_xn, new_yn, new_zn, new_origin, nvalues = pre_compute( outfile + '.dat', xn1, yn1, zn1, dx1, dy1, dz1, origin1, values1, sphradius, divider, pad_radius) dxlib.write_out_dx_file(outfile + '.dx', new_xn, new_yn, new_zn, dx1, dy1, dz1, new_origin, nvalues)
def main(): if len(sys.argv) != 6: # if no input print "ERORR:" print "syntex: dx-gist_make_centers.py dx-input-file sign cutoff distint pdb-output-file" print "sign can be 1 or -1: if one should always be used for densities," print " for energies, weight of one means pdb contains cordenates where " print " waters do not want to be(anti-waters)." print " for energies, weight of negative one means pdb contains cordenates " print " where waters do want to be (negative energies)." print "cutoff can only be a positive floating point number. " print " this point is used to deterint clusters of points" print "distint howmeny grid points away considered conected. should be 1 (0.5 angstroms) or 2(1.0 A), 3 (1.5 A)" print "dx-input-file input file in dx formate produed by gist, may be disities or energies" print "pdb-output-file is an output file in pdb formate contains the weighted mean poition of clusters" return infile1 = sys.argv[1] sign = float(sys.argv[2]) threshold = float(sys.argv[3]) dist = int(sys.argv[4]) outfile = sys.argv[5] xn,yn,zn,dx,dy,dz,origin,values = dxlib.read_in_dx_file(infile1) gridscale = dx # assumes that they are all the same spaceing make_centers(outfile,values,gridscale,xn,yn,zn,origin, sign, threshold, dist)
def main(): if len(sys.argv) != 3: # if no input print "ERORR:" print "syntex: dx-gist_rescore.py dx-file sphere_file" print "dx-input-file input file in dx formate produed by gist, may be disities or energies" print "sphere file that defines the binding site (low dielectric sphere recomended) " return infiledx = sys.argv[1] infilesph = sys.argv[2] prefixdx = extract_fileprefix_from_path(infiledx) prefixsph = extract_fileprefix_from_path(infilesph) outfile = "site_energetics_dx-"+prefixdx+"sph-"+prefixsph print infiledx print infilesph xn,yn,zn,dx,dy,dz,origin,values = dxlib.read_in_dx_file(infiledx) gridscale = dx # assumes that they are all the same spaceing print gridscale ,xn,yn,zn,dx,dy,dz,origin sphs = sph_lib.read_sph(infilesph,'A','A') file1 = open(outfile+'gist_values.txt','w') new_values, atom_energies = calc_score(outfile+'.txt',values,gridscale,xn,yn,zn,origin, sphs, file1, True) dxlib.write_out_dx_file(outfile+'.dx',xn,yn,zn,dx,dy,dz,origin,new_values) convert_sph_to_pdb_and_write(sphs,atom_energies,outfile+'.pdb') file1.close()
def main(): if len(sys.argv) != 5: # if no input print "ERORR:" print "syntex: dx-divide_grids.py gist-Eww-dens.dx gist-gO.dx 0.0329 temp" print "v[i] = v1[i] / (w2*v2[i]) " return infile1 = sys.argv[1] infile2 = sys.argv[2] weight2 = float(sys.argv[3]) outfile = sys.argv[4] xn1,yn1,zn1,dx1,dy1,dz1,origin1,values1 = dx.read_in_dx_file(infile1) xn2,yn2,zn2,dx2,dy2,dz2,origin2,values2 = dx.read_in_dx_file(infile2) new_values = dx.divide_energy_density(outfile+'.dat',xn1,yn1,zn1,dx1,dy1,dz1,origin1,values1,xn2,yn2,zn2,dx2,dy2,dz2,origin2,values2,weight2) dx.write_out_dx_file(outfile+'.dx',xn1,yn1,zn1,dx1,dy1,dz1,origin1,new_values)
def main(): if len(sys.argv) != 5: # if no input print "ERORR:" print "syntex: dx-combine_grids.py gist-Eww-dens.dx gist-gO.dx 10.0 temp" print "v[i] = {v1[i], if v2[i]>t or 0, if v2[i]<t" print "v1 is energey, v2 is the density, t is the threshold that must be exceded." return infile1 = sys.argv[1] # gist energy infile2 = sys.argv[2] # density threshold = float(sys.argv[3]) # density threshold outfile = sys.argv[4] xn1,yn1,zn1,dx1,dy1,dz1,origin1,values1 = dxlib.read_in_dx_file(infile1) xn2,yn2,zn2,dx2,dy2,dz2,origin2,values2 = dxlib.read_in_dx_file(infile2) new_values = dxlib.combine_values_density_threshold(outfile+'.dat',xn1,yn1,zn1,dx1,dy1,dz1,origin1,values1,xn2,yn2,zn2,dx2,dy2,dz2,origin2,values2,threshold) dxlib.write_out_dx_file(outfile+'.dx',xn1,yn1,zn1,dx1,dy1,dz1,origin1,new_values)
def main(): if len(sys.argv) != 5: # if no input print "ERORR:" print "syntex: dx-gist_rescore.py dx-file mol2" print "dx-input-file input file in dx formate produed by gist, may be disities or energies" print "mol2 containing docked poses. " print "Hchoice [0(use standard radius), 1 (use 0.8 for nonpolar H, instead of 1.540), or 2 (ignore H)]" print "radius_pad : if a value of 8.0 is given then 8 angstroms is added to all atom radii" return infiledx = sys.argv[1] infilemol2 = sys.argv[2] Hchoice = int(sys.argv[3]) pad = float(sys.argv[4]) outfile = "out" print infiledx print infilemol2 DOCKpath = os.getenv('DOCKBASE') print(DOCKpath) vdwdict = intialize_vdw_parm(DOCKpath + '/proteins/defaults/vdw.parms.amb.mindock') #vdwdict = intialize_vdw_parm('/nfs/home/tbalius/zzz.github/DOCK/proteins/defaults/vdw.parms.amb.mindock') xn, yn, zn, dx, dy, dz, origin, values = dxlib.read_in_dx_file(infiledx) gridscale = dx # assumes that they are all the same spaceing mols = mol2.read_Mol2_file(infilemol2) file1 = open(outfile + 'gist_values.txt', 'w') N = len(mols) count = 0 for mol in mols: new_values = calc_score(outfile, values, gridscale, xn, yn, zn, origin, mol, vdwdict, file1, (N < 3), Hchoice, pad) if N < 3: # only print gist grids if there are a few poses in the mol2 file print "writting gist grid for overlap with ligand . . ." dxlib.write_out_dx_file(outfile + str(count) + "new_gist.dx", xn, yn, zn, dx, dy, dz, origin, new_values) count = count + 1 #exit() file1.close()
def main(): if len(sys.argv) != 4: # if no input print "ERORR:" print "syntex: dx-gist_extreme.py dx-input-file cutoff pdb-output-file" print "cutoff can only be a positive floating point number. " print " this point is used to deterint clusters of points" print "dx-input-file input file in dx formate produed by gist, may be disities or energies" print "pdb-output-file is an output file in pdb formate contains the weighted mean poition of clusters" return infile1 = sys.argv[1] threshold = float(sys.argv[2]) outfile = sys.argv[3] xn, yn, zn, dx, dy, dz, origin, values = dxlib.read_in_dx_file(infile1) gridscale = dx # assumes that they are all the same spaceing get_extreme(outfile, values, gridscale, xn, yn, zn, origin, threshold)
def main(): if len(sys.argv) != 4: # if no input print "ERORR:" print "syntex: dx-gist_make_courser.py gist-Eww-dens.dx 1 temp" #print "syntex: dx-combine_grids.py gist-Eww-dens.dx 3 temp" print " " return infile1 = sys.argv[1] number = int(sys.argv[2]) outfile = sys.argv[3] xn,yn,zn,dx,dy,dz,origin,values = dxlib.read_in_dx_file(infile1) gridscale = dx # assumes that they are all the same spaceing xnew,ynew,znew,origin_new,gridscale_new,values_new = dxlib.make_courser(outfile+'.dat',values,gridscale,xn,yn,zn,origin,number) dxlib.write_out_dx_file(outfile+'.dx',xnew,ynew,znew,gridscale_new,gridscale_new,gridscale_new,origin_new,values_new)
def main(): if len(sys.argv) != 4: # if no input print "ERORR:" print "syntex: dx-remove_extrema.py gistvalues.dx 5.0 gistvalues_cap" print "vnew[i] = {-t1, if v[i] <= -t1 " print " t1, if v[i] >= t1 " print " v[i] otherwise " return infile1 = sys.argv[1] # gist energy t1 = float(sys.argv[2]) # energy threshold outfile = sys.argv[3] xn1, yn1, zn1, dx1, dy1, dz1, origin1, values1 = dxlib.read_in_dx_file( infile1) new_values = [] countn = 0 countp = 0 for val in values1: if (val < -1.0 * t1): val = -1.0 * t1 countn = countn + 1 elif (val > 1.0 * t1): val = 1.0 * t1 countp = countp + 1 #else: new_values.append(val) print "%d number of point are caped in positive direction" % countp print "%d number of point are caped in negative direction" % countn #new_values = combine_values_density_threshold(outfile+'.dat',xn1,yn1,zn1,dx1,dy1,dz1,origin1,values1,xn2,yn2,zn2,dx2,dy2,dz2,origin2,values2,threshold) dxlib.write_out_dx_file(outfile + '.dx', xn1, yn1, zn1, dx1, dy1, dz1, origin1, new_values)
def main(): if len(sys.argv) != 7: # if no input print "ERORR:" print "syntex: dx-histogram.py gistvalues.dx min max num output [vyes,vno]" return infile1 = sys.argv[1] # gist energy minv = float(sys.argv[2]) # energy threshold maxv = float(sys.argv[3]) num = int(sys.argv[4]) output = sys.argv[5] verbose = sys.argv[6] #threshold = sys.argv[7] threshold = 3.0 if verbose == "vyes": boolverbose = True elif verbose == "vno": boolverbose = False else: print "error: must be vyes,vno" xn1, yn1, zn1, dx1, dy1, dz1, origin1, values1 = dxlib.read_in_dx_file( infile1) histogram = [] histogram_t = [] # trunc histogram histogram_nz = [] # histogram without zero values counted midbins = [] step = (maxv - minv) / float(num) print "infile = %s" % infile1 print "minv = %f\nmaxv = %f\n num = %d\n step = %f\n" % (minv, maxv, num, step) midbin = minv + step / 2.0 for i in range(0, num): histogram.append(0) histogram_t.append(0) histogram_nz.append(0) if midbin > maxv: print "error" exit() midbins.append(midbin) midbin = midbin + step countn = 0 countp = 0 min_ov = 1000 # minimum observed value max_ov = -1000 # maximum observed value ip3 = int(round((+3.0 - minv) / (maxv - minv) * (num - 1))) # value of index for value of +3.0 in3 = int(round((-3.0 - minv) / (maxv - minv) * (num - 1))) # value of index for value of -3.0 for val in values1: if (val < minv): countn = countn + 1 continue if (val > maxv): countp = countp + 1 continue i = int(round((val - minv) / (maxv - minv) * (num - 1))) if boolverbose: print "%f->%d->%f" % (val, i, midbins[i]) histogram[i] = histogram[i] + 1 if val != 0.0: histogram_nz[i] = histogram_nz[i] + 1 if val <= threshold and val >= -1.0 * threshold: histogram_t[i] = histogram_t[i] + 1 elif (val > threshold): histogram_t[ip3] = histogram_t[ip3] + 1 elif (val < -1.0 * threshold): histogram_t[in3] = histogram_t[in3] + 1 fh = open(output, 'w') for i in range(0, num): print "%f, %d,%d,%d" % (midbins[i], histogram[i], histogram_nz[i], histogram_t[i]) fh.write("%f,%d,%d,%d\n" % (midbins[i], histogram[i], histogram_nz[i], histogram_t[i])) print "number less than min: %d\nnumber grater than max: %d" % (countn, countp)