PEATDB/Ekin/Titration.py
def comparepKas(cls, E1, E2, d, titratable=False, errcutoff=1e2):
        """Compare pKas from fits in two ekin datasets
           returns:
               None if fails to find meaningful pKas from fits
               otherwise returns tuple of results"""
        reliable=True
        #print d
        try:
            res1 = E1.getMetaData(d)['residue']
        except:
            #print E1.getDataset(d)
            return
        if titratable == True and not res1 in cls.titratable:
            return None
        fitdata1 = E1.getFitData(d)
        fitdata2 = E2.getFitData(d)
        if len(fitdata1)<1:
            return None
        model1 = fitdata1['model']
        model2 = fitdata2['model']

        #if model1 != model2:
        #    print 'different models'
            #return None

        p1,p1val,sp1 = cls.getMainpKa(fitdata1, res=res1)#,strict=False)
        p2,p2val,sp2 = cls.getMainpKa(fitdata2, res=res1)#,strict=False)
        allpkas1,allpkvals1,allsp1 = cls.getallpKas(fitdata1,minspan=0.03)
        allpkas2,allpkvals2,allsp2 = cls.getallpKas(fitdata2,minspan=0.03)

        if p1val != None and p2val != None and len(allpkas1) > 0 and len(allpkas2) > 0:
            pchk = cls.getClosest(p1val, allpkvals2)
            try:
                perr1 = round(E1.getMeta(d, 'exp_errors')[p1][1],4)
                perr2 = round(E2.getMeta(d, 'exp_errors')[p2][1],4)
            except:
                return None
            #print d, p1val, p2val, perr1, perr2
            #print errcutoff
            if perr1>errcutoff or perr2>errcutoff: return None
            if p2val != pchk:
                p2val = pchk
        else:
            if p1val != None and p2val == None:
                if len(allpkas2) > 0:
                    p2val = cls.getClosest(p1val, allpkvals2)
                else:
                    return None
            elif p2val != None and p1val == None:
                if len(allpkas1) > 0:
                    p1val = cls.getClosest(p2val, allpkvals1)
                else:
                    return None
            elif p1val==None and p2val==None:
                return None
            perr1=perr2=None
            reliable = False

        return p1val, p2val, sp1, sp2, perr1, perr2, reliable
Compare pKas from fits in two ekin datasets
           returns:
               None if fails to find meaningful pKas from fits
               otherwise returns tuple of results
Compare pKas from fits in two ekin datasets
returns:
None if fails to find meaningful pKas from fits
otherwise returns tuple of results
Compare pKas from fits in two ekin datasets returns : None if fails to find meaningful pKas from fits otherwise returns tuple of results
def comparepKas(cls, E1, E2, d, titratable=False, errcutoff=1e2):
        reliable=True
        try:
            res1 = E1.getMetaData(d)['residue']
        except:
            return
        if titratable == True and not res1 in cls.titratable:
            return None
        fitdata1 = E1.getFitData(d)
        fitdata2 = E2.getFitData(d)
        if len(fitdata1)<1:
            return None
        model1 = fitdata1['model']
        model2 = fitdata2['model']
        p1,p1val,sp1 = cls.getMainpKa(fitdata1, res=res1)
        p2,p2val,sp2 = cls.getMainpKa(fitdata2, res=res1)
        allpkas1,allpkvals1,allsp1 = cls.getallpKas(fitdata1,minspan=0.03)
        allpkas2,allpkvals2,allsp2 = cls.getallpKas(fitdata2,minspan=0.03)
        if p1val != None and p2val != None and len(allpkas1) > 0 and len(allpkas2) > 0:
            pchk = cls.getClosest(p1val, allpkvals2)
            try:
                perr1 = round(E1.getMeta(d, 'exp_errors')[p1][1],4)
                perr2 = round(E2.getMeta(d, 'exp_errors')[p2][1],4)
            except:
                return None
            , p1val, p2val, perr1, perr2
            if perr1>errcutoff or perr2>errcutoff: return None
            if p2val != pchk:
                p2val = pchk
        else:
            if p1val != None and p2val == None:
                if len(allpkas2) > 0:
                    p2val = cls.getClosest(p1val, allpkvals2)
                else:
                    return None
            elif p2val != None and p1val == None:
                if len(allpkas1) > 0:
                    p1val = cls.getClosest(p2val, allpkvals1)
                else:
                    return None
            elif p1val==None and p2val==None:
                return None
            perr1=perr2=None
            reliable = False
        return p1val, p2val, sp1, sp2, perr1, perr2, reliable
def comparepKas ( cls , E1 , E2 , d , titratable = False , errcutoff = 1e2 ) : reliable = True try : res1 = E1 . getMetaData ( d ) [ 'residue' ] except : return if titratable == True and not res1 in cls . titratable : return None fitdata1 = E1 . getFitData ( d ) fitdata2 = E2 . getFitData ( d ) if len ( fitdata1 ) < 1 : return None model1 = fitdata1 [ 'model' ] model2 = fitdata2 [ 'model' ] p1 , p1val , sp1 = cls . getMainpKa ( fitdata1 , res = res1 ) p2 , p2val , sp2 = cls . getMainpKa ( fitdata2 , res = res1 ) allpkas1 , allpkvals1 , allsp1 = cls . getallpKas ( fitdata1 , minspan = 0.03 ) allpkas2 , allpkvals2 , allsp2 = cls . getallpKas ( fitdata2 , minspan = 0.03 ) if p1val != None and p2val != None and len ( allpkas1 ) > 0 and len ( allpkas2 ) > 0 : pchk = cls . getClosest ( p1val , allpkvals2 ) try : perr1 = round ( E1 . getMeta ( d , 'exp_errors' ) [ p1 ] [ 1 ] , 4 ) perr2 = round ( E2 . getMeta ( d , 'exp_errors' ) [ p2 ] [ 1 ] , 4 ) except : return None if perr1 > errcutoff or perr2 > errcutoff : return None if p2val != pchk : p2val = pchk else : if p1val != None and p2val == None : if len ( allpkas2 ) > 0 : p2val = cls . getClosest ( p1val , allpkvals2 ) else : return None elif p2val != None and p1val == None : if len ( allpkas1 ) > 0 : p1val = cls . getClosest ( p2val , allpkvals1 ) else : return None elif p1val == None and p2val == None : return None perr1 = perr2 = None reliable = False return p1val , p2val , sp1 , sp2 , perr1 , perr2 , reliable
Compare pKas from fits in two ekin datasets
returns:
None if fails to find meaningful pKas from fits
otherwise returns tuple of results
Compare pKas from fits in two ekin datasets returns : None if fails to find meaningful pKas from fits otherwise returns tuple of results
"""Compare pKas from fits in two ekin datasets
           returns:
               None if fails to find meaningful pKas from fits
               otherwise returns tuple of results""" #print d #print E1.getDataset(d) #if model1 != model2: #    print 'different models' #return None #,strict=False) #,strict=False) #print d, p1val, p2val, perr1, perr2 #print errcutoff
cls
E1
E2
d
titratable
errcutoff