import sys
import numpy as np

def read_phi(flname, n_steps, n_loci, stride):
	sampled_phis = np.zeros((n_steps / stride, n_loci))
	fl = open(flname)
	current_iter_idx = 0 # index used for storage
	last_iter_idx = 0 # index used to identify when we finish a step
	for ln in fl:
		cols = ln.strip().split(",")
		iter_idx = int(cols[0])
		locus_idx = int(cols[1])
		phi = float(cols[2])
		if current_iter % stride == 0:
			if last_iter_idx != iter_idx:
				last_iter_idx = iter_idx
				current_iter_idx += 1
			sampled_phis[current_iter_idx, locus_idx] = phi
	fl.close()

	return sampled_phis


if __name__ == "__main__":
	bamova_phi_output_flname = sys.argv[1]
	n_steps = int(sys.argv[2])
	n_loci = int(sys.argv[3])
	stride = int(sys.argv[4])
	npy_flname = sys.argv[5]

	matrix = read_phi(bamova_phi_output_flname, n_steps, n_loci, stride)

	np.save(matrix, npy_flname)
@@ -60,24 +60,16 @@
 , n_loci
-, stride
 ):%0A%09samp
@@ -100,17 +100,8 @@
 teps
- / stride
 , n_
@@ -695,35 +695,8 @@
 3%5D)%0A
-%09stride = int(sys.argv%5B4%5D)%0A
 %09npy
@@ -718,9 +718,9 @@
 rgv%5B
-5
+4
 %5D%0A%0A%09
@@ -782,16 +782,8 @@
 loci
-, stride
 )%0A%0A%09

Remove stride