modified: myjupyterlab.sh
[GalaxyCodeBases.git] / projects / recombineMap / sperm_by_fw / crossover_prediction / Simple_method / sum.py
blobf6a08468406540719d6415cc62f632d149e1aab9
1 import sys, os
3 changeposfile = []
4 def mydir(arg, dirname, names):
5 files = [os.path.normpath(os.path.join(dirname, file)) for file in names]
6 for filename in files:
7 if filename[-3:]=='pos':
8 changeposfile.append(open(filename,"r"))
12 if len(sys.argv)==1:
13 path=os.getcwd()
14 else:
15 path = sys.argv[1]
17 os.path.walk(path, mydir, 0)
19 w = open("sum.changepos","w")
20 sum = {}
22 for file in changeposfile:
23 for line in file:
24 item = line.split('\t')
25 if not sum.has_key(item[0]):
26 sum.update({item[0]:0})
27 print item, len(item)
28 sum[item[0]]+=len(item)-2
29 items = sum.items()
30 items.sort()
31 for item in items:
32 w.write(str(item[0]))
33 w.write('\t')
34 w.write(str(item[1]))
35 w.write('\n')
37 print items