diff --git a/file_tools.py b/file_tools.py index b220c9e..e07707d 100755 --- a/file_tools.py +++ b/file_tools.py @@ -12,7 +12,7 @@ def file_read (file): lines_of_file = block_lines.split('\n') #divide into lines at carriage rtns del lines_of_file [0] # header del lines_of_file [-1] # last line is blank so remove it - print lines_of_file [0] + print (lines_of_file [0]) return lines_of_file def file_write (file,data): diff --git a/noise.py b/noise.py index 38c748b..9e4fe15 100755 --- a/noise.py +++ b/noise.py @@ -11,7 +11,7 @@ ## Traces that exceed the limit are popped from the list and the failing points are explicitly listed to the terminal ## Output is tab delimited columns of verified traces 'verified.txt' - +import sys from math import * import platform from trace_tools import mean, variance, rmsd, traces_scale, trace_scale, traces_average, baselines_quality, baseline_subtract @@ -46,9 +46,9 @@ def clean_bad_baselines(input_traces, baseline_range=[0,99]): b_end = baseline_range[1] mean_sigma2_bs, rmsd_sigma2_bs, bs_variances = baselines_quality (input_traces, b_start, b_end) - print 'Mean baseline variance = ', mean_sigma2_bs - print 'RMSD of baseline variance =', rmsd_sigma2_bs - print bs_variances + print ('Mean baseline variance = ', mean_sigma2_bs) + print ('RMSD of baseline variance =', rmsd_sigma2_bs) + print (bs_variances) ## discard any trace with excessive baseline noise - Sigma2Bs gt Mean + 4 RMSD ex_noise_traces_to_pop = [] @@ -83,7 +83,7 @@ def construct_diffs(input_traces, UNITARY_CURRENT=.5, baseline_range=[0,99]): diff.append((input_traces[x+1][y]-input_traces[x][y])/2) difference_traces.append(diff) - print 'Constructed ', len(difference_traces), ' difference traces' + print ('Constructed ', len(difference_traces), ' difference traces') ## calculate mean current, invert and subtract baseline mean_I_inverted_bs_sub = mean_inverse_baseline_sub(input_traces, b_start, b_end) @@ -99,7 +99,7 @@ def construct_diffs(input_traces, UNITARY_CURRENT=.5, baseline_range=[0,99]): limit = 7 * sqrt(UNITARY_CURRENT * I + mean_sigma2_bs) limits.append(limit) - print 'Verifying variance of difference traces' + print ('Verifying variance of difference traces') excess_points, excess_limits, excess_differences = [],[],[] @@ -130,8 +130,8 @@ def construct_diffs(input_traces, UNITARY_CURRENT=.5, baseline_range=[0,99]): if len(excess_points[i]) > 0: message = "Trace {} contained {} points greater than the limit and was removed from set\n".format(i, len(excess_points[i])) messages += message - print message - print zip(excess_limits[i],excess_differences[i]) + print (message) + print (zip(excess_limits[i],excess_differences[i])) difference_traces_to_pop.append(i) if input_traces_to_pop.count(i) == 0: #Check if this trace was already discarded last time input_traces_to_pop.append(i) @@ -171,8 +171,11 @@ def final_prep(input_traces, difference_traces, baseline_range): for d_trace in difference_traces: isochrone.append(d_trace[isochronous_point]) - mean_dZt_squared = mean (map (square, isochrone)) - + if sys.version_info[0] > 2: + mean_dZt_squared = mean (list(map (square, isochrone))) + else: + mean_dZt_squared = mean (map (square, isochrone)) + #factor of '2' because of dZt = 1/2 * {y(i+1)-y(i)}; Heinemann and Conti final_ensemble_variance.append(2 * mean_dZt_squared) @@ -195,10 +198,10 @@ def write_output (difference_traces, header_line, filename='verified.txt'): output_lines.insert(0, header_line) output_file = filename - print 'Writing {} difference traces to {} with mean and variance in first two columns...'.format(len(difference_traces), output_file) + print ('Writing {} difference traces to {} with mean and variance in first two columns...'.format(len(difference_traces), output_file)) file_write (output_file,output_lines) - print 'Done' + print ('Done') diff --git a/verifyTk.py b/verifyTk.py index b994ced..a8b8695 100644 --- a/verifyTk.py +++ b/verifyTk.py @@ -163,7 +163,7 @@ def on_help(): def callback_fname(self): ### there is no need to do anything until the analysis starts #this is just for debugging - print self.v.get() + print (self.v.get()) def callback5(self): 'Called by PLOT variance current button.'