import numpy as np
file1 = open('/home/scottn/pearsoncorrelmotifcount.txt')
file2 = open('/home/scottn/binpearson.txt')
file3 = open('/home/scottn/runwithgemma/output/mousejul8correllmm1.assoc.txt')
file4 = open('/home/scottn/runwithgemma/output/mousejul1sixmerdifflmm1.assoc.txt')
file5 = open('/home/scottn/runwithgemma/output/mousejul1dimercorrellmm1.assoc.txt')
ofile1 = open('/home/scottn/pearsoncorrelmotifcount.sort.txt', 'w+')
ofile2 = open('/home/scottn/binpearson.sort.txt', 'w+')
ofile3 = open('/home/scottn/runwithgemma/output/mousejul8correllmm1.assoc.sort.txt', 'w+')
ofile4 = open('/home/scottn/runwithgemma/output/mousejul1sixmerdifflmm1.assoc.sort.txt', 'w+')
ofile5 = open('/home/scottn/runwithgemma/output/mousejul1dimercorrellmm1.assoc.sort.txt', 'w+')
for i in range(1,6):
	tarray = np.genfromtxt(eval('file'+str(i)), dtype=None, delimiter='\t', names=None)
	n = len(tarray[0])
	tarray[tarray[:,n-1].argsort()]
	for row in tarray:
		eval('ofile'+str(i)).write('\t'.join([str(x) for x in row])+'\n')
	eval('ofile'+str(i)).close()
