-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_pull_complete.py
More file actions
39 lines (29 loc) · 1.04 KB
/
Copy pathcheck_pull_complete.py
File metadata and controls
39 lines (29 loc) · 1.04 KB
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
36
37
import argparse
import os.path
import math
import json
parser = argparse.ArgumentParser(description='Pull genotypes.')
parser.add_argument('data_dir', type=str, help='Directory containing genotype data.')
parser.add_argument('file_type', type=str, help='Type of file to check.')
args = parser.parse_args()
chroms = [str(x) for x in range(1, 23)] + ['X', 'Y']
# grab assembly
with open('%s/info.json' % args.data_dir, 'r') as f:
info = json.load(f)
assembly = info['assembly']
batch_size = info['batch_size']
with open('data/chrom_lengths%s.json' % assembly, 'r') as f:
chrom_lengths = json.load(f)
missing_files = []
for chrom in chroms:
chrom_length = chrom_lengths[chrom]
if batch_size == -1:
num_batches = 1
else:
num_batches = int(math.ceil(chrom_length/batch_size))
print(chrom, batch_size, num_batches)
for batch_num in range(num_batches):
filename = '%s/chr.%s.%d.%s' % (args.data_dir, chrom, batch_num, args.file_type)
if not os.path.isfile(filename):
missing_files.append(filename)
print('Missing files:', missing_files)