pKa/effective_dielectric_constant.py
def analyse_one_pdbfile(pdbfile,bigdict=None):
    """Load the MC.tabdata file and the sugelm file to determine the
    effective dielectric constant for single mutations"""
    mcfile=pdbfile+'.MC.tabdata'
    sugelm=pdbfile+'.sugelm_data'
    print 'Loading:'
    print mcfile
    print sugelm
    print
    import os
    if not os.path.isfile(mcfile):
        return [],[],0
    if not os.path.isfile(sugelm):
        return [],[],0
    if bigdict:
        fd=open(bigdict)
        import pickle
        big_dict=pickle.load(fd)
        fd.close()
    #
    # Get the PDB file
    #
    import pKaTool.pKaIO
    P=pKaTool.pKaIO.pKaIO(pdbfile)
    # Matrix
    matrix=P.read_matrix()
    # Intrinsic pKa values for mutated residues
    intpkafile=pdbfile+'.intpka_data'
    fd=open(intpkafile)
    import pickle
    mutant_intpkas=pickle.load(fd)
    fd.close()
    #
    # Read the PDB file
    #
    import Protool
    PDB=Protool.structureIO()
    PDB.readpdb(pdbfile)
    #
    # Start calculating
    #
    mc=getfile(mcfile)
    su=getfile(sugelm)['data']
    print 'Number of mutations in sugelm',len(su.keys())
    print 'Number of mutations in tabdata',len(mc.keys())

    sites={}
    import string
    for mutation in su.keys():
        orgres=mutation.split(':')[:2]
        orgres=string.join(orgres,':')
        sites[orgres]=1
    print 'Number of unique sites',len(sites.keys())
    #
    # Should we do the full solutions or just single mutations?
    #
    if bigdict:
        print 'Getting mutations from bigdict'
        mutations=[]
        for key in big_dict.keys():
            pdbfile_name=os.path.split(pdbfile)[1]
            pos=key.find(pdbfile_name)
            if pos!=-1:
                target=key[pos+len(pdbfile_name):]
                for muts,dpka in big_dict[key]:
                    mutations.append([target,muts,dpka])
    else:
        mutations=mc.keys()
    #
    # Load the wild type PDB file
    #
    X_wt=Protool.structureIO()
    X_wt.readpdb(pdbfile)
    #
    # go on, calculate the difference between the MC result and the phi result
    #
    mutations.sort()
    phi=[]
    real=[]
    ratio=[]
    dist=[]
    epses_dpKa=[]
    epses=[]
    import types
    for mutant in mutations:
        if type(mutant) is types.ListType:
            #
            # Deal with multiple mutations
            #
            sum_phidpka=0.0
            sum_MCdpka=0.0
            mutations=mutant[1]
            target=mutant[0]
            rdpka=mutant[2]
            if len(mutations)<2:
                continue
            for mutation in mutations:
                phidpka,MCdpka=get_phidpka(mutation=mutation,target=target,su=su,mc=mc,matrix=matrix)
                sum_phidpka=sum_phidpka+phidpka
                sum_MCdpka=sum_MCdpka+MCdpka
            phi.append(sum_phidpka)
            real.append(rdpka)
            #if abs(rdpka-sum_phidpka)>1.0:
            #    print 'T: %15s phidpka %5.1f rdpka: %5.1f muts: %s ' %(target,sum_phidpka,rdpka,str(mutations))
        else:
            #
            # This is for looking at single mutations
            #
            import Design_pKa_help
            X=Design_pKa_help.pKa_dist(pdbfile)
            targets=mc[mutant].keys()
            targets.sort()
            #
            # Load the mutant PDB file if we can
            #
            import os
            pdbdir=pdbfile+'.pdbs'
            mutfile=os.path.join(pdbdir,mutant+'.pdb')
            if os.path.isfile(mutfile):
                import Protool
                X_mut=Protool.structureIO_fast()
                X_mut.readpdb(mutfile)
            else:
                X_mut=None
            #
            # Loop over all targets
            #
            for target in targets:
                #
                # Get the distance between the target and the mutatn
                #
                targetnum=':'+target.split(':')[1]
                mutantnum=':'+mutant.split(':')[1]
                distance=X.get_min_dist(target,mutant)
                #
                # Get the delta pKa values
                #
                phidpka,rdpka=get_phidpka(mutation=mutant,target=target,su=su,mc=mc,matrix=matrix)
                if not rdpka:
                    continue
                if abs(phidpka)>=0.0001 and abs(rdpka)<20.0:
                    phi.append(phidpka)
                    real.append(abs(rdpka))
                    dist.append(distance)
                    #
                    # Effective eps
                    #
                    eps_eff,distance_eps=get_effective_eps(target,mutant,abs(rdpka),X_mut=X_mut,X_wt=X_wt,phidpka=phidpka)
                    if eps_eff:
                        epses.append(eps_eff)
                        #epses_dpKa.append(abs(rdpka))
                        epses_dpKa.append(distance_eps)
                    #ratio.append(rdpka/phidpka)
                    #print phidpka,rdpka
    tabdata_muts=len(mutations)
    return phi,real,tabdata_muts,dist,epses_dpKa,epses
Load the MC.tabdata file and the sugelm file to determine the
    effective dielectric constant for single mutations
Load the MC.tabdata file and the sugelm file to determine the
effective dielectric constant for single mutations
Load the MC . tabdata file and the sugelm file to determine the effective dielectric constant for single mutations
def analyse_one_pdbfile(pdbfile,bigdict=None):
    mcfile=pdbfile+'.MC.tabdata'
    sugelm=pdbfile+'.sugelm_data'
    print 'Loading:'
    print mcfile
    print sugelm
    print
    import os
    if not os.path.isfile(mcfile):
        return [],[],0
    if not os.path.isfile(sugelm):
        return [],[],0
    if bigdict:
        fd=open(bigdict)
        import pickle
        big_dict=pickle.load(fd)
        fd.close()
     Get the PDB file
    import pKaTool.pKaIO
    P=pKaTool.pKaIO.pKaIO(pdbfile)
     Matrix
    matrix=P.read_matrix()
     Intrinsic pKa values for mutated residues
    intpkafile=pdbfile+'.intpka_data'
    fd=open(intpkafile)
    import pickle
    mutant_intpkas=pickle.load(fd)
    fd.close()
     Read the PDB file
    import Protool
    PDB=Protool.structureIO()
    PDB.readpdb(pdbfile)
     Start calculating
    mc=getfile(mcfile)
    su=getfile(sugelm)['data']
    print 'Number of mutations in sugelm',len(su.keys())
    print 'Number of mutations in tabdata',len(mc.keys())
    sites={}
    import string
    for mutation in su.keys():
        orgres=mutation.split(':')[:2]
        orgres=string.join(orgres,':')
        sites[orgres]=1
    print 'Number of unique sites',len(sites.keys())
     Should we do the full solutions or just single mutations?
    if bigdict:
        print 'Getting mutations from bigdict'
        mutations=[]
        for key in big_dict.keys():
            pdbfile_name=os.path.split(pdbfile)[1]
            pos=key.find(pdbfile_name)
            if pos!=-1:
                target=key[pos+len(pdbfile_name):]
                for muts,dpka in big_dict[key]:
                    mutations.append([target,muts,dpka])
    else:
        mutations=mc.keys()
     Load the wild type PDB file
    X_wt=Protool.structureIO()
    X_wt.readpdb(pdbfile)
     go on, calculate the difference between the MC result and the phi result
    mutations.sort()
    phi=[]
    real=[]
    ratio=[]
    dist=[]
    epses_dpKa=[]
    epses=[]
    import types
    for mutant in mutations:
        if type(mutant) is types.ListType:
             Deal with multiple mutations
            sum_phidpka=0.0
            sum_MCdpka=0.0
            mutations=mutant[1]
            target=mutant[0]
            rdpka=mutant[2]
            if len(mutations)<2:
                continue
            for mutation in mutations:
                phidpka,MCdpka=get_phidpka(mutation=mutation,target=target,su=su,mc=mc,matrix=matrix)
                sum_phidpka=sum_phidpka+phidpka
                sum_MCdpka=sum_MCdpka+MCdpka
            phi.append(sum_phidpka)
            real.append(rdpka)
            if abs(rdpka-sum_phidpka)>1.0:
                print 'T: %15s phidpka %5.1f rdpka: %5.1f muts: %s ' %(target,sum_phidpka,rdpka,str(mutations))
        else:
             This is for looking at single mutations
            import Design_pKa_help
            X=Design_pKa_help.pKa_dist(pdbfile)
            targets=mc[mutant].keys()
            targets.sort()
             Load the mutant PDB file if we can
            import os
            pdbdir=pdbfile+'.pdbs'
            mutfile=os.path.join(pdbdir,mutant+'.pdb')
            if os.path.isfile(mutfile):
                import Protool
                X_mut=Protool.structureIO_fast()
                X_mut.readpdb(mutfile)
            else:
                X_mut=None
             Loop over all targets
            for target in targets:
                 Get the distance between the target and the mutatn
                targetnum=':'+target.split(':')[1]
                mutantnum=':'+mutant.split(':')[1]
                distance=X.get_min_dist(target,mutant)
                 Get the delta pKa values
                phidpka,rdpka=get_phidpka(mutation=mutant,target=target,su=su,mc=mc,matrix=matrix)
                if not rdpka:
                    continue
                if abs(phidpka)>=0.0001 and abs(rdpka)<20.0:
                    phi.append(phidpka)
                    real.append(abs(rdpka))
                    dist.append(distance)
                     Effective eps
                    eps_eff,distance_eps=get_effective_eps(target,mutant,abs(rdpka),X_mut=X_mut,X_wt=X_wt,phidpka=phidpka)
                    if eps_eff:
                        epses.append(eps_eff)
                        epses_dpKa.append(abs(rdpka))
                        epses_dpKa.append(distance_eps)
                    ratio.append(rdpka/phidpka)
                    print phidpka,rdpka
    tabdata_muts=len(mutations)
    return phi,real,tabdata_muts,dist,epses_dpKa,epses
def analyse_one_pdbfile ( pdbfile , bigdict = None ) : mcfile = pdbfile + '.MC.tabdata' sugelm = pdbfile + '.sugelm_data' print 'Loading:' print mcfile print sugelm print import os if not os . path . isfile ( mcfile ) : return [ ] , [ ] , 0 if not os . path . isfile ( sugelm ) : return [ ] , [ ] , 0 if bigdict : fd = open ( bigdict ) import pickle big_dict = pickle . load ( fd ) fd . close ( ) import pKaTool . pKaIO P = pKaTool . pKaIO . pKaIO ( pdbfile ) matrix = P . read_matrix ( ) intpkafile = pdbfile + '.intpka_data' fd = open ( intpkafile ) import pickle mutant_intpkas = pickle . load ( fd ) fd . close ( ) import Protool PDB = Protool . structureIO ( ) PDB . readpdb ( pdbfile ) mc = getfile ( mcfile ) su = getfile ( sugelm ) [ 'data' ] print 'Number of mutations in sugelm' , len ( su . keys ( ) ) print 'Number of mutations in tabdata' , len ( mc . keys ( ) ) sites = { } import string for mutation in su . keys ( ) : orgres = mutation . split ( ':' ) [ : 2 ] orgres = string . join ( orgres , ':' ) sites [ orgres ] = 1 print 'Number of unique sites' , len ( sites . keys ( ) ) if bigdict : print 'Getting mutations from bigdict' mutations = [ ] for key in big_dict . keys ( ) : pdbfile_name = os . path . split ( pdbfile ) [ 1 ] pos = key . find ( pdbfile_name ) if pos != - 1 : target = key [ pos + len ( pdbfile_name ) : ] for muts , dpka in big_dict [ key ] : mutations . append ( [ target , muts , dpka ] ) else : mutations = mc . keys ( ) X_wt = Protool . structureIO ( ) X_wt . readpdb ( pdbfile ) mutations . sort ( ) phi = [ ] real = [ ] ratio = [ ] dist = [ ] epses_dpKa = [ ] epses = [ ] import types for mutant in mutations : if type ( mutant ) is types . ListType : sum_phidpka = 0.0 sum_MCdpka = 0.0 mutations = mutant [ 1 ] target = mutant [ 0 ] rdpka = mutant [ 2 ] if len ( mutations ) < 2 : continue for mutation in mutations : phidpka , MCdpka = get_phidpka ( mutation = mutation , target = target , su = su , mc = mc , matrix = matrix ) sum_phidpka = sum_phidpka + phidpka sum_MCdpka = sum_MCdpka + MCdpka phi . append ( sum_phidpka ) real . append ( rdpka ) else : import Design_pKa_help X = Design_pKa_help . pKa_dist ( pdbfile ) targets = mc [ mutant ] . keys ( ) targets . sort ( ) import os pdbdir = pdbfile + '.pdbs' mutfile = os . path . join ( pdbdir , mutant + '.pdb' ) if os . path . isfile ( mutfile ) : import Protool X_mut = Protool . structureIO_fast ( ) X_mut . readpdb ( mutfile ) else : X_mut = None for target in targets : targetnum = ':' + target . split ( ':' ) [ 1 ] mutantnum = ':' + mutant . split ( ':' ) [ 1 ] distance = X . get_min_dist ( target , mutant ) phidpka , rdpka = get_phidpka ( mutation = mutant , target = target , su = su , mc = mc , matrix = matrix ) if not rdpka : continue if abs ( phidpka ) >= 0.0001 and abs ( rdpka ) < 20.0 : phi . append ( phidpka ) real . append ( abs ( rdpka ) ) dist . append ( distance ) eps_eff , distance_eps = get_effective_eps ( target , mutant , abs ( rdpka ) , X_mut = X_mut , X_wt = X_wt , phidpka = phidpka ) if eps_eff : epses . append ( eps_eff ) epses_dpKa . append ( distance_eps ) tabdata_muts = len ( mutations ) return phi , real , tabdata_muts , dist , epses_dpKa , epses
Load the MC.tabdata file and the sugelm file to determine the
effective dielectric constant for single mutations
Load the MC . tabdata file and the sugelm file to determine the effective dielectric constant for single mutations
"""Load the MC.tabdata file and the sugelm file to determine the
    effective dielectric constant for single mutations""" # # Get the PDB file # # Matrix # Intrinsic pKa values for mutated residues # # Read the PDB file # # # Start calculating # # # Should we do the full solutions or just single mutations? # # # Load the wild type PDB file # # # go on, calculate the difference between the MC result and the phi result # # # Deal with multiple mutations # #if abs(rdpka-sum_phidpka)>1.0: #    print 'T: %15s phidpka %5.1f rdpka: %5.1f muts: %s ' %(target,sum_phidpka,rdpka,str(mutations)) # # This is for looking at single mutations # # # Load the mutant PDB file if we can # # # Loop over all targets # # # Get the distance between the target and the mutatn # # # Get the delta pKa values # # # Effective eps # #epses_dpKa.append(abs(rdpka)) #ratio.append(rdpka/phidpka) #print phidpka,rdpka
pdbfile
bigdict