def PCA(fn, residue_PCA): """ get the name of files which have PCA """ inputfile = open(fn + "_protein.pdb") for line in inputfile: if pdbinfo.isAtom(line) == 1 and pdbinfo.resn( line).split()[0] == "PCA": residue_PCA.append(fn)
def Hg2toFlag(filename): """ change Hg2+ ion atom name to be FLAG """ f = open("tmp", "w") for lines in fileinput.input(filename): if pdbinfo.isAtom(lines) == 1 and \ pdbinfo.resn(lines).split()[0] == 'HG': lines = lines[0:12] + "FLAG" + lines[16::] f.write(lines) fileinput.close() f.close() os.system("mv tmp " + filename)
def checkIons(fn): """ check the information of ions fn_protein_proc3_nonprot <--- ions """ inpdb = fn + "_protein_proc3_nonprot.pdb" ions = [] if os.stat(inpdb)[6] > 0: for lines in fileinput.input(inpdb): atm = pdbinfo.atmn(lines) res = pdbinfo.resn(lines) ions.append(atm + " " + res) return ions
def fixFe2(fn): """ Change residue FE2 atom name to be FE2 """ pdbin = fn + "_protein_proc2.pdb" pdbout = fn + "_protein_proc2_fixFe2.pdb" f = open(pdbout, "w") for lines in fileinput.input(pdbin): if pdbinfo.isAtom(lines) == 1 and pdbinfo.resn(lines) == 'FE2': lines = lines[0:12] + ' FE2' + lines[16:] f.write(lines) f.close() fileinput.close() os.system("mv " + pdbout + " " + pdbin)
def rmPCA(fn): """ remove PCA from these files """ inputfile = open(fn + "_protein.pdb") outputfile = open(fn + "_protein_tmp.pdb", "w") for line in inputfile: if pdbinfo.isAtom(line) == 1 and pdbinfo.resn( line).split()[0] == "PCA": continue else: outputfile.write(line) outputfile.close() os.system("mv " + fn + "_protein_tmp.pdb " + fn + "_protein.pdb") os.system("rm " + fn + "_tmp.pdb")
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