-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgene_list_kellis_sig.py
32 lines (27 loc) · 1.03 KB
/
gene_list_kellis_sig.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
import os
import pickle
def add_genes(list_path, gene_set):
try:
with open(list_path) as list_file:
for line in list_file:
gene_set.add(line.strip())
except FileNotFoundError as e:
print(e)
def build_list(gwas_dir, res_dir, out_dir):
gene_set = set()
studies = os.listdir(gwas_dir)
for study in studies:
gwas_path = os.path.join(gwas_dir, study)
gwas_name = study.split(".")[0]
list_path = os.path.join(res_dir, f"{gwas_name}_sig", "genes.txt")
add_genes(list_path, gene_set)
gene_list = list(gene_set)
print(len(gene_list)) ####
with open(os.path.join(out_dir, "list_429_sig.pickle"), "wb") as out_file:
pickle.dump(gene_list, out_file)
if __name__ == '__main__':
# Kellis 429
data_path_kellis = "/agusevlab/awang/sc_kellis"
res_dir = "/agusevlab/awang/ase_finemap_results/sc_results/kellis_429/colocalization"
gwas_dir = "/agusevlab/awang/gwas_data"
build_list(gwas_dir, res_dir, data_path_kellis)