PEATDB/Ekin/Titration.py
def dotitDBStats(self, ekindata, proteins=None, redirect=False):
        """Stats for titration datasets - takes a dict of ekindata, with the nmr
           column name as the key"""


        totaldatasets=0
        totalphpoints=[]
        minphpoints=[];maxphpoints=[]
        phranges=[]
        stdevphrange=0
        residuestats={}
        proteinstats={}
        lessXphstep=0

        totaltitres=0
        for t in self.residue_list: residuestats[t]=0
        names = {}
        for i in ekindata:
            names[i] = {}
            proteinstats[i] = {}

        for i in ekindata:
            ekinprjs = ekindata[i]
            avgchemshft=0
            names[i]['total'] = 0
            for prot in ekinprjs:
                proteinstats[prot]={}
                proteinstats[prot][i]={}
                E = ekinprjs[prot]
                totaldatasets += len(E.datasets)
                names[i]['total'] += len(E.datasets)
                proteinstats[prot][i]['total'] = len(E.datasets)
                for ed in E.datasets:
                    try:
		                ek = EkinDataset(E.data[ed])
		                totalphpoints.append(ek.length())
		                maxphpoints.append(ek.maxX())
		                minphpoints.append(ek.minX())
		                phranges.append(ek.maxX()-ek.minX())
		                phstep = (ek.maxX()-ek.minX()) / ek.length()
		                if phstep <= 0.3:
		                    lessXphstep+=1
		                ek.avgY()
		                fit = E.getFitData(ed)
		                res = E.getField(ed, 'residue')
		                if res != None:
		                    residuestats[res] += 1
                    except:
                        pass

        print '<div>'
        print '<h3>Global statistics for current data:</h3>'
        print '<a>'
        print 'total no of datasets: %s <br>' %totaldatasets
        print 'average/stdev. no. pH points: %.2f, %.2f <br>' %(numpy.mean(totalphpoints), numpy.std(totalphpoints))
        print 'average lowest/highest pH point: %.2f, %.2f, std. devs.(%s, %s) <br>' \
                %(numpy.mean(minphpoints), numpy.mean(maxphpoints), numpy.std(minphpoints), numpy.std(maxphpoints))
        print 'average/stdev. pH ranges: %.2f, %.2f <br>' %(numpy.mean(phranges), numpy.std(phranges))
        print 'total no. of pH points: %s <br>' %numpy.sum(totalphpoints)
        for t in self.titratable:
            totaltitres += residuestats[t]
        print 'total no. of titratable residues: %s (%.2f) <br>' %(totaltitres, float(totaltitres)/totaldatasets*100)
        print 'Per nucleus stats: <br>'
        for i in names:
            perc = round(float(names[i]['total'])/totaldatasets*100,2)
            print '%s: %s (%s) <br>' %(i,names[i]['total'], perc)

        perlessXcurves=0
        total=0
        for p in proteinstats:
            for i in names:
                if proteinstats[p].has_key(i):
                    n=proteinstats[p][i]['total']
                    total+=1.0
                    if n<=5:
                        perlessXcurves+=1

        print 'percent with less than 5 curves: %.2f <br>' %(perlessXcurves/total)
        print 'percent with lower than 0.2 pH step: %.2f <br>' %(float(lessXphstep)/totaldatasets)
        print '</a>'
        print '</div>'

        #stats on fits
        stats={}

        for i in ekindata:
            s = self.getFitStats(ekindata[i])
            stats[i] = s
            modls=s.keys()

        print '<div id="right">'
        print '<h3>Model fitting:</h3>'
        print '<table id="mytable" width=60%>'
        print '<th></th>'
        for m in modls:
            print '<th>%s</th>' %m
        for x in stats:
            print '<tr><td>%s</td>' %x
            for m in modls:
                print '<td>%s</td>' %stats[x][m]
            #print '<td>%s</td>' %total
            print '</tr>'
        print '</table>'
        print '</div>'

        #breakdown
        print '<div id="right">'
        print '<table id="summary" width=60% align=center cellspacing=0>'
        print '<h3>Breakdown by Residue:</h3>'

        print '<th>%s</th> <th>%s</th> <th>(%s)</th>' %('residue','curves','% total')
        for r in residuestats:
            print '<tr>'
            if Utils.getDictSum(residuestats) == 0:
                perc=0.0
            else:
                perc = round(float(residuestats[r])/Utils.getDictSum(residuestats)*100,2)
            print '<td>%s</td> <td>%s</td> <td>(%s)</td>' %(r,residuestats[r], perc)
            print '</tr>'

        print '</td></tr>'
        print '</table>'
        print '</div>'
        print '</div>'
        return
Stats for titration datasets - takes a dict of ekindata, with the nmr
           column name as the key
Stats for titration datasets - takes a dict of ekindata, with the nmr
column name as the key
Stats for titration datasets - takes a dict of ekindata with the nmr column name as the key
def dotitDBStats(self, ekindata, proteins=None, redirect=False):
        totaldatasets=0
        totalphpoints=[]
        minphpoints=[];maxphpoints=[]
        phranges=[]
        stdevphrange=0
        residuestats={}
        proteinstats={}
        lessXphstep=0
        totaltitres=0
        for t in self.residue_list: residuestats[t]=0
        names = {}
        for i in ekindata:
            names[i] = {}
            proteinstats[i] = {}
        for i in ekindata:
            ekinprjs = ekindata[i]
            avgchemshft=0
            names[i]['total'] = 0
            for prot in ekinprjs:
                proteinstats[prot]={}
                proteinstats[prot][i]={}
                E = ekinprjs[prot]
                totaldatasets += len(E.datasets)
                names[i]['total'] += len(E.datasets)
                proteinstats[prot][i]['total'] = len(E.datasets)
                for ed in E.datasets:
                    try:
		                ek = EkinDataset(E.data[ed])
		                totalphpoints.append(ek.length())
		                maxphpoints.append(ek.maxX())
		                minphpoints.append(ek.minX())
		                phranges.append(ek.maxX()-ek.minX())
		                phstep = (ek.maxX()-ek.minX()) / ek.length()
		                if phstep <= 0.3:
		                    lessXphstep+=1
		                ek.avgY()
		                fit = E.getFitData(ed)
		                res = E.getField(ed, 'residue')
		                if res != None:
		                    residuestats[res] += 1
                    except:
                        pass
        print '<div>'
        print '<h3>Global statistics for current data:</h3>'
        print '<a>'
        print 'total no of datasets: %s <br>' %totaldatasets
        print 'average/stdev. no. pH points: %.2f, %.2f <br>' %(numpy.mean(totalphpoints), numpy.std(totalphpoints))
        print 'average lowest/highest pH point: %.2f, %.2f, std. devs.(%s, %s) <br>' \
                %(numpy.mean(minphpoints), numpy.mean(maxphpoints), numpy.std(minphpoints), numpy.std(maxphpoints))
        print 'average/stdev. pH ranges: %.2f, %.2f <br>' %(numpy.mean(phranges), numpy.std(phranges))
        print 'total no. of pH points: %s <br>' %numpy.sum(totalphpoints)
        for t in self.titratable:
            totaltitres += residuestats[t]
        print 'total no. of titratable residues: %s (%.2f) <br>' %(totaltitres, float(totaltitres)/totaldatasets*100)
        print 'Per nucleus stats: <br>'
        for i in names:
            perc = round(float(names[i]['total'])/totaldatasets*100,2)
            print '%s: %s (%s) <br>' %(i,names[i]['total'], perc)
        perlessXcurves=0
        total=0
        for p in proteinstats:
            for i in names:
                if proteinstats[p].has_key(i):
                    n=proteinstats[p][i]['total']
                    total+=1.0
                    if n<=5:
                        perlessXcurves+=1
        print 'percent with less than 5 curves: %.2f <br>' %(perlessXcurves/total)
        print 'percent with lower than 0.2 pH step: %.2f <br>' %(float(lessXphstep)/totaldatasets)
        print '</a>'
        print '</div>'
        stats={}
        for i in ekindata:
            s = self.getFitStats(ekindata[i])
            stats[i] = s
            modls=s.keys()
        print '<div id="right">'
        print '<h3>Model fitting:</h3>'
        print '<table id="mytable" width=60%>'
        print '<th></th>'
        for m in modls:
            print '<th>%s</th>' %m
        for x in stats:
            print '<tr><td>%s</td>' %x
            for m in modls:
                print '<td>%s</td>' %stats[x][m]
            print '</tr>'
        print '</table>'
        print '</div>'
        print '<div id="right">'
        print '<table id="summary" width=60% align=center cellspacing=0>'
        print '<h3>Breakdown by Residue:</h3>'
        print '<th>%s</th> <th>%s</th> <th>(%s)</th>' %('residue','curves','% total')
        for r in residuestats:
            print '<tr>'
            if Utils.getDictSum(residuestats) == 0:
                perc=0.0
            else:
                perc = round(float(residuestats[r])/Utils.getDictSum(residuestats)*100,2)
            print '<td>%s</td> <td>%s</td> <td>(%s)</td>' %(r,residuestats[r], perc)
            print '</tr>'
        print '</td></tr>'
        print '</table>'
        print '</div>'
        print '</div>'
        return
def dotitDBStats ( self , ekindata , proteins = None , redirect = False ) : totaldatasets = 0 totalphpoints = [ ] minphpoints = [ ] ; maxphpoints = [ ] phranges = [ ] stdevphrange = 0 residuestats = { } proteinstats = { } lessXphstep = 0 totaltitres = 0 for t in self . residue_list : residuestats [ t ] = 0 names = { } for i in ekindata : names [ i ] = { } proteinstats [ i ] = { } for i in ekindata : ekinprjs = ekindata [ i ] avgchemshft = 0 names [ i ] [ 'total' ] = 0 for prot in ekinprjs : proteinstats [ prot ] = { } proteinstats [ prot ] [ i ] = { } E = ekinprjs [ prot ] totaldatasets += len ( E . datasets ) names [ i ] [ 'total' ] += len ( E . datasets ) proteinstats [ prot ] [ i ] [ 'total' ] = len ( E . datasets ) for ed in E . datasets : try : ek = EkinDataset ( E . data [ ed ] ) totalphpoints . append ( ek . length ( ) ) maxphpoints . append ( ek . maxX ( ) ) minphpoints . append ( ek . minX ( ) ) phranges . append ( ek . maxX ( ) - ek . minX ( ) ) phstep = ( ek . maxX ( ) - ek . minX ( ) ) / ek . length ( ) if phstep <= 0.3 : lessXphstep += 1 ek . avgY ( ) fit = E . getFitData ( ed ) res = E . getField ( ed , 'residue' ) if res != None : residuestats [ res ] += 1 except : pass print '<div>' print '<h3>Global statistics for current data:</h3>' print '<a>' print 'total no of datasets: %s <br>' % totaldatasets print 'average/stdev. no. pH points: %.2f, %.2f <br>' % ( numpy . mean ( totalphpoints ) , numpy . std ( totalphpoints ) ) print 'average lowest/highest pH point: %.2f, %.2f, std. devs.(%s, %s) <br>' % ( numpy . mean ( minphpoints ) , numpy . mean ( maxphpoints ) , numpy . std ( minphpoints ) , numpy . std ( maxphpoints ) ) print 'average/stdev. pH ranges: %.2f, %.2f <br>' % ( numpy . mean ( phranges ) , numpy . std ( phranges ) ) print 'total no. of pH points: %s <br>' % numpy . sum ( totalphpoints ) for t in self . titratable : totaltitres += residuestats [ t ] print 'total no. of titratable residues: %s (%.2f) <br>' % ( totaltitres , float ( totaltitres ) / totaldatasets * 100 ) print 'Per nucleus stats: <br>' for i in names : perc = round ( float ( names [ i ] [ 'total' ] ) / totaldatasets * 100 , 2 ) print '%s: %s (%s) <br>' % ( i , names [ i ] [ 'total' ] , perc ) perlessXcurves = 0 total = 0 for p in proteinstats : for i in names : if proteinstats [ p ] . has_key ( i ) : n = proteinstats [ p ] [ i ] [ 'total' ] total += 1.0 if n <= 5 : perlessXcurves += 1 print 'percent with less than 5 curves: %.2f <br>' % ( perlessXcurves / total ) print 'percent with lower than 0.2 pH step: %.2f <br>' % ( float ( lessXphstep ) / totaldatasets ) print '</a>' print '</div>' stats = { } for i in ekindata : s = self . getFitStats ( ekindata [ i ] ) stats [ i ] = s modls = s . keys ( ) print '<div id="right">' print '<h3>Model fitting:</h3>' print '<table id="mytable" width=60%>' print '<th></th>' for m in modls : print '<th>%s</th>' % m for x in stats : print '<tr><td>%s</td>' % x for m in modls : print '<td>%s</td>' % stats [ x ] [ m ] print '</tr>' print '</table>' print '</div>' print '<div id="right">' print '<table id="summary" width=60% align=center cellspacing=0>' print '<h3>Breakdown by Residue:</h3>' print '<th>%s</th> <th>%s</th> <th>(%s)</th>' % ( 'residue' , 'curves' , '% total' ) for r in residuestats : print '<tr>' if Utils . getDictSum ( residuestats ) == 0 : perc = 0.0 else : perc = round ( float ( residuestats [ r ] ) / Utils . getDictSum ( residuestats ) * 100 , 2 ) print '<td>%s</td> <td>%s</td> <td>(%s)</td>' % ( r , residuestats [ r ] , perc ) print '</tr>' print '</td></tr>' print '</table>' print '</div>' print '</div>' return
Stats for titration datasets - takes a dict of ekindata, with the nmr
column name as the key
Stats for titration datasets - takes a dict of ekindata with the nmr column name as the key
"""Stats for titration datasets - takes a dict of ekindata, with the nmr
           column name as the key""" #stats on fits #print '<td>%s</td>' %total #breakdown
self
ekindata
proteins
redirect