pKaTool/stab_fit/myfitter.py
def test10R():
    """pKa fitting from kcats using substr depletion"""
    path = 'fergal_10R'    
    folders = ['fergal_10R/10RWT','fergal_10R/U33W1']
    pkas=[]
    for path in folders:
        fig=plt.figure(figsize=(8,8))
        i=1
        data = []
        ax1=None      
        for f in os.listdir(path):       
            if os.path.splitext(f)[1] != '.csv': continue
            cr = csv.reader(open(os.path.join(path,f),'r'))
            ph=float(f.split(' ')[1])        
            cols = len(cr.next())-1
            print path, f, ph, '%s cols' %cols
            vals = [r for r in cr]
            #may be several replicates
            for c in range(0,cols,2):
                x = [float(r[c]) for r in vals]
                y = [float(r[c+1]) for r in vals]
            
                #fit
                M = max(y)
                F=fitter(depletion,[M,1,1],x,y)
                F.fit()
                D=F.params[1]
                print 'D',D
                if ph==9.0 and D>6: continue
                data.append((ph,D))
                if c==0:
                    ax=fig.add_subplot(4,4,i,sharey=ax1)
                    i+=1
                if ax1==None: ax1=ax
                F.plot(ax)
                ax.set_title(ph)
            
        #fit pKa
        fig.subplots_adjust(wspace=0.4,hspace=0.4)
        x,y=zip(*data)
        F=fitter(hh1pka,[5,2,0],x,y)
        F.fit()
        pkas.append(F.params[0])
        F.plot()
        #res = F.estimateUncertainty(x,y,[5,2,0],xerr=0.1,yerr=0.2,runs=10)        
        pickle.dump(data,open(os.path.basename(path)+'.pickle','w'))
    print pkas    
    return
pKa fitting from kcats using substr depletion
pKa fitting from kcats using substr depletion
pKa fitting from kcats using substr depletion
def test10R():
    path = 'fergal_10R'    
    folders = ['fergal_10R/10RWT','fergal_10R/U33W1']
    pkas=[]
    for path in folders:
        fig=plt.figure(figsize=(8,8))
        i=1
        data = []
        ax1=None      
        for f in os.listdir(path):       
            if os.path.splitext(f)[1] != '.csv': continue
            cr = csv.reader(open(os.path.join(path,f),'r'))
            ph=float(f.split(' ')[1])        
            cols = len(cr.next())-1
            print path, f, ph, '%s cols' %cols
            vals = [r for r in cr]
            for c in range(0,cols,2):
                x = [float(r[c]) for r in vals]
                y = [float(r[c+1]) for r in vals]
                M = max(y)
                F=fitter(depletion,[M,1,1],x,y)
                F.fit()
                D=F.params[1]
                print 'D',D
                if ph==9.0 and D>6: continue
                data.append((ph,D))
                if c==0:
                    ax=fig.add_subplot(4,4,i,sharey=ax1)
                    i+=1
                if ax1==None: ax1=ax
                F.plot(ax)
                ax.set_title(ph)
         pKa
        fig.subplots_adjust(wspace=0.4,hspace=0.4)
        x,y=zip(*data)
        F=fitter(hh1pka,[5,2,0],x,y)
        F.fit()
        pkas.append(F.params[0])
        F.plot()
        pickle.dump(data,open(os.path.basename(path)+'.pickle','w'))
    print pkas    
    return
def test10R ( ) : path = 'fergal_10R' folders = [ 'fergal_10R/10RWT' , 'fergal_10R/U33W1' ] pkas = [ ] for path in folders : fig = plt . figure ( figsize = ( 8 , 8 ) ) i = 1 data = [ ] ax1 = None for f in os . listdir ( path ) : if os . path . splitext ( f ) [ 1 ] != '.csv' : continue cr = csv . reader ( open ( os . path . join ( path , f ) , 'r' ) ) ph = float ( f . split ( ' ' ) [ 1 ] ) cols = len ( cr . next ( ) ) - 1 print path , f , ph , '%s cols' % cols vals = [ r for r in cr ] for c in range ( 0 , cols , 2 ) : x = [ float ( r [ c ] ) for r in vals ] y = [ float ( r [ c + 1 ] ) for r in vals ] M = max ( y ) F = fitter ( depletion , [ M , 1 , 1 ] , x , y ) F . fit ( ) D = F . params [ 1 ] print 'D' , D if ph == 9.0 and D > 6 : continue data . append ( ( ph , D ) ) if c == 0 : ax = fig . add_subplot ( 4 , 4 , i , sharey = ax1 ) i += 1 if ax1 == None : ax1 = ax F . plot ( ax ) ax . set_title ( ph ) fig . subplots_adjust ( wspace = 0.4 , hspace = 0.4 ) x , y = zip ( * data ) F = fitter ( hh1pka , [ 5 , 2 , 0 ] , x , y ) F . fit ( ) pkas . append ( F . params [ 0 ] ) F . plot ( ) pickle . dump ( data , open ( os . path . basename ( path ) + '.pickle' , 'w' ) ) print pkas return
pKa fitting from kcats using substr depletion
pKa fitting from kcats using substr depletion
"""pKa fitting from kcats using substr depletion""" #may be several replicates #fit #fit pKa #res = F.estimateUncertainty(x,y,[5,2,0],xerr=0.1,yerr=0.2,runs=10)        