PEATDB/plugins/KineticsAnalysis.py
def analyseKinetics(self, name, enzymeconc, enzymeconcerr,
                              dilution, altdilution, doftest=True, run=None):
        """Analyse MM kinetics fits from ekin project to extract kcats and kms etc"""

        print 'analysing MM data..'

        E = EkinProject()
        E.openProject(os.path.join(self.path, name))

        #We iterate over the phs to get kcats vs pH etc.
        kcatdatasets = []
        phs=[]; kcats=[]; kms=[]; kcatkms=[]; kslopes=[]
        kcaterrors=[]; kmerrors=[]; kcatkmerrors=[]; pherrors=[]; kslopeerrors=[]
        activelist=[]
        enzpercerr = enzymeconcerr/enzymeconc
        #introduce an error factor for the enzyme conc here to account
        #for variance in kcats between replicates..
        factor = 0.1
        lbls=['ph', 'vmax','[E]', '[E]err', 'dilution', 'kcat', 'kcat err', 'km', 'km err',
                 'kcat/km', 'kcat/km err', 'slope@0.025', 'slope@0.05']

        #send output to log files as html tables
        saveout = sys.stdout
        fsock = open(os.path.join(self.path,'log_'+str(run)+'.html'), 'a')
        sys.stdout = fsock
        self.doHeader()

        print '<h1>%s</h1>' %name
        print '<table>'
        for l in lbls:
            print '<th>%s</th>' %l
        print '<tr>'
        for d in self.phlist:
            ph=float(d.replace(',','.'))
            phs.append(ph)
            if d == '6' or d=='6,5':
                dil = dilution
            else:
                dil = altdilution

            vmax = E.getMetaData(d)['Vmax']
            km = E.getMetaData(d)['Km']
            kms.append(km)

            kcat = vmax / ( enzymeconc / dil )
            kcatkm = (kcat/km) / 1000

            vmaxerror = E.getMeta(d, 'exp_errors')['Vmax'][1]
            kmerror = E.getMeta(d, 'exp_errors')['Km'][1]
            #kmpercerror = kmerror / (km / dil)

            #check MM fit
            status = self.checkFit(E, d, 0.002)
            activelist.append(status)

            #get slope at chosen [S] to use for alternate kcat/km value
            #we check that it's less than km at this [S]
            ekd = E.getDataset(d)
            kslope1 = ekd.getYVal(4) #0.025
            kslope2 = ekd.getYVal(5) #0.05

            kslopes.append(kslope1)
            kslopeerrors.append(ekd.getYError(4))

            kcaterror = kcat * math.sqrt( pow(vmaxerror/vmax,2) + pow(enzpercerr+factor,2) )
            kcatkmerror = kcatkm * math.sqrt( pow(kcaterror/kcat,2) + pow(kmerror/km,2) )
            kcats.append(kcat)
            kcaterrors.append(kcaterror)
            kmerrors.append(kmerror)
            pherrors.append(self.pherr)
            kcatkms.append(kcatkm)
            kcatkmerrors.append(kcatkmerror)

            prms=[ph, vmax, enzymeconc, enzymeconcerr, dil, kcat, kcaterror, km, kmerror, kcatkm, kcatkmerror]
            for p in range(len(prms)):
                print '<td>%.3f</td>' %float(prms[p])
            #print 'using slope %s at [S]=%s' %(kslope, ekd.getXVal(5))
            print '<td>%.4f</td>' %float(kslope1)
            print '<td>%.4f</td>' %float(kslope2)
            print '<tr>'

        print '</table>'

        sys.stdout.flush()
        sys.stdout = saveout
        fsock.close()

        #print activelist
        kcatdata = EkinDataset(xy=[phs, kcats], xerrs=pherrors, yerrs=kcaterrors,
                                        active=activelist,xlabels='pH',ylabels='Kcat')

        kmdata = EkinConvert.xy2ekin([phs, kms], errorlists=(pherrors, kmerrors), labels=('pH','Km'))
        kcatkmdata = EkinConvert.xy2ekin([phs, kcatkms], errorlists=(pherrors, kcatkmerrors), labels=('pH','Kcat/Km'))
        kslopesdata = EkinConvert.xy2ekin([phs, kslopes], errorlists=(pherrors, kslopeerrors), labels=('pH','Kcat/Km'))
        E.insertDataset(kcatdata, 'Kcat', replace=True)
        E.insertDataset(kmdata, 'Km',replace=True)
        E.insertDataset(kcatkmdata, 'Kcat/Km',replace=True)
        E.insertDataset(kslopesdata, 'Slope@0.025',replace=True)
        E.addMeta('Kcat', 'enzymeconc', enzymeconc)

        kd = ['Kcat', 'Km', 'Kcat/Km', 'Slope@0.025']

        if doftest == True:
            #use ftest to see if 1 pka is better than fitting a line
            for d in kd:
                E.findBestModel(d, update=True, models=['Linear', '1 pKa 2 Chemical shifts'],
                                         conv=1e-12, grad=1e-12, strictchecking=False)
        else:
            for d in kd:
                E.fitDatasets(datasets=['Kcat', 'Km', 'Kcat/Km', 'Slope@0.025'], models=['1 pKa 2 Chemical shifts'],
                                    noiter=400, conv=1e-12, grad=1e-12, silent=True)
        print 'got pH vs. Kcat data'
        print 'done.', E
        print
        return E
Analyse MM kinetics fits from ekin project to extract kcats and kms etc
Analyse MM kinetics fits from ekin project to extract kcats and kms etc
Analyse MM kinetics fits from ekin project to extract kcats and kms etc
def analyseKinetics(self, name, enzymeconc, enzymeconcerr,
                              dilution, altdilution, doftest=True, run=None):
        print 'analysing MM data..'
        E = EkinProject()
        E.openProject(os.path.join(self.path, name))
        kcatdatasets = []
        phs=[]; kcats=[]; kms=[]; kcatkms=[]; kslopes=[]
        kcaterrors=[]; kmerrors=[]; kcatkmerrors=[]; pherrors=[]; kslopeerrors=[]
        activelist=[]
        enzpercerr = enzymeconcerr/enzymeconc
        factor = 0.1
        lbls=['ph', 'vmax','[E]', '[E]err', 'dilution', 'kcat', 'kcat err', 'km', 'km err',
                 'kcat/km', 'kcat/km err', 'slope@0.025', 'slope@0.05']
        saveout = sys.stdout
        fsock = open(os.path.join(self.path,'log_'+str(run)+'.html'), 'a')
        sys.stdout = fsock
        self.doHeader()
        print '<h1>%s</h1>' %name
        print '<table>'
        for l in lbls:
            print '<th>%s</th>' %l
        print '<tr>'
        for d in self.phlist:
            ph=float(d.replace(',','.'))
            phs.append(ph)
            if d == '6' or d=='6,5':
                dil = dilution
            else:
                dil = altdilution
            vmax = E.getMetaData(d)['Vmax']
            km = E.getMetaData(d)['Km']
            kms.append(km)
            kcat = vmax / ( enzymeconc / dil )
            kcatkm = (kcat/km) / 1000
            vmaxerror = E.getMeta(d, 'exp_errors')['Vmax'][1]
            kmerror = E.getMeta(d, 'exp_errors')['Km'][1]
            status = self.checkFit(E, d, 0.002)
            activelist.append(status)
            ekd = E.getDataset(d)
            kslope1 = ekd.getYVal(4) 
            kslope2 = ekd.getYVal(5) 
            kslopes.append(kslope1)
            kslopeerrors.append(ekd.getYError(4))
            kcaterror = kcat * math.sqrt( pow(vmaxerror/vmax,2) + pow(enzpercerr+factor,2) )
            kcatkmerror = kcatkm * math.sqrt( pow(kcaterror/kcat,2) + pow(kmerror/km,2) )
            kcats.append(kcat)
            kcaterrors.append(kcaterror)
            kmerrors.append(kmerror)
            pherrors.append(self.pherr)
            kcatkms.append(kcatkm)
            kcatkmerrors.append(kcatkmerror)
            prms=[ph, vmax, enzymeconc, enzymeconcerr, dil, kcat, kcaterror, km, kmerror, kcatkm, kcatkmerror]
            for p in range(len(prms)):
                print '<td>%.3f</td>' %float(prms[p])
            print '<td>%.4f</td>' %float(kslope1)
            print '<td>%.4f</td>' %float(kslope2)
            print '<tr>'
        print '</table>'
        sys.stdout.flush()
        sys.stdout = saveout
        fsock.close()
        kcatdata = EkinDataset(xy=[phs, kcats], xerrs=pherrors, yerrs=kcaterrors,
                                        active=activelist,xlabels='pH',ylabels='Kcat')
        kmdata = EkinConvert.xy2ekin([phs, kms], errorlists=(pherrors, kmerrors), labels=('pH','Km'))
        kcatkmdata = EkinConvert.xy2ekin([phs, kcatkms], errorlists=(pherrors, kcatkmerrors), labels=('pH','Kcat/Km'))
        kslopesdata = EkinConvert.xy2ekin([phs, kslopes], errorlists=(pherrors, kslopeerrors), labels=('pH','Kcat/Km'))
        E.insertDataset(kcatdata, 'Kcat', replace=True)
        E.insertDataset(kmdata, 'Km',replace=True)
        E.insertDataset(kcatkmdata, 'Kcat/Km',replace=True)
        E.insertDataset(kslopesdata, 'Slope@0.025',replace=True)
        E.addMeta('Kcat', 'enzymeconc', enzymeconc)
        kd = ['Kcat', 'Km', 'Kcat/Km', 'Slope@0.025']
        if doftest == True:
            for d in kd:
                E.findBestModel(d, update=True, models=['Linear', '1 pKa 2 Chemical shifts'],
                                         conv=1e-12, grad=1e-12, strictchecking=False)
        else:
            for d in kd:
                E.fitDatasets(datasets=['Kcat', 'Km', 'Kcat/Km', 'Slope@0.025'], models=['1 pKa 2 Chemical shifts'],
                                    noiter=400, conv=1e-12, grad=1e-12, silent=True)
        print 'got pH vs. Kcat data'
        print 'done.', E
        print
        return E
def analyseKinetics ( self , name , enzymeconc , enzymeconcerr , dilution , altdilution , doftest = True , run = None ) : print 'analysing MM data..' E = EkinProject ( ) E . openProject ( os . path . join ( self . path , name ) ) kcatdatasets = [ ] phs = [ ] ; kcats = [ ] ; kms = [ ] ; kcatkms = [ ] ; kslopes = [ ] kcaterrors = [ ] ; kmerrors = [ ] ; kcatkmerrors = [ ] ; pherrors = [ ] ; kslopeerrors = [ ] activelist = [ ] enzpercerr = enzymeconcerr / enzymeconc factor = 0.1 lbls = [ 'ph' , 'vmax' , '[E]' , '[E]err' , 'dilution' , 'kcat' , 'kcat err' , 'km' , 'km err' , 'kcat/km' , 'kcat/km err' , 'slope@0.025' , 'slope@0.05' ] saveout = sys . stdout fsock = open ( os . path . join ( self . path , 'log_' + str ( run ) + '.html' ) , 'a' ) sys . stdout = fsock self . doHeader ( ) print '<h1>%s</h1>' % name print '<table>' for l in lbls : print '<th>%s</th>' % l print '<tr>' for d in self . phlist : ph = float ( d . replace ( ',' , '.' ) ) phs . append ( ph ) if d == '6' or d == '6,5' : dil = dilution else : dil = altdilution vmax = E . getMetaData ( d ) [ 'Vmax' ] km = E . getMetaData ( d ) [ 'Km' ] kms . append ( km ) kcat = vmax / ( enzymeconc / dil ) kcatkm = ( kcat / km ) / 1000 vmaxerror = E . getMeta ( d , 'exp_errors' ) [ 'Vmax' ] [ 1 ] kmerror = E . getMeta ( d , 'exp_errors' ) [ 'Km' ] [ 1 ] status = self . checkFit ( E , d , 0.002 ) activelist . append ( status ) ekd = E . getDataset ( d ) kslope1 = ekd . getYVal ( 4 ) kslope2 = ekd . getYVal ( 5 ) kslopes . append ( kslope1 ) kslopeerrors . append ( ekd . getYError ( 4 ) ) kcaterror = kcat * math . sqrt ( pow ( vmaxerror / vmax , 2 ) + pow ( enzpercerr + factor , 2 ) ) kcatkmerror = kcatkm * math . sqrt ( pow ( kcaterror / kcat , 2 ) + pow ( kmerror / km , 2 ) ) kcats . append ( kcat ) kcaterrors . append ( kcaterror ) kmerrors . append ( kmerror ) pherrors . append ( self . pherr ) kcatkms . append ( kcatkm ) kcatkmerrors . append ( kcatkmerror ) prms = [ ph , vmax , enzymeconc , enzymeconcerr , dil , kcat , kcaterror , km , kmerror , kcatkm , kcatkmerror ] for p in range ( len ( prms ) ) : print '<td>%.3f</td>' % float ( prms [ p ] ) print '<td>%.4f</td>' % float ( kslope1 ) print '<td>%.4f</td>' % float ( kslope2 ) print '<tr>' print '</table>' sys . stdout . flush ( ) sys . stdout = saveout fsock . close ( ) kcatdata = EkinDataset ( xy = [ phs , kcats ] , xerrs = pherrors , yerrs = kcaterrors , active = activelist , xlabels = 'pH' , ylabels = 'Kcat' ) kmdata = EkinConvert . xy2ekin ( [ phs , kms ] , errorlists = ( pherrors , kmerrors ) , labels = ( 'pH' , 'Km' ) ) kcatkmdata = EkinConvert . xy2ekin ( [ phs , kcatkms ] , errorlists = ( pherrors , kcatkmerrors ) , labels = ( 'pH' , 'Kcat/Km' ) ) kslopesdata = EkinConvert . xy2ekin ( [ phs , kslopes ] , errorlists = ( pherrors , kslopeerrors ) , labels = ( 'pH' , 'Kcat/Km' ) ) E . insertDataset ( kcatdata , 'Kcat' , replace = True ) E . insertDataset ( kmdata , 'Km' , replace = True ) E . insertDataset ( kcatkmdata , 'Kcat/Km' , replace = True ) E . insertDataset ( kslopesdata , 'Slope@0.025' , replace = True ) E . addMeta ( 'Kcat' , 'enzymeconc' , enzymeconc ) kd = [ 'Kcat' , 'Km' , 'Kcat/Km' , 'Slope@0.025' ] if doftest == True : for d in kd : E . findBestModel ( d , update = True , models = [ 'Linear' , '1 pKa 2 Chemical shifts' ] , conv = 1e-12 , grad = 1e-12 , strictchecking = False ) else : for d in kd : E . fitDatasets ( datasets = [ 'Kcat' , 'Km' , 'Kcat/Km' , 'Slope@0.025' ] , models = [ '1 pKa 2 Chemical shifts' ] , noiter = 400 , conv = 1e-12 , grad = 1e-12 , silent = True ) print 'got pH vs. Kcat data' print 'done.' , E print return E
Analyse MM kinetics fits from ekin project to extract kcats and kms etc
Analyse MM kinetics fits from ekin project to extract kcats and kms etc
"""Analyse MM kinetics fits from ekin project to extract kcats and kms etc""" #We iterate over the phs to get kcats vs pH etc. #introduce an error factor for the enzyme conc here to account #for variance in kcats between replicates.. #send output to log files as html tables #kmpercerror = kmerror / (km / dil) #check MM fit #get slope at chosen [S] to use for alternate kcat/km value #we check that it's less than km at this [S] #0.025 #0.05 #print 'using slope %s at [S]=%s' %(kslope, ekd.getXVal(5)) #print activelist #use ftest to see if 1 pka is better than fitting a line
self
name
enzymeconc
enzymeconcerr
dilution
altdilution
doftest
run