PEATDB/Ekin/Titration.py
def compareExtractedpKas(cls, DB, col, prot1, prot2):
        """Compare extracted pKas across similar proteins and plot correlations per res"""

        pkas = cls.extractpKas(DB, col)
        p1={};p2={};p1errs={};p2errs={}
        labels={}
        tp=['conserved','non-conserved']
        for t in tp:
            p1[t]=[];p2[t]=[]
            p1errs[t]=[];p2errs[t]=[]
            labels[t]=[]
        s1=[];s2=[]
        pkas1 = pkas[prot1]
        pkas2 = pkas[prot2]

        for n in pkas1.keys():
            if n in pkas1 and n in pkas2:
                res1 = pkas1[n]['res']; res2 = pkas2[n]['res']
                #this part requires alignment info!!
                if res1 == res2:# and res1 in cls.titratable:
                    t='conserved'
                else:
                    t='non-conserved'
                p1[t].append(pkas1[n]['pka']); p2[t].append(pkas2[n]['pka'])
                p1errs[t].append(pkas1[n]['pkaerror']); p2errs[t].append(pkas2[n]['pkaerror'])
                #s1.append(pkas1[n]['span']); s2.append(pkas2[n]['span']);
                labels[t].append(n)

        fig1=pylab.figure()
        i=0; leg=[]
        for t in tp:
            print p1[t], labels[t]
            if len(p1[t])==0 or len(p2[t])==0:
                continue
            cls.doXYPlot(fig1, p1[t], p2[t], xerrs=p1errs[t], yerrs=p2errs[t],
                            symbol=cls.shapes[i], color=cls.pylabcolors[i],
                            title='compared pKas', annotate=labels[t],
                            xlabel=prot1, ylabel=prot2)
            l = pylab.Line2D(range(10), range(10), color=cls.pylabcolors[i], alpha=0.8,
                                marker=cls.shapes[i])
            leg.append(l)
            i+=1
        pylab.legend(leg,tp,numpoints=1)
        a=fig1.get_axes()[0]
        a.set_xlim(4,5.5)
        a.set_ylim(4,5.5)
        fig1.savefig('compareprotpkas.png', dpi=200)

        '''fig2=pylab.figure()
        cc = cls.doXYPlot(fig2, s1, s2, xerrs=p1errs, yerrs=p2errs,
                            title='compared $\Delta\delta$', annotate=labels[t],
                            xlabel=prot1, ylabel=prot2)

        fig2.savefig('compareprotspans.png', dpi=200)'''
        return
Compare extracted pKas across similar proteins and plot correlations per res
Compare extracted pKas across similar proteins and plot correlations per res
Compare extracted pKas across similar proteins and plot correlations per res
def compareExtractedpKas(cls, DB, col, prot1, prot2):
        pkas = cls.extractpKas(DB, col)
        p1={};p2={};p1errs={};p2errs={}
        labels={}
        tp=['conserved','non-conserved']
        for t in tp:
            p1[t]=[];p2[t]=[]
            p1errs[t]=[];p2errs[t]=[]
            labels[t]=[]
        s1=[];s2=[]
        pkas1 = pkas[prot1]
        pkas2 = pkas[prot2]
        for n in pkas1.keys():
            if n in pkas1 and n in pkas2:
                res1 = pkas1[n]['res']; res2 = pkas2[n]['res']
                if res1 == res2:
                    t='conserved'
                else:
                    t='non-conserved'
                p1[t].append(pkas1[n]['pka']); p2[t].append(pkas2[n]['pka'])
                p1errs[t].append(pkas1[n]['pkaerror']); p2errs[t].append(pkas2[n]['pkaerror'])
                labels[t].append(n)
        fig1=pylab.figure()
        i=0; leg=[]
        for t in tp:
            print p1[t], labels[t]
            if len(p1[t])==0 or len(p2[t])==0:
                continue
            cls.doXYPlot(fig1, p1[t], p2[t], xerrs=p1errs[t], yerrs=p2errs[t],
                            symbol=cls.shapes[i], color=cls.pylabcolors[i],
                            title='compared pKas', annotate=labels[t],
                            xlabel=prot1, ylabel=prot2)
            l = pylab.Line2D(range(10), range(10), color=cls.pylabcolors[i], alpha=0.8,
                                marker=cls.shapes[i])
            leg.append(l)
            i+=1
        pylab.legend(leg,tp,numpoints=1)
        a=fig1.get_axes()[0]
        a.set_xlim(4,5.5)
        a.set_ylim(4,5.5)
        fig1.savefig('compareprotpkas.png', dpi=200)
        return
def compareExtractedpKas ( cls , DB , col , prot1 , prot2 ) : pkas = cls . extractpKas ( DB , col ) p1 = { } ; p2 = { } ; p1errs = { } ; p2errs = { } labels = { } tp = [ 'conserved' , 'non-conserved' ] for t in tp : p1 [ t ] = [ ] ; p2 [ t ] = [ ] p1errs [ t ] = [ ] ; p2errs [ t ] = [ ] labels [ t ] = [ ] s1 = [ ] ; s2 = [ ] pkas1 = pkas [ prot1 ] pkas2 = pkas [ prot2 ] for n in pkas1 . keys ( ) : if n in pkas1 and n in pkas2 : res1 = pkas1 [ n ] [ 'res' ] ; res2 = pkas2 [ n ] [ 'res' ] if res1 == res2 : t = 'conserved' else : t = 'non-conserved' p1 [ t ] . append ( pkas1 [ n ] [ 'pka' ] ) ; p2 [ t ] . append ( pkas2 [ n ] [ 'pka' ] ) p1errs [ t ] . append ( pkas1 [ n ] [ 'pkaerror' ] ) ; p2errs [ t ] . append ( pkas2 [ n ] [ 'pkaerror' ] ) labels [ t ] . append ( n ) fig1 = pylab . figure ( ) i = 0 ; leg = [ ] for t in tp : print p1 [ t ] , labels [ t ] if len ( p1 [ t ] ) == 0 or len ( p2 [ t ] ) == 0 : continue cls . doXYPlot ( fig1 , p1 [ t ] , p2 [ t ] , xerrs = p1errs [ t ] , yerrs = p2errs [ t ] , symbol = cls . shapes [ i ] , color = cls . pylabcolors [ i ] , title = 'compared pKas' , annotate = labels [ t ] , xlabel = prot1 , ylabel = prot2 ) l = pylab . Line2D ( range ( 10 ) , range ( 10 ) , color = cls . pylabcolors [ i ] , alpha = 0.8 , marker = cls . shapes [ i ] ) leg . append ( l ) i += 1 pylab . legend ( leg , tp , numpoints = 1 ) a = fig1 . get_axes ( ) [ 0 ] a . set_xlim ( 4 , 5.5 ) a . set_ylim ( 4 , 5.5 ) fig1 . savefig ( 'compareprotpkas.png' , dpi = 200 ) '''fig2=pylab.figure()
        cc = cls.doXYPlot(fig2, s1, s2, xerrs=p1errs, yerrs=p2errs,
                            title='compared $\Delta\delta$', annotate=labels[t],
                            xlabel=prot1, ylabel=prot2)

        fig2.savefig('compareprotspans.png', dpi=200)''' return
Compare extracted pKas across similar proteins and plot correlations per res
Compare extracted pKas across similar proteins and plot correlations per res
"""Compare extracted pKas across similar proteins and plot correlations per res""" #this part requires alignment info!! # and res1 in cls.titratable: #s1.append(pkas1[n]['span']); s2.append(pkas2[n]['span']); '''fig2=pylab.figure()
        cc = cls.doXYPlot(fig2, s1, s2, xerrs=p1errs, yerrs=p2errs,
                            title='compared $\Delta\delta$', annotate=labels[t],
                            xlabel=prot1, ylabel=prot2)

        fig2.savefig('compareprotspans.png', dpi=200)'''
cls
DB
col
prot1
prot2