-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind_broken_headers.py
More file actions
35 lines (28 loc) · 996 Bytes
/
Copy pathfind_broken_headers.py
File metadata and controls
35 lines (28 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import glob
import multiprocessing
import sys
def detect_broken_file(file_name):
with open(file_name, 'r') as f:
first_line = f.readline()
count = first_line.count('IBD_var_EE')
return file_name, count
def main():
sim_path = sys.argv[1]
model = sys.argv[2]
pool = multiprocessing.Pool()
listing = glob.glob('{}/results_sims_AJ_M{}/*.summary'.format(sim_path, model))
results = pool.imap_unordered(detect_broken_file, listing, 10)
for file_name, count in results:
if count == 1:
# All good. Nothing to see here. Move along.
sys.stderr.write('.')
elif count == 0:
# Not there. Weird.
sys.stderr.write('\nGermline not run? {}\n'.format(file_name))
elif count > 2:
# Whoah Nelly. Throw a fit.
sys.stderr.write('\nWhat the hell? {}\n'.format(file_name))
elif count == 2:
print(file_name)
if __name__ == '__main__':
main()