-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathcompute_maf.py
More file actions
39 lines (29 loc) · 835 Bytes
/
Copy pathcompute_maf.py
File metadata and controls
39 lines (29 loc) · 835 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
36
37
38
39
import sys
from timeit import timeit
from typing import List, Set
sys.path.insert(0, '../shared')
def get_chrom(my_chrom):
calls = []
with open('my_hapmap.tped') as f:
for l in f:
toks = l.rstrip().split(' ')
chrom = int(toks[0])
if chrom < my_chrom:
continue
if chrom > my_chrom:
break
calls.append(toks[4:])
return calls
calls = get_chrom(1)
size_calls = len(calls)
size_list = sys.getsizeof(calls)
print(f'Number of SNPs on chromsome 1: {size_calls}')
print(f'Memory size of the list: {size_list}')
print(f'Memory per SNP {size_list // size_calls}')
print(sys.getsizeof(calls[0]))
print(sys.getsizeof('A'))
all_ids = set()
for SNP in calls:
for obj in SNP:
all_ids.add(id(obj))
print(len(all_ids))