PEATDB/Ekin/Titration.py
def correlatewithStructure(cls, ekindata, peatdb, pdbs=None):
        """Correlate a structural or other single property with each residue pKa/span"""
        #example here is for %surface accessibility

        import random

        count=0
        pkas=[]
        spans={}
        other={}
        for t in cls.titratable:
            spans[t]=[]
            other[t]=[]
        failedpdb=[]

        proteins = ekindata.keys()
        for prot in proteins:
            print prot
            print
            print 'doing protein', prot
            print '---------------------'
            #for structure stuff, we need pdb file here
            if peatdb != None:
                #get pdb file
                pdbfile = cls.save_PEAT_Structure(peatdb, prot)
                print 'trying to get pdb from PEAT db'
            elif pdbs.has_key(prot):
                pdbfile = pdbs[prot]
                #pdblines = cls.getPDBfromFile(pdbfile)
            if pdbfile == None:
                print 'no pdb file, skipping'
                failedpdb.append(protname)
                continue
            else:
                print 'got pdb'
            #get another attribute here eg. % rel. access.
            relacc = cls.getRelAccessibility(pdbfile)
            print relacc.keys()
            print

            E = EkinProject(ekindata[prot])
            for dataset in E.datasets:
                #resdata = cls.getResidueFields(ekindata[prot][dataset])
                resdata = E.getMetaData(dataset)
                res = resdata['residue']
                atom = resdata['atom']

                rk = cls.getPDBResidueName(resdata)
                #print 'trying', rk
                if res in cls.titratable:
                    if dataset in self.excluded:
                        continue
                    if relacc.has_key(rk):
                        accval = relacc[rk]['sum']['rel']
                        print 'found relative acc:', rk, accval
                        count+=1
                    else:
                        continue

                    if ekindata[prot]['__datatabs_fits__'].has_key(dataset):
                        fitdata = ekindata[prot]['__datatabs_fits__'][dataset]
                        #print 'fitdata', fitdata
                    pk,pkval,sp1 = cls.getMainpKa(fitdata, res=res)
                    print dataset, pk, pkval
                    if pkval != None:
                        pkas.append(pkval)
                        spans[res].append(sp1)
                        #other.append(random.uniform(pkval-0.4,pkval+0.4)*1.3)   #test
                        other[res].append(accval)
                    else:
                        print 'no primary pKa'
        print spans, other
        print 'failed to get pdbs for:', failedpdb
        print 'acc values found for %s residues'  % count
        pylab.figure(4)
        #cls.doXYPlot(pkas, other, title='compare x', xlabel='pkas', ylabel='y')
        #cls.doXYPlot(spans, other, title='Rel Access. vs $\delta$ shift', xlabel='$\delta$ chem. shift', ylabel='y')
        pylab.gcf().text(0.5, 0.95, 'Rel Access. vs $\delta$ shift', horizontalalignment='center',
                        fontproperties=FontProperties(size=18))

        i=1
        for r in spans.keys():
            pylab.subplot(2,2,i)
            cls.doXYPlot(spans[r], other[r], title=r) # xlabel='$\delta$ chem. shift', ylabel='% Surface Access.')
            i+=1

        pylab.show()
        return
Correlate a structural or other single property with each residue pKa/span
Correlate a structural or other single property with each residue pKa/span
Correlate a structural or other single property with each residue pKa / span
def correlatewithStructure(cls, ekindata, peatdb, pdbs=None):
        import random
        count=0
        pkas=[]
        spans={}
        other={}
        for t in cls.titratable:
            spans[t]=[]
            other[t]=[]
        failedpdb=[]
        proteins = ekindata.keys()
        for prot in proteins:
            print prot
            print
            print 'doing protein', prot
            print '---------------------'
            if peatdb != None:
                pdbfile = cls.save_PEAT_Structure(peatdb, prot)
                print 'trying to get pdb from PEAT db'
            elif pdbs.has_key(prot):
                pdbfile = pdbs[prot]
            if pdbfile == None:
                print 'no pdb file, skipping'
                failedpdb.append(protname)
                continue
            else:
                print 'got pdb'
            relacc = cls.getRelAccessibility(pdbfile)
            print relacc.keys()
            print
            E = EkinProject(ekindata[prot])
            for dataset in E.datasets:
                resdata = E.getMetaData(dataset)
                res = resdata['residue']
                atom = resdata['atom']
                rk = cls.getPDBResidueName(resdata)
                if res in cls.titratable:
                    if dataset in self.excluded:
                        continue
                    if relacc.has_key(rk):
                        accval = relacc[rk]['sum']['rel']
                        print 'found relative acc:', rk, accval
                        count+=1
                    else:
                        continue
                    if ekindata[prot]['__datatabs_fits__'].has_key(dataset):
                        fitdata = ekindata[prot]['__datatabs_fits__'][dataset]
                    pk,pkval,sp1 = cls.getMainpKa(fitdata, res=res)
                    print dataset, pk, pkval
                    if pkval != None:
                        pkas.append(pkval)
                        spans[res].append(sp1)
                        other[res].append(accval)
                    else:
                        print 'no primary pKa'
        print spans, other
        print 'failed to get pdbs for:', failedpdb
        print 'acc values found for %s residues'  % count
        pylab.figure(4)
        pylab.gcf().text(0.5, 0.95, 'Rel Access. vs $\delta$ shift', horizontalalignment='center',
                        fontproperties=FontProperties(size=18))
        i=1
        for r in spans.keys():
            pylab.subplot(2,2,i)
            cls.doXYPlot(spans[r], other[r], title=r) 
            i+=1
        pylab.show()
        return
def correlatewithStructure ( cls , ekindata , peatdb , pdbs = None ) : import random count = 0 pkas = [ ] spans = { } other = { } for t in cls . titratable : spans [ t ] = [ ] other [ t ] = [ ] failedpdb = [ ] proteins = ekindata . keys ( ) for prot in proteins : print prot print print 'doing protein' , prot print '---------------------' if peatdb != None : pdbfile = cls . save_PEAT_Structure ( peatdb , prot ) print 'trying to get pdb from PEAT db' elif pdbs . has_key ( prot ) : pdbfile = pdbs [ prot ] if pdbfile == None : print 'no pdb file, skipping' failedpdb . append ( protname ) continue else : print 'got pdb' relacc = cls . getRelAccessibility ( pdbfile ) print relacc . keys ( ) print E = EkinProject ( ekindata [ prot ] ) for dataset in E . datasets : resdata = E . getMetaData ( dataset ) res = resdata [ 'residue' ] atom = resdata [ 'atom' ] rk = cls . getPDBResidueName ( resdata ) if res in cls . titratable : if dataset in self . excluded : continue if relacc . has_key ( rk ) : accval = relacc [ rk ] [ 'sum' ] [ 'rel' ] print 'found relative acc:' , rk , accval count += 1 else : continue if ekindata [ prot ] [ '__datatabs_fits__' ] . has_key ( dataset ) : fitdata = ekindata [ prot ] [ '__datatabs_fits__' ] [ dataset ] pk , pkval , sp1 = cls . getMainpKa ( fitdata , res = res ) print dataset , pk , pkval if pkval != None : pkas . append ( pkval ) spans [ res ] . append ( sp1 ) other [ res ] . append ( accval ) else : print 'no primary pKa' print spans , other print 'failed to get pdbs for:' , failedpdb print 'acc values found for %s residues' % count pylab . figure ( 4 ) pylab . gcf ( ) . text ( 0.5 , 0.95 , 'Rel Access. vs $\delta$ shift' , horizontalalignment = 'center' , fontproperties = FontProperties ( size = 18 ) ) i = 1 for r in spans . keys ( ) : pylab . subplot ( 2 , 2 , i ) cls . doXYPlot ( spans [ r ] , other [ r ] , title = r ) i += 1 pylab . show ( ) return
Correlate a structural or other single property with each residue pKa/span
Correlate a structural or other single property with each residue pKa / span
"""Correlate a structural or other single property with each residue pKa/span""" #example here is for %surface accessibility #for structure stuff, we need pdb file here #get pdb file #pdblines = cls.getPDBfromFile(pdbfile) #get another attribute here eg. % rel. access. #resdata = cls.getResidueFields(ekindata[prot][dataset]) #print 'trying', rk #print 'fitdata', fitdata #other.append(random.uniform(pkval-0.4,pkval+0.4)*1.3)   #test #cls.doXYPlot(pkas, other, title='compare x', xlabel='pkas', ylabel='y') #cls.doXYPlot(spans, other, title='Rel Access. vs $\delta$ shift', xlabel='$\delta$ chem. shift', ylabel='y') # xlabel='$\delta$ chem. shift', ylabel='% Surface Access.')
cls
ekindata
peatdb
pdbs