PEATDB/Ekin/Titration.py
def compareNuclei(cls, DB, col1, col2, names=None, titratable=True,
                        silent=False, path=None):
        """Compare corresponding datasets for proteins that have data
          for 2 different NMR nuclei e.g. 1H vs 15N over entire DB"""

        relpkas1=[]
        relpkas2=[]
        relspans1=[]
        relspans2=[]
        otherpkas1=[]
        otherpkas2=[]
        #names=[]
        pkasbyres1={}
        pkasbyres2={}
        for t in cls.residue_list:
            pkasbyres1[t]=[]
            pkasbyres2[t]=[]

        cls.getProtNames(DB)

        for prot in DB.getRecs():
            name = cls.protnames[prot]
            if names != None and name not in names:
                continue
            if silent==False:
                print 'processing protein', name
                print '-------------------------'
            if not DB[prot].has_key(col1) or not DB[prot].has_key(col2):
                continue
            E1 = DB[prot][col1]
            E2 = DB[prot][col2]

            X = cls.compareAllpKas(E1, E2, titratable, exclude=cls.excluded)

            if X == None:
                continue
            rp1, rp2, op1, op2, rsp1, rsp2, errs1, errs2, resnames = X
            relpkas1.extend(rp1)
            relpkas2.extend(rp2)
            otherpkas1.extend(op1)
            otherpkas2.extend(op2)

            for vals in zip(resnames,rp1,rp2):
                r,a,b=vals
                #print r,a,b
                if r in cls.titratable:
                    pkasbyres1[r].append(a)
                    pkasbyres2[r].append(b)

        if silent==False:
            print 'reliable pkas matched:', len(relpkas1)
            print 'others:', len(otherpkas1)

        f=pylab.figure(figsize=(10,20))
        ax1=f.add_subplot(211)
        ax2=f.add_subplot(212)
        cc = cls.doXYPlot(ax1, relpkas1, relpkas2, #names=names,
                        title='15N vs 1H: reliable pKas', xlabel='15N (pH units)', ylabel='1H (pH units)')
        #print 'reliable pKas, correl coeff:', cc
        cc = cls.doXYPlot(ax2, otherpkas1, otherpkas2, color='r',
                        title='15N vs 1H : other pKas', xlabel='15N (pH units)', ylabel='1H (pH units)')
        f.suptitle('Comparison of corresponding 1H vs 15N fitted pKas',fontsize=24)
        #print 'other pKas, correl coeff:', cc

        if path==None:
            path = os.getcwd()
        fname = 'comparenuclei.png'
        f.savefig(os.path.join(path,fname), dpi=100)

        f1=pylab.figure(figsize=(8,8))
        ax=f1.add_subplot(111)
        i=0
        leglines = [];series=[]
        for r in pkasbyres1.keys():
            if len(pkasbyres1[r])==0:
                continue
            if i >= len(cls.shapes) or i>=len(cls.pylabcolors):
                i=0
            cls.doXYPlot(ax, pkasbyres1[r],pkasbyres2[r], symbol=cls.shapes[i], color=cls.pylabcolors[i],
                            markersize=40,
                            title='1H vs 15N: reliable pKa values by residue', xlabel='15N', ylabel='1H')
            l = pylab.Line2D(range(10), range(10), color=cls.pylabcolors[i], alpha=0.7,
                                marker=cls.shapes[i])
            leglines.append(l)
            series.append(r)
            i+=1
        leg = ax.legend(leglines, series, markerscale=2,
                             numpoints=1,loc='lower right',
                             prop=FontProperties(size="small"))
        leg.draw_frame(False)
        fname1 = 'comparenuclei_relbyres.png'
        f1.savefig(os.path.join(path,fname1), dpi=100)
        #pylab.show()
        return fname, fname1
Compare corresponding datasets for proteins that have data
          for 2 different NMR nuclei e.g. 1H vs 15N over entire DB
Compare corresponding datasets for proteins that have data
for 2 different NMR nuclei e.g. 1H vs 15N over entire DB
Compare corresponding datasets for proteins that have data for 2 different NMR nuclei e . g . 1H vs 15N over entire DB
def compareNuclei(cls, DB, col1, col2, names=None, titratable=True,
                        silent=False, path=None):
        relpkas1=[]
        relpkas2=[]
        relspans1=[]
        relspans2=[]
        otherpkas1=[]
        otherpkas2=[]
        pkasbyres1={}
        pkasbyres2={}
        for t in cls.residue_list:
            pkasbyres1[t]=[]
            pkasbyres2[t]=[]
        cls.getProtNames(DB)
        for prot in DB.getRecs():
            name = cls.protnames[prot]
            if names != None and name not in names:
                continue
            if silent==False:
                print 'processing protein', name
                print '-------------------------'
            if not DB[prot].has_key(col1) or not DB[prot].has_key(col2):
                continue
            E1 = DB[prot][col1]
            E2 = DB[prot][col2]
            X = cls.compareAllpKas(E1, E2, titratable, exclude=cls.excluded)
            if X == None:
                continue
            rp1, rp2, op1, op2, rsp1, rsp2, errs1, errs2, resnames = X
            relpkas1.extend(rp1)
            relpkas2.extend(rp2)
            otherpkas1.extend(op1)
            otherpkas2.extend(op2)
            for vals in zip(resnames,rp1,rp2):
                r,a,b=vals
                if r in cls.titratable:
                    pkasbyres1[r].append(a)
                    pkasbyres2[r].append(b)
        if silent==False:
            print 'reliable pkas matched:', len(relpkas1)
            print 'others:', len(otherpkas1)
        f=pylab.figure(figsize=(10,20))
        ax1=f.add_subplot(211)
        ax2=f.add_subplot(212)
        cc = cls.doXYPlot(ax1, relpkas1, relpkas2, 
                        title='15N vs 1H: reliable pKas', xlabel='15N (pH units)', ylabel='1H (pH units)')
        cc = cls.doXYPlot(ax2, otherpkas1, otherpkas2, color='r',
                        title='15N vs 1H : other pKas', xlabel='15N (pH units)', ylabel='1H (pH units)')
        f.suptitle('Comparison of corresponding 1H vs 15N fitted pKas',fontsize=24)
        if path==None:
            path = os.getcwd()
        fname = 'comparenuclei.png'
        f.savefig(os.path.join(path,fname), dpi=100)
        f1=pylab.figure(figsize=(8,8))
        ax=f1.add_subplot(111)
        i=0
        leglines = [];series=[]
        for r in pkasbyres1.keys():
            if len(pkasbyres1[r])==0:
                continue
            if i >= len(cls.shapes) or i>=len(cls.pylabcolors):
                i=0
            cls.doXYPlot(ax, pkasbyres1[r],pkasbyres2[r], symbol=cls.shapes[i], color=cls.pylabcolors[i],
                            markersize=40,
                            title='1H vs 15N: reliable pKa values by residue', xlabel='15N', ylabel='1H')
            l = pylab.Line2D(range(10), range(10), color=cls.pylabcolors[i], alpha=0.7,
                                marker=cls.shapes[i])
            leglines.append(l)
            series.append(r)
            i+=1
        leg = ax.legend(leglines, series, markerscale=2,
                             numpoints=1,loc='lower right',
                             prop=FontProperties(size="small"))
        leg.draw_frame(False)
        fname1 = 'comparenuclei_relbyres.png'
        f1.savefig(os.path.join(path,fname1), dpi=100)
        return fname, fname1
def compareNuclei ( cls , DB , col1 , col2 , names = None , titratable = True , silent = False , path = None ) : relpkas1 = [ ] relpkas2 = [ ] relspans1 = [ ] relspans2 = [ ] otherpkas1 = [ ] otherpkas2 = [ ] pkasbyres1 = { } pkasbyres2 = { } for t in cls . residue_list : pkasbyres1 [ t ] = [ ] pkasbyres2 [ t ] = [ ] cls . getProtNames ( DB ) for prot in DB . getRecs ( ) : name = cls . protnames [ prot ] if names != None and name not in names : continue if silent == False : print 'processing protein' , name print '-------------------------' if not DB [ prot ] . has_key ( col1 ) or not DB [ prot ] . has_key ( col2 ) : continue E1 = DB [ prot ] [ col1 ] E2 = DB [ prot ] [ col2 ] X = cls . compareAllpKas ( E1 , E2 , titratable , exclude = cls . excluded ) if X == None : continue rp1 , rp2 , op1 , op2 , rsp1 , rsp2 , errs1 , errs2 , resnames = X relpkas1 . extend ( rp1 ) relpkas2 . extend ( rp2 ) otherpkas1 . extend ( op1 ) otherpkas2 . extend ( op2 ) for vals in zip ( resnames , rp1 , rp2 ) : r , a , b = vals if r in cls . titratable : pkasbyres1 [ r ] . append ( a ) pkasbyres2 [ r ] . append ( b ) if silent == False : print 'reliable pkas matched:' , len ( relpkas1 ) print 'others:' , len ( otherpkas1 ) f = pylab . figure ( figsize = ( 10 , 20 ) ) ax1 = f . add_subplot ( 211 ) ax2 = f . add_subplot ( 212 ) cc = cls . doXYPlot ( ax1 , relpkas1 , relpkas2 , title = '15N vs 1H: reliable pKas' , xlabel = '15N (pH units)' , ylabel = '1H (pH units)' ) cc = cls . doXYPlot ( ax2 , otherpkas1 , otherpkas2 , color = 'r' , title = '15N vs 1H : other pKas' , xlabel = '15N (pH units)' , ylabel = '1H (pH units)' ) f . suptitle ( 'Comparison of corresponding 1H vs 15N fitted pKas' , fontsize = 24 ) if path == None : path = os . getcwd ( ) fname = 'comparenuclei.png' f . savefig ( os . path . join ( path , fname ) , dpi = 100 ) f1 = pylab . figure ( figsize = ( 8 , 8 ) ) ax = f1 . add_subplot ( 111 ) i = 0 leglines = [ ] ; series = [ ] for r in pkasbyres1 . keys ( ) : if len ( pkasbyres1 [ r ] ) == 0 : continue if i >= len ( cls . shapes ) or i >= len ( cls . pylabcolors ) : i = 0 cls . doXYPlot ( ax , pkasbyres1 [ r ] , pkasbyres2 [ r ] , symbol = cls . shapes [ i ] , color = cls . pylabcolors [ i ] , markersize = 40 , title = '1H vs 15N: reliable pKa values by residue' , xlabel = '15N' , ylabel = '1H' ) l = pylab . Line2D ( range ( 10 ) , range ( 10 ) , color = cls . pylabcolors [ i ] , alpha = 0.7 , marker = cls . shapes [ i ] ) leglines . append ( l ) series . append ( r ) i += 1 leg = ax . legend ( leglines , series , markerscale = 2 , numpoints = 1 , loc = 'lower right' , prop = FontProperties ( size = "small" ) ) leg . draw_frame ( False ) fname1 = 'comparenuclei_relbyres.png' f1 . savefig ( os . path . join ( path , fname1 ) , dpi = 100 ) return fname , fname1
Compare corresponding datasets for proteins that have data
for 2 different NMR nuclei e.g.
Compare corresponding datasets for proteins that have data for 2 different NMR nuclei e . g .
"""Compare corresponding datasets for proteins that have data
          for 2 different NMR nuclei e.g. 1H vs 15N over entire DB""" #names=[] #print r,a,b #names=names, #print 'reliable pKas, correl coeff:', cc #print 'other pKas, correl coeff:', cc #pylab.show()
cls
DB
col1
col2
names
titratable
silent
path