if i == 1:
continue # poor calibration bumps for the older cantilevers
- print >> kf, "K(%d) = %g +/- %g, (# %d)" \
- % (i, avgK[i], stdK[i], numK[i])
+ kf.write('K({}) = {} +/- {}, (# {})\n'.format(
+ i, avgK[i], stdK[i], numK[i]))
kf.close()
return (avgK, stdK, numK)
Vs = FofV.keys()
Vs.sort()
af = open(AVGFILE, 'w')
- print >> af, '#'+'\t'.join(\
- ['Pulling speed (nm/s)','Spring constant (pN/nm)',
- 'Mean force (pN)','Std. force (pN)','Events (#)'])
+ af.write('{}{}\n'.format(
+ '#', '\t'.join(
+ ['Pulling speed (nm/s)','Spring constant (pN/nm)',
+ 'Mean force (pN)','Std. force (pN)','Events (#)'])))
for V in Vs:
for i,k in enumerate(avgK):
if i == 1:
if len(F) == 0:
continue
outs= [V, k, F.mean(), F.std(), len(F)]
- souts = ["%.2f" % (x) for x in outs]
- souts[-1] = "%d" % outs[-1] # special treatment for the integer
- print >> af, '\t'.join(souts)
+ souts = ['{:.2f}'.format(x) for x in outs]
+ souts[-1] = str(outs[-1]) # special treatment for the integer
+ af.write('\t'.join(souts))
+ af.write('\n')
af.close()
if __name__ == '__main__':
y = []
w = [] # weights
-print >> sys.stderr, "Fitting data from", fname
+sys.stderr.write('Fitting data from {}\n'.format(fname))
for line in open(fname, 'r'):
fields = [float(a) for a in line.strip().split()]
if WEIGHTHACK==True:
slope,intercept,r,two_tailed_prob,stderr_of_the_estimate = linregress([log10(xi) for xi in x],y)
else:
slope,intercept,r,two_tailed_prob,stderr_of_the_estimate = linregress(x,y)
-#print slope,intercept,r,two_tailed_prob,stderr_of_the_estimate
+#print(' '.join(str(x) for x in [
+# slope,intercept,r,two_tailed_prob,stderr_of_the_estimate]))
def f(x):
if LOGX == True:
x.sort()
xmin = x[0]
xmax = x[-1]
-print '#fitted line'
-print '%g\t%g' % (xmin, f(xmin))
-print '%g\t%g' % (xmax, f(xmax))
+print('#fitted line')
+print('{}\t{}'.format(xmin, f(xmin)))
+print('{}\t{}'.format(xmax, f(xmax)))