def GetFinger(lig,pro,pts,pdbid): mscore=0.0 #without volumn correction mscorev=0.0 #with volumn correction cutoff=12.0 Finger=[] #without volumn correction Fingerv=[] #with volumn correction #f1=open("%s_GlideAfinger.txt"%pdbid,'wb') f2=open("%s.num"%pdbid,'wb') #for i in range(len(dist.DC_TYPES)): # Finger.append([0]*12) #for i in range(len(dist.DC_TYPES)): # Fingerv.append([0]*12) for a1 in lig.atoms: if a1.OBAtom.IsHydrogen(): continue a1_type=pat.LigAtomTyper(a1.OBAtom) if a1_type == '': continue for a2 in pro.atoms: if a2.OBAtom.IsHydrogen(): continue a2_type=pat.ProAtomTyper(a2.OBAtom) if a2_type in ('OW',''):continue dis_type='%s-%s'%(a1_type,a2_type) if dis_type not in dist.DC_TYPES: print 'Atom pair type %s has not been defined, the following pair has been neglected.'%(dis_type) print a1.OBAtom.GetType(),a1.OBAtom.GetIdx(),a2.OBAtom.GetType(),a2.OBAtom.GetIdx() continue j=dist.DC_TYPES.index(dis_type) d=rpd.GetDistance(a1.OBAtom,a2.OBAtom) if d>=cutoff: continue k=int((d-dist.D_MIN*0.1)/dist.D_DELT*10.0) #print >>f2, "%s,%d,%.6f,%d"%(dis_type,j,d,k) print >>f2, "%s,%d,%s,%d,%.6f"%(a1_type,a1.OBAtom.GetIdx(),a2_type,a2.OBAtom.GetIdx(),d) mscorev += pts.vect[j][k][0] mscore += pts.vect[j][k][1] ''' ascore=pts.vect[j][k][0] ascorev=pts.vect[j][k][1] m=int(d/1.0) Finger[j][m]+=ascore Fingerv[j][m]+=ascorev mscore+=ascore mscorev+=ascorev CFinger=CList(Finger) CFingerv=CList(Fingerv) print CFinger for j in range(len(dist.DC_TYPES)): dist_type=dist.DC_TYPES[j] i=1 while i<12: afinger=CFinger[j][i] afingerv=CFingerv[j][i] f1.write("%s-%d%10.2f\n"%(dist_type,i-1,afinger)) f2.write("%s-%d%10.2f\n"%(dist_type,i-1,afingerv)) i=i+1 f1.close() ''' f2.close() return mscore,mscorev
def RawDisPrint(lig, pro): v = [] for a1 in lig.atoms: atom1 = a1.OBAtom ## if a1.OBAtom.IsHydrogen(): ## continue a1_type = pat.LigAtomTyper(atom1) a1_idx = -1 if a1_type in pat.LIG_TYPES: a1_idx = pat.LIG_TYPES.index(a1_type) for a2 in pro.atoms: atom2 = a2.OBAtom ## if a2.OBAtom.IsHydrogen(): ## continue distance = GetDistance(atom1, atom2) if distance >= 12.0: continue a2_type = pat.ProAtomTyper(atom2) a2_idx = -1 if a2_type in pat.PRO_TYPES: a2_idx = pat.PRO_TYPES.index(a2_type) dis_type = '%s-%s' % (a1_type, a2_type) info = FormatedOutput(atom1, atom2) line = '%s,%d,%d,%s,%.4fA\n' % (dis_type, a1_idx, a2_idx, info, distance) v.append(line) for a2 in lig.atoms: atom2 = a2.OBAtom ## if a2.OBAtom.IsHydrogen(): ## continue if atom1.GetIdx() == atom2.GetIdx(): continue distance = GetDistance(atom1, atom2) if distance >= 12.0: continue a2_type = pat.LigAtomTyper(atom2) a2_idx = -1 if a2_type in pat.LIG_TYPES: a2_idx = pat.LIG_TYPES.index(a2_type) dis_type = '#%s-%s' % (a1_type, a2_type) info = FormatedOutput(atom1, atom2) line = '%s,%d,%d,%s,%.4fA\n' % (dis_type, a1_idx, a2_idx, info, distance) v.append(line) return v
def dTypeGen(alist, blist, form): sl, sr, dtlist = set(), set(), [] for a in alist: for b in blist: d, a1_type, a2_type = rpd.GetDistance( a.OBAtom, b.OBAtom), pat.LigAtomTyper( a.OBAtom), pat.ProAtomTyper(b.OBAtom) if form(d, a1_type, a2_type): sl.add(a) sr.add(b) dtlist.append((d, a1_type, a2_type)) return dtlist, len(sl), len(sr)
def GetFinger(lig,pro,pts,pdbid): mscore=0.0 #with volumn correction mscorev=0.0 #without volumn correction cutoff=12.0 Finger=[] Fingerv=[] f1=open("%s_GlideCfinger.txt"%pdbid,'wb') f2=open("%s_GlideCfingerv.txt"%pdbid,'wb') for i in range(len(dist.DC_TYPES)): Finger.append([0]*4) for i in range(len(dist.DC_TYPES)): Fingerv.append([0]*4) for a1 in lig.atoms: if a1.OBAtom.IsHydrogen(): continue a1_type=pat.LigAtomTyper(a1.OBAtom) for a2 in pro.atoms: if a2.OBAtom.IsHydrogen(): continue a2_type=pat.ProAtomTyper(a2.OBAtom) if a2_type=='OW':continue dis_type='%s-%s'%(a1_type,a2_type) if dis_type not in dist.DC_TYPES: print 'Atom pair type %s has not been defined, the following pair has been neglected.'%(dis_type) print a1.OBAtom.GetType(),a1.OBAtom.GetIdx(),a2.OBAtom.GetType(),a2.OBAtom.GetIdx() continue j=dist.DC_TYPES.index(dis_type) d=rpd.GetDistance(a1.OBAtom,a2.OBAtom) if d>=cutoff: continue k=int((d-dist.D_MIN*0.1)/dist.D_DELT*10.0) ascore=pts.vect[j][k][0] ascorev=pts.vect[j][k][1] m=int(d/3.0) Finger[j][m]+=ascore Fingerv[j][m]+=ascorev mscore+=ascore mscorev+=ascorev CFinger=CList(Finger) CFingerv=CList(Fingerv) print CFinger for j in range(len(dist.DC_TYPES)): dist_type=dist.DC_TYPES[j] for i in range(4): afinger=CFinger[j][i] afingerv=CFingerv[j][i] f1.write("%s-%d%7.2f\n"%(dist_type,i,afinger)) f2.write("%s-%d%7.2f\n"%(dist_type,i,afingerv)) f1.close() f2.close() return mscore,mscorev
def run(self): global mutex, ligand, protein, outf, ap_iter while True: mutex.acquire() try: i, j = ap_iter.next() except StopIteration: break mutex.release() dist = protein.atoms[j].OBAtom.GetDistance(ligand.atoms[i].OBAtom) if dist >= 12.0: continue ltype = pmf_atom_typer.LigAtomTyper(ligand.atoms[i].OBAtom) if ltype == "": continue ptype = pmf_atom_typer.ProAtomTyper(protein.atoms[j].OBAtom) if ptype in ("", "HD"): continue mutex.acquire() print >> outf, "%s,%d,%s,%d,%.6f" % (ltype, i + 1, ptype, j + 1, dist) #outf.flush() mutex.release()
def do_for_each(name): _format = name[name.rfind(".") + 1:] basename = name[:name.rfind(".")] out_name = basename + ".num" pdb_id = basename.split("_")[-1] #if len(pro_atom[pdb_id]) == 0: # print "to do atom typing for %s..."%pdb_id, # sys.stdout.flush() # calc_pro_types(pdb_id) # print " Done" # sys.stdout.flush() pdb_name = "/home/xmluo/jlpeng/cMet/pdb_protein/%s_protein.pdb" % pdb_id lig = pybel.readfile(_format, name).next() pro = pybel.readfile("pdb", pdb_name).next() outf = open(out_name, "w") for al in lig.atoms: if al.OBAtom.IsHydrogen(): continue ltype = pmf_atom_typer.LigAtomTyper(al.OBAtom) lidx = al.OBAtom.GetIdx() if ltype == "": continue for j in xrange(len(pro.atoms)): ap = pro.atoms[j] if ap.OBAtom.IsHydrogen(): continue dist = ap.OBAtom.GetDistance(al.OBAtom) if dist >= cutoff: continue #ptype = pro_atom[pdb_id][j] ptype = pmf_atom_typer.ProAtomTyper(ap.OBAtom) pidx = ap.OBAtom.GetIdx() if ptype in ('', 'OW'): continue print >> outf, "%s,%d,%s,%d,%.6f" % (ltype, lidx, ptype, pidx, dist) outf.close()
def dTypeGen_old(alist, blist): for a in alist: for b in blist: yield rpd.GetDistance(a.OBAtom, b.OBAtom), pat.LigAtomTyper( a.OBAtom), pat.ProAtomTyper(b.OBAtom)