-
Notifications
You must be signed in to change notification settings - Fork 0
/
gene_list_kellis_test.py
33 lines (29 loc) · 1.25 KB
/
gene_list_kellis_test.py
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
import os
import pickle
def build_list(data_dir, contig, out_dir):
gene_list = []
contig_set = set() ####
for gene_name in os.listdir(data_dir):
gene_dir = os.path.join(data_dir, gene_name)
gene_path = os.path.join(gene_dir, "gene_data.pickle")
try:
with open(gene_path, "rb") as gene_file:
gene_data = pickle.load(gene_file)
# print(gene_data["markers"][0][0]) ####
contig_set.add(gene_data["markers"][0][0]) ####
if gene_data["markers"][0][0] == contig:
# print(gene_data["markers"][0][0]) ####
gene_list.append(gene_name)
except Exception as e:
continue
print(len(gene_list)) ####
print(sorted(list(contig_set))) ####
with open(os.path.join(out_dir, f"list_429_test_{contig}.pickle"), "wb") as out_file:
pickle.dump(gene_list, out_file)
if __name__ == '__main__':
# Kellis 429
data_path_kellis = "/agusevlab/awang/sc_kellis"
genes_dir_kellis = os.path.join(data_path_kellis, "genes_429")
# build_list(genes_dir_kellis, "22", data_path_kellis)
build_list(genes_dir_kellis, "10", data_path_kellis)
# build_list(genes_dir_kellis, "1", data_path_kellis)