PEATDB/Ekin/Titration.py
def findpKas(cls, E, titratable=True, reliable=True, minspan=0.06):
        """Get pkas for an ekin project"""
        pkasdict = {}
        for d in E.datasets:
            resdata = E.getMetaData(d)
            if not resdata.has_key('residue') or not resdata.has_key('res_num'):
                #print d
                continue
            res = resdata['residue']
            try:
                atom = resdata['atom']
            except:
                atom = resdata['atom_type']

            resnum = resdata['res_num']
            fitdata = E.getFitData(d)

            if titratable == True and not res in cls.titratable:
                continue
            if fitdata == None or len(fitdata)<2:
                continue
            if reliable == True:
                p,pval,sp = cls.getMainpKa(fitdata, res=res, minspan=minspan, maxspan=5)
                if pval == None:
                    continue
                pkas = [(p,pval,sp)]
            else:
                pnames, pvals, spans = cls.getallpKas(fitdata, minspan=minspan)
                if pnames == None:
                    continue
                pkas = zip(pnames, pvals, spans)

            if len(pkas)>0 and pkas!=None:
                pkasdict[d]={}
                pkasdict[d]['res']=res
                pkasdict[d]['resnum']=resnum
                pkasdict[d]['atom']=atom
                pkasdict[d]['model']=fitdata['model']
                for plst in pkas:
                    (p, pval, sp) = plst
                    s = 'span' + p.strip('pKa')
                    if E.getMeta(d, 'exp_errors')==None:
                        #normally we should have stored this already
                        ferrs = E.estimateExpUncertainty(d, runs=10, xuncert=0.2, yuncert=0.1)
                        E.addMeta(d, 'exp_errors', ferrs)
                    try:
                        pkaerr = round(E.getMeta(d, 'exp_errors')[p][1],4)
                        spanerr = round(E.getMeta(d, 'exp_errors')[s][1],4)
                    except:
                        #print 'failed to get exp errs'
                        pkaerr = 0.0
                        spanerr = 0.0
                    #print  d, plst#, pkaerr, spanerr
                    if reliable==True and (pkaerr > 1.5 or spanerr > sp):
                        #print d, 'exp error too big, omitting: %s %s' %(pkaerr, spanerr)
                        continue
                    pkasdict[d][p]={}
                    pkasdict[d][p][p]=pval
                    pkasdict[d][p]['span']=sp
                    pkasdict[d][p]['pkaerror']=pkaerr
                    pkasdict[d][p]['spanerror']=spanerr

        return pkasdict
Get pkas for an ekin project
Get pkas for an ekin project
Get pkas for an ekin project
def findpKas(cls, E, titratable=True, reliable=True, minspan=0.06):
        pkasdict = {}
        for d in E.datasets:
            resdata = E.getMetaData(d)
            if not resdata.has_key('residue') or not resdata.has_key('res_num'):
                continue
            res = resdata['residue']
            try:
                atom = resdata['atom']
            except:
                atom = resdata['atom_type']
            resnum = resdata['res_num']
            fitdata = E.getFitData(d)
            if titratable == True and not res in cls.titratable:
                continue
            if fitdata == None or len(fitdata)<2:
                continue
            if reliable == True:
                p,pval,sp = cls.getMainpKa(fitdata, res=res, minspan=minspan, maxspan=5)
                if pval == None:
                    continue
                pkas = [(p,pval,sp)]
            else:
                pnames, pvals, spans = cls.getallpKas(fitdata, minspan=minspan)
                if pnames == None:
                    continue
                pkas = zip(pnames, pvals, spans)
            if len(pkas)>0 and pkas!=None:
                pkasdict[d]={}
                pkasdict[d]['res']=res
                pkasdict[d]['resnum']=resnum
                pkasdict[d]['atom']=atom
                pkasdict[d]['model']=fitdata['model']
                for plst in pkas:
                    (p, pval, sp) = plst
                    s = 'span' + p.strip('pKa')
                    if E.getMeta(d, 'exp_errors')==None:
                        ferrs = E.estimateExpUncertainty(d, runs=10, xuncert=0.2, yuncert=0.1)
                        E.addMeta(d, 'exp_errors', ferrs)
                    try:
                        pkaerr = round(E.getMeta(d, 'exp_errors')[p][1],4)
                        spanerr = round(E.getMeta(d, 'exp_errors')[s][1],4)
                    except:
                        pkaerr = 0.0
                        spanerr = 0.0
                    if reliable==True and (pkaerr > 1.5 or spanerr > sp):
                        , 'exp error too big, omitting: %s %s' %(pkaerr, spanerr)
                        continue
                    pkasdict[d][p]={}
                    pkasdict[d][p][p]=pval
                    pkasdict[d][p]['span']=sp
                    pkasdict[d][p]['pkaerror']=pkaerr
                    pkasdict[d][p]['spanerror']=spanerr
        return pkasdict
def findpKas ( cls , E , titratable = True , reliable = True , minspan = 0.06 ) : pkasdict = { } for d in E . datasets : resdata = E . getMetaData ( d ) if not resdata . has_key ( 'residue' ) or not resdata . has_key ( 'res_num' ) : continue res = resdata [ 'residue' ] try : atom = resdata [ 'atom' ] except : atom = resdata [ 'atom_type' ] resnum = resdata [ 'res_num' ] fitdata = E . getFitData ( d ) if titratable == True and not res in cls . titratable : continue if fitdata == None or len ( fitdata ) < 2 : continue if reliable == True : p , pval , sp = cls . getMainpKa ( fitdata , res = res , minspan = minspan , maxspan = 5 ) if pval == None : continue pkas = [ ( p , pval , sp ) ] else : pnames , pvals , spans = cls . getallpKas ( fitdata , minspan = minspan ) if pnames == None : continue pkas = zip ( pnames , pvals , spans ) if len ( pkas ) > 0 and pkas != None : pkasdict [ d ] = { } pkasdict [ d ] [ 'res' ] = res pkasdict [ d ] [ 'resnum' ] = resnum pkasdict [ d ] [ 'atom' ] = atom pkasdict [ d ] [ 'model' ] = fitdata [ 'model' ] for plst in pkas : ( p , pval , sp ) = plst s = 'span' + p . strip ( 'pKa' ) if E . getMeta ( d , 'exp_errors' ) == None : ferrs = E . estimateExpUncertainty ( d , runs = 10 , xuncert = 0.2 , yuncert = 0.1 ) E . addMeta ( d , 'exp_errors' , ferrs ) try : pkaerr = round ( E . getMeta ( d , 'exp_errors' ) [ p ] [ 1 ] , 4 ) spanerr = round ( E . getMeta ( d , 'exp_errors' ) [ s ] [ 1 ] , 4 ) except : pkaerr = 0.0 spanerr = 0.0 if reliable == True and ( pkaerr > 1.5 or spanerr > sp ) : continue pkasdict [ d ] [ p ] = { } pkasdict [ d ] [ p ] [ p ] = pval pkasdict [ d ] [ p ] [ 'span' ] = sp pkasdict [ d ] [ p ] [ 'pkaerror' ] = pkaerr pkasdict [ d ] [ p ] [ 'spanerror' ] = spanerr return pkasdict
Get pkas for an ekin project
Get pkas for an ekin project
"""Get pkas for an ekin project""" #print d #normally we should have stored this already #print 'failed to get exp errs' #print  d, plst#, pkaerr, spanerr #print d, 'exp error too big, omitting: %s %s' %(pkaerr, spanerr)
cls
E
titratable
reliable
minspan