Exemplo n.º 1
0
    def RMSDProt(self):

        prRMSDprot = self.dMD["prRMSD"] + "protein/"
        pathFolder.createFolder(prRMSDprot)
        if not "prSuperMatrix" in dir(self):
            self.Superimpose(0)

        # pfilout
        pfilout = prRMSDprot + "protRMSD"
        if path.exists(pfilout):
            return
        else:
            filout = open(pfilout, "w")
            filout.write("Time\tRMSDall\tRMSDC\tDmax\n0\t0\t0\t0\n")

        # open reference frame
        nframeref = str("%05d" % (0))
        pframeref = self.dMD["prframe"] + "frame_" + nframeref + ".pdb"
        cprotref = PDB.PDB(PDB_input=pframeref)
        cprotref.get_atomProt()

        i = self.stepFrame
        imax = float(self.MDtime) / float(self.timeframe)
        while i < imax:
            nframe2 = str("%05d" % (i))
            pframe2 = self.dMD["prframe"] + "frame_" + nframe2 + ".pdb"

            cprot2 = PDB.PDB(PDB_input=pframe2)
            cprot2.get_atomProt()

            pmatrix = self.prSuperMatrix + str(nframeref) + "_" + str(nframe2)
            #apply matrix on frame 2
            matrixload = toolbox.loadMatrixTMalign(pmatrix)
            for atomprot2 in cprot2.latomProt:
                atomprot2.applyMatrixRotTransloc(matrixload)

            lRMSD = calculate.RMSDTwoList(cprotref.latomProt, cprot2.latomProt)
            filout.write("%s\t%s\t%s\t%s\n" %
                         (i / 100.0, lRMSD[0], lRMSD[1], lRMSD[2]))
            i += self.stepFrame

        filout.close()
        runExternalSoft.runscatterplotRMSD(pfilout)
Exemplo n.º 2
0
    def computeRMSDProt(self, pr_MDout):
        # load ligand in frame 0
        cfram0 = PDB.PDB(pr_MDout + "framesMD/frame_00000.pdb")
        cfram0.get_lAtoms()

        pr_TMalign = pr_MDout + "RMSDs/superimpose/"
        l_pTMaling = listdir(pr_TMalign)

        dRMSD = {}
        for pTMalign in l_pTMaling:
            frame = pTMalign.split("_")[-1]
            #print frame
            dmatrixTMalign = toolbox.loadMatrixTMalign(pr_TMalign + pTMalign)
            cFrame = PDB.PDB("%sframesMD/frame_%s.pdb" % (pr_MDout, frame))
            cFrame.get_lAtoms()

            for atomLig in cFrame.latom:
                atomLig.applyMatrixRotTransloc(dmatrixTMalign)

            RMSDframe = calculate.RMSDTwoList(cfram0.latom, cFrame.latom)
            dRMSD[frame] = RMSDframe

        # write the RMSD lig file
        pfilout = pr_MDout + "RMSDs/protein/protRMSD_all"
        filout = open(pfilout, "w")
        filout.write("Time\tRMSDall\tRMSDC\tDmax\n")
        filout.write("0.0\t0.0\t0.0\t0.0\n")

        i = 1
        imax = len(dRMSD.keys())
        while i <= imax:
            frame = str("%05d" % (i))
            filout.write(
                "%.2f\t%s\t%s\t%s\n" %
                (i / 100.0, dRMSD[frame][0], dRMSD[frame][1], dRMSD[frame][2]))
            i = i + 1
        filout.close()
        return pfilout
Exemplo n.º 3
0
    def computeRMSDLig(self, pr_MDout):

        # load ligand in frame 0
        clig0 = PDB.PDB(pr_MDout + "lig/LGD_00000.pdb")
        clig0.get_lAtoms()

        pr_TMalign = pr_MDout + "RMSDs/superimpose/"
        l_pTMaling = listdir(pr_TMalign)

        dRMSD = {}
        for pTMalign in l_pTMaling:
            frame = pTMalign.split("_")[-1]
            #print frame
            dmatrixTMalign = toolbox.loadMatrixTMalign(pr_TMalign + pTMalign)
            cligFrame = PDB.PDB("%slig/LGD_%s.pdb" % (pr_MDout, frame))
            cligFrame.get_lAtoms()

            for atomLig in cligFrame.latom:
                atomLig.applyMatrixRotTransloc(dmatrixTMalign)

            RMSDframe = calculate.RMSDTwoList(clig0.latom, cligFrame.latom)
            dRMSD[frame] = RMSDframe[0]

        # write the RMSD lig file
        pfilout = pr_MDout + "RMSDs/ligand/ligRMSD"
        filout = open(pfilout, "w")
        filout.write("Time\tRMSD\n")
        filout.write("0.0\t0.0\n")

        i = 1
        imax = len(dRMSD.keys())
        while i <= imax:
            frame = str("%05d" % (i))
            filout.write("%.2f\t%s\n" % (i / 100.0, dRMSD[frame]))
            i = i + 1
        filout.close()
        return pfilout
Exemplo n.º 4
0
    def protResRMSF(self):

        prResidues = self.dMD["prRMSD"] + "residues/"
        pathFolder.createFolder(prResidues)

        try:
            print self.prSuperMatrix
        except:
            print self.Superimpose(0)

        pfilout = prResidues + "resRMSD"
        if path.exists(pfilout):
            return
        else:
            filout = open(pfilout, "w")
            filout.write("NameRes\tall\tCa\tDmax\n")

        # open reference frame
        nframeref = str("%05d" % (0))
        pframeref = self.dMD["prframe"] + "frame_" + nframeref + ".pdb"
        cprotref = PDB.PDB(PDB_input=pframeref)
        cprotref.get_byres()

        dRMSFres = {}
        i = self.stepFrame
        imax = float(self.MDtime) / float(self.timeframe)
        while i < imax:
            print i, imax, "frame"
            nframe2 = str("%05d" % (i))
            pframe2 = self.dMD["prframe"] + "frame_" + nframe2 + ".pdb"

            cprot2 = PDB.PDB(PDB_input=pframe2)
            cprot2.get_lAtoms()

            pmatrix = self.prSuperMatrix + str(nframeref) + "_" + str(nframe2)
            # apply matrix on frame 2
            matrixload = toolbox.loadMatrixTMalign(pmatrix)
            for atomprot2 in cprot2.latom:
                atomprot2.applyMatrixRotTransloc(matrixload)
            cprot2.get_byres()

            for resname in cprot2.byres:
                res = resname.split("_")[0]
                if res in PDB.LRESSHORT:
                    numres = int(resname.split("_")[1])
                    if not numres in dRMSFres.keys():
                        dRMSFres[numres] = {}
                        dRMSFres[numres]["all"] = []
                        dRMSFres[numres]["Ca"] = []
                        dRMSFres[numres]["Dmax"] = []
                    RMSDRes = calculate.RMSDTwoList(cprotref.byres[resname],
                                                    cprot2.byres[resname])
                    dRMSFres[numres]["all"].append(RMSDRes[0])
                    dRMSFres[numres]["Ca"].append(RMSDRes[1])
                    dRMSFres[numres]["Dmax"].append(RMSDRes[3])
            i += self.stepFrame

        orderednum = sorted(dRMSFres.keys())
        for num in orderednum:
            filout.write(
                str(num) + "\t" + str(average(dRMSFres[num]["all"])) + "\t" +
                str(average(dRMSFres[num]["Ca"])) + "\t" +
                str(average(dRMSFres[num]["Dmax"])) + "\n")
        filout.close()

        runExternalSoft.runScatterplotRMSF(pfilout)
Exemplo n.º 5
0
    def ligRMSFShaEP(self, RMSF=1, ShaEPScore=1):

        prLig = self.dMD["prRMSD"] + "ligand/"
        pathFolder.createFolder(prLig)

        try:
            print self.prSuperMatrix
        except:
            print self.Superimpose(0)

        # open reference frame
        nframeref = str("%05d" % (0))
        pframeref = self.dMD["prLig"] + "LGD_" + nframeref + ".pdb"
        cligref = PDB.PDB(PDB_input=pframeref)
        cligref.get_lAtoms()

        if RMSF == 1 and ShaEPScore == 1:
            pfiloutRMSF = prLig + "ligRMSF"
            pfiloutShaEP = prLig + "ligShaEP"
            if path.exists(pfiloutShaEP) and path.exists(pfiloutRMSF):
                return

        if RMSF == 1:
            pfiloutRMSF = prLig + "ligRMSF"
            filoutRMSF = open(pfiloutRMSF, "w")
            filoutRMSF.write("Atom\tRMSF\n")

        if ShaEPScore == 1:
            pfiloutShaEP = prLig + "ligShaEP"
            filoutShaEP = open(pfiloutShaEP, "w")
            filoutShaEP.write("Time\tESPscore\tShape\n")

            prtemp = prLig + "temp/"
            pathFolder.createFolder(prtemp, clean=1)

        dRMSF = {}

        i = self.stepFrame
        imax = float(self.MDtime) / float(self.timeframe)
        while i < imax:
            print i, imax, "frame"
            nframe2 = str("%05d" % (i))
            pframe2 = self.dMD["prLig"] + "LGD_" + nframe2 + ".pdb"

            clig2 = PDB.PDB(PDB_input=pframe2)
            clig2.get_lAtoms()

            pmatrix = self.prSuperMatrix + str(nframeref) + "_" + str(nframe2)
            # apply matrix on frame 2
            matrixload = toolbox.loadMatrixTMalign(pmatrix)
            for atomlig2 in clig2.latom:
                atomlig2.applyMatrixRotTransloc(matrixload)

            if RMSF == 1:
                print len(cligref.latom), len(clig2.latom)
                for atomRef in cligref.latom:
                    name = str(atomRef.name)
                    for atomframe in clig2.latom:
                        if name == atomframe.name:
                            RMSD = calculate.RMSDTwoList([atomRef],
                                                         [atomframe])
                            if not name in dRMSF.keys():
                                dRMSF[name] = []
                            dRMSF[name].append(RMSD[0])
                            break

            if ShaEPScore == 1:
                pathFolder.cleanFolder(prtemp)
                ptempref = prtemp + pframeref.split("/")[-1]
                ptempframe2 = prtemp + pframe2.split("/")[-1]
                copyfile(pframeref, ptempref)
                clig2.writePDB(ptempframe2, conect=1)
                runExternalSoft.runShaep(ptempref, ptempframe2,
                                         prtemp + "shaep-out")
                doutShaep = parseShaep.parseOutputShaep(prtemp + "shaep-out")
                filoutShaEP.write(
                    str(i / 100.0) + "\t" + str(doutShaep["ESP_similarity"]) +
                    "\t" + str(doutShaep["shape_similarity"]) + "\n")
                pathFolder.cleanFolder(prtemp)

            i += self.stepFrame

        if ShaEPScore == 1:
            filoutShaEP.close()
            runExternalSoft.scatterplotShaEP(pfiloutShaEP)

        if RMSF == 1:
            for natom in dRMSF.keys():
                linew = str(natom) + "\t" + str(average(dRMSF[natom])) + "\n"
                filoutRMSF.write(linew)
            filoutRMSF.close()
            runExternalSoft.RMSFLig(pfiloutRMSF)