def checkGap2(fn): gap = [] inpdb = fn + "_protein_proc7.pdb" for lines in fileinput.input("pdb4amber3.log"): if lines[0:3] == "gap": line = lines.split() #id1 = line[-3].split("_")[1] #id2 = line[-1].split("_")[1] ### change when using in prepare pair-test ### id1 = line[6] id2 = line[-1] id1 = "%4d" % (int(id1)) id2 = "%4d" % (int(id2)) gap.append(id1) gap.append(id2) gapb = copy.copy(gap) gapinch = [] fileinput.close() if len(gap) > 0: gapchid = [i for i in range(len(gap))] for lines in fileinput.input(inpdb): if pdbinfo.isAtom(lines) == 1 and pdbinfo.resi(lines) in gap: tmpid = gap.index(pdbinfo.resi(lines)) gapchid[tmpid] = pdbinfo.chid(lines) gap[tmpid] = 0 fileinput.close() for i in range(len(gapb) / 2): if gapchid[2 * i] == gapchid[ 2 * i + 1] and int(gapb[2 * i + 1]) - int(gapb[2 * i]) > 1: gapinch.append(gapb[2 * i]) gapinch.append(gapb[2 * i + 1]) return gapinch
def addTER(fn, gapinch): inpdb = fn + "_protein_proc_se.pdb" outpdb = fn + "_protein_proc4.pdb" halfgap = [gapinch[2 * i + 1] for i in range(len(gapinch) / 2)] f = open(outpdb, "w") for lines in fileinput.input(inpdb): if pdbinfo.isAtom(lines) == 1 and pdbinfo.resi(lines) in halfgap: f.write("TER \n") halfgap.remove(pdbinfo.resi(lines)) f.write(lines) fileinput.close() f.close()
def checkGap(fn): """ Check the gap information from the pdb4amber22.log file """ gap = [] for lines in fileinput.input("pdb4amber22.log"): if lines[0:3] == "gap": line = lines.split() #id1 = line[-3].split("_")[1] #id2 = line[-1].split("_")[1] ### change when using in prepare pair-test ### id1 = line[6] id2 = line[-1] id1 = "%4d" % (int(id1)) id2 = "%4d" % (int(id2)) gap.append(id1) gap.append(id2) gapb = copy.copy(gap) gapinch = [] # for gap within one chain fileinput.close() inpdb = fn + "_protein_proc_se.pdb" if len(gap) > 0: gapchid = [i for i in range(len(gap))] for lines in fileinput.input(inpdb): if pdbinfo.isAtom(lines) == 1 and pdbinfo.resi(lines) in gap: tmpid = gap.index(pdbinfo.resi(lines)) gapchid[tmpid] = pdbinfo.chid(lines) gap[tmpid] = 0 fileinput.close() for i in range(len(gapb) / 2): if gapchid[2 * i] == gapchid[2 * i + 1] and int( gapb[2 * i + 1] ) - int( gapb[2 * i] ) == 1: # the residues form the gap are close residues in same chain gapinch.append(gapb[2 * i]) gapinch.append(gapb[2 * i + 1]) return gapinch
def assignPDB1(fn, res): chid = res.keys() inpdb = fn + "_protein_proc8_noCYX.pdb" outpdb = fn + "_protein_proc8_assign1.pdb" f = open(outpdb, "w") for lines in fileinput.input(inpdb): if pdbinfo.isAtom(lines) == 1: resid = pdbinfo.resi(lines).split()[0] if resid in chid: lines = lines[:17] + res[resid] + lines[20:] f.write(lines) fileinput.close() f.close()
def changeRes(fn, res1, res2): inpdb = fn + "_protein_proc8.pdb" outpdb = fn + "_protein_prep.pdb" chid1 = res1.keys() chid2 = res2.keys() f = open(outpdb, "w") for lines in fileinput.input(inpdb): if pdbinfo.isAtom(lines) == 1: resid = pdbinfo.resi(lines).split()[0] if resid in chid1: lines = lines[:17] + res1[resid] + lines[20:] elif resid in chid2: lines = lines[:17] + res2[resid] + lines[20:] f.write(lines) fileinput.close() f.close()
def getProton(fn): inpdb = fn + "_protein_proc8_assign1.pqr" proton = {} for lines in fileinput.input(inpdb): if pdbinfo.isAtom(lines) == 1: resn = pdbinfo.resn(lines) if resn == 'HIS': resi = pdbinfo.resi(lines).split()[0] atmn = pdbinfo.atmn(lines) if resi in proton.keys() and atmn in [' HD1', ' HE2']: proton[resi][1].append(atmn) elif resi not in proton.keys(): proton[resi] = [resn, []] if atmn in [' HD1', 'HE2']: proton[resi][1].append(atmn) res = checkProtonState(proton) return res