def fitFunction(x,param): #unpack position vector x1 = x[0:size1] x2 = x[size1:size2end] x3 = x[size2end:size3end] #create rate vectors y1 = np.zeros(size1) y2 = np.zeros(size2) y3 = np.zeros(size3) #get rates for index,item in enumerate(x1): y1[index] = SDMMrates(0,int(item),N,dGBP,dGp,dGBM,dGassoc,dGMM,param,c,mode) for index,item in enumerate(x2): y2[index] = SDMMrates(2,int(item),N,dGBP,dGp,dGBM,dGassoc,dGMM,param,c,mode) for index,item in enumerate(x3): y3[index] = SDMMrates(11,int(item),N,dGBP,dGp,dGBM,dGassoc,dGMM,param,c,mode) #recombine rate vector out = np.concatenate((y1,y2,y3)) return out
def fitFunction(x, param1, param2, param3, param4): #unpack position vector x1 = x[0:size1] x2 = x[size1:size2end] x3 = x[size2end:size3end] x4 = x[size3end:size4end] x5 = x[size4end:size5end] x6 = x[size5end:size6end] #create rate vectors y1 = np.zeros(size1) y2 = np.zeros(size2) y3 = np.zeros(size3) y4 = np.zeros(size4) y5 = np.zeros(size5) y6 = np.zeros(size6) #get rates for index, item in enumerate(x1): y1[index] = SDMMrates(int(item), 10, N, dGBP, param1, param2, param3, param4, kbm, c, mode) for index, item in enumerate(x2): y2[index] = SDMMrates(int(item), 9, N, dGBP, param1, param2, param3, param4, kbm, c, mode) for index, item in enumerate(x3): y3[index] = SDMMrates(int(item), 8, N, dGBP, param1, param2, param3, param4, kbm, c, mode) for index, item in enumerate(x4): y4[index] = SDMMrates(int(item), 7, N, dGBP, param1, param2, param3, param4, kbm, c, mode) for index, item in enumerate(x5): y5[index] = SDMMrates(int(item), 6, N, dGBP, param1, param2, param3, param4, kbm, c, mode) for index, item in enumerate(x6): y6[index] = SDMMrates(int(item), 5, N, dGBP, param1, param2, param3, param4, kbm, c, mode) #calculate relative rates y1 = y1 / y1[0] y2 = y2 / y2[0] y3 = y3 / y3[0] y4 = y4 / y4[0] y5 = y5 / y5[0] y6 = y6 / y6[0] #recombine rate vector out = np.concatenate((y1, y2, y3, y4, y5, y6)) return out
print('kbm ={:.1e}, error: {:.0e}'.format(popt[0],pErr[0])) ############################################################################## ###create mismatch position dependence (Figure 3B)############################ SDratesP = np.zeros(size1) SDratesMM2 = np.zeros(size2) SDratesMM11 = np.zeros(size3) for index,item in enumerate(xdataP): SDratesP[index] = SDMMrates(0,int(item),N,dGBP,dGp,dGBM,dGassoc,dGMM,*popt,c,mode) for index,item in enumerate(xdataMM2): SDratesMM2[index] = SDMMrates(2,int(item),N,dGBP,dGp,dGBM,dGassoc,dGMM,*popt,c,mode) for index,item in enumerate(xdataMM11): SDratesMM11[index] = SDMMrates(11,int(item),N,dGBP,dGp,dGBM,dGassoc,dGMM,*popt,c,mode) plt.semilogy(xdataP,SDratesP) plt.semilogy(xdataMM2,SDratesMM2) plt.semilogy(xdataMM11,SDratesMM11) ############################################################################## ###plot measurements (Figure 3B)############################
dGBP = 2.52 #base pairing energy dGp = 3.5 #branch migration initiation energy dGBM = 7.4 #branch migration penalty dGassoc = 2.5 #association energy dGMM = 9.5 #mismatch penalty #define time constant kbm = 36E3 #branch migration rate constant ############################################################################## ###single value output######################################################## toeholdLength = 10 mismatchPosition = 2 mismatchPosition2 = 20 SDrate = SDMMrates(mismatchPosition2, toeholdLength, N, dGBP, dGp, dGBM, dGassoc, dGMM, kbm, c, mode, mismatchPosition) print( 'mean reaction time: {:.1f} s (toehold length: {:.0f} mismatch positions: {:.0f} and {:.0f})' .format(1 / SDrate, toeholdLength, mismatchPosition, mismatchPosition2)) ############################################################################## ###create mismatch position dependence ####################################### position = np.arange(1, N, 1) SDrates = np.zeros(N) for mismatchPosition2 in range(N): SDrates[mismatchPosition2] = SDMMrates(mismatchPosition2, toeholdLength, N, dGBP, dGp, dGBM, dGassoc, dGMM, kbm, c, mode, mismatchPosition)
I1OT = 0.0 I2OT = 0.0 O = 0.0 I1T = 0.0 I2T = 0.0 I2I1T = 0.0 I1I2T = 0.0 c = 1.0E-9 #can be arbitrary, since k1 and k2 are concentration independent k11p, k11m, k12 = SDMMrates(18, 4, 20, dGBP, dGp, dGBM, dGassoc, dGMM, kbm, c, "singleIncumbent", output=3) k21p, k21m, k22 = SDMMrates(3, 4, 20, dGBP, dGp, dGBM, dGassoc, dGMM, kbm, c,
#initiate samples toe3Samples = np.zeros((sampleSize, N)) toe4Samples = np.zeros((sampleSize, N)) toe5Samples = np.zeros((sampleSize, N)) #initiate produce parameter samples parameterSamples = np.random.multivariate_normal(popt, pcov, sampleSize) #calculate MM position dependence for each set of parameters i = 0 for pi in parameterSamples: for mismatchPosition in range(1, N): toe3Samples[i, mismatchPosition] = SDMMrates(mismatchPosition, 3, N, dGBP, *pi, kbm, c, mode) toe4Samples[i, mismatchPosition] = SDMMrates(mismatchPosition, 4, N, dGBP, *pi, kbm, c, mode) toe5Samples[i, mismatchPosition] = SDMMrates(mismatchPosition, 5, N, dGBP, *pi, kbm, c, mode) #calculate relative rate toe3Samples[i, :] = toe3Samples[i, :] / SDMMrates(0, 3, N, dGBP, *pi, kbm, c, mode) toe4Samples[i, :] = toe4Samples[i, :] / SDMMrates(0, 4, N, dGBP, *pi, kbm, c, mode) toe5Samples[i, :] = toe5Samples[i, :] / SDMMrates(0, 5, N, dGBP, *pi, kbm, c, mode) i = i + 1
print('dGp ={:.1f}, error: {:.1f}'.format(popt[0], pErr[0])) print('dGBM ={:.1f}, error: {:.1f}'.format(popt[1], pErr[1])) print('dGassoc ={:.1f}, error: {:.1f}'.format(popt[2], pErr[2])) print('dGMM ={:.1f}, error: {:.1f}'.format(popt[3], pErr[3])) ############################################################################## ###create mismatch position dependence (Figure 3A)############################ position = np.arange(1, N, 1) for toeholdLength in range(5, 11): SDrates = np.zeros(N) for mismatchPosition in range(N): SDrates[mismatchPosition] = SDMMrates(mismatchPosition, toeholdLength, N, dGBP, *popt, kbm, c, mode) plt.semilogy(position, SDrates[1:N] / SDrates[0]) ############################################################################## ###plot measurements (Figure 3A)############################ #restart color cycle plt.gca().set_prop_cycle(None) #plot data plt.errorbar(xdataT05[1:], ydataT05[1:], yerr=ydataT05[1:] * error, fmt='v') plt.errorbar(xdataT06[1:], ydataT06[1:], yerr=ydataT06[1:] * error, fmt='D') plt.errorbar(xdataT07[1:], ydataT07[1:], yerr=ydataT07[1:] * error, fmt='>') plt.errorbar(xdataT08[1:], ydataT08[1:], yerr=ydataT08[1:] * error, fmt='o') plt.errorbar(xdataT09[1:], ydataT09[1:], yerr=ydataT09[1:] * error, fmt='^')
#define energy parameters dGBP = 2.52 #base pairing energy dGp = 3.5 #branch migration initiation energy dGBM = 7.4 #branch migration penalty dGassoc = 2.5 #association energy dGMM = 9.5 #mismatch penalty #define time constant kbm = 36E3 #branch migration rate constant ############################################################################## ###single value output######################################################## toeholdLength = 4 mismatchPosition = 5 #position 0 results in no mismatch meanSDrate = SDMMrates(mismatchPosition, toeholdLength, N, dGBP, dGp, dGBM, dGassoc, dGMM, kbm, c, mode) print( 'mean reaction time: {:.1f} s (toehold length: {:.0f} mismatch position: {:.0f})' .format(1 / meanSDrate, toeholdLength, mismatchPosition)) ############################################################################## ###create mismatch position dependence ####################################### position = np.arange(1, N, 1) SDrates = np.zeros(N) for mismatchPosition in range(N): SDrates[mismatchPosition] = SDMMrates(mismatchPosition, toeholdLength, N, dGBP, dGp, dGBM, dGassoc, dGMM, kbm, c, mode)
kbm = 36E3 #branch migration rate constant ############################################################################## ###single value output######################################################## N = 17 #number of displacement positions toeholdLength = 4 mismatchPosition = 5 #position 0 results in no mismatch #initiate data vector dataPoints = 100 keff = np.zeros(dataPoints) kfirst = np.zeros(dataPoints) ksecond = np.zeros(dataPoints) c = np.logspace(-6,-1,dataPoints) for i in range(dataPoints): keff[i] , ksecond[i] , kfirst[i] , cThresh = SDMMrates(mismatchPosition,toeholdLength,N,dGBP,dGp,dGBM,dGassoc,dGMM,kbm,c[i],mode,output=2) plt.loglog(c,keff) plt.loglog(c,kfirst,'k--') plt.loglog(c,ksecond*c,'k--') plt.axvline(x=cThresh,color='grey',linestyle='dotted') plt.ylim(np.min(keff)*0.9,np.max(keff)*2) plt.xlabel("Concentration (M)") plt.ylabel("Displacement rate (1/s)")
sampleSize = 1000 #initiate samples singleMMSamples = np.zeros((sampleSize,N)) doubleMMSamples = np.zeros((sampleSize,N)) #initiate produce parameter samples parameterSamples = np.random.multivariate_normal(popt, pcov,sampleSize) #calculate MM position dependence for each set of parameters i=0 for pi in parameterSamples: for mismatchPosition in range(1,N): singleMMSamples[i,mismatchPosition] = SDMMrates(mismatchPosition,toeholdLength,N,dGBP,*pi,kbm,c,mode,0) doubleMMSamples[i,mismatchPosition] = SDMMrates(mismatchPosition,toeholdLength,N,dGBP,*pi,kbm,c,mode,2) #calculate relative rate singleMMSamples[i,:] = singleMMSamples[i,:] / SDMMrates(0,toeholdLength,N,dGBP,*pi,kbm,c,mode,0) doubleMMSamples[i,:] = doubleMMSamples[i,:] / SDMMrates(0,toeholdLength,N,dGBP,*pi,kbm,c,mode,0) i = i + 1 #form array of samples singleMMArray = np.asarray(singleMMSamples) doubleMMArray = np.asarray(doubleMMSamples) #calculate upper and lower percentiles