-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_enrichment_wgcna.py
69 lines (53 loc) · 1.5 KB
/
_enrichment_wgcna.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Imports
import sys, os
import math
import argparse
import uuid
import subprocess
# Variables
SCRATCH = "/aloy/scratch/mduran/sysmalvac/"
PATH = os.path.dirname(os.path.realpath(__file__))
CMD = "/usr/local/bin/singularity exec %s/singularity/sysmalvac.simg python" % PATH
SCRIPT = PATH + "/enrichment_wgcna.py"
granularity = 1
# Create folder structure
filenames = [
"CSP_I7_C1",
"CSP_RTS_CONTROL",
"iRBC_I7_C1",
"iRBC_RTS_CONTROL",
"malaria_CSP_CONTROL",
"malaria_CSP_RTS",
"malaria_iRBC_CONTROL",
"malaria_iRBC_RTS",
"protected_CSP_C1",
"protected_CSP_I7",
"protected_iRBC_C1",
"protected_iRBC_I7"
]
genesets = [
"btm",
"modules",
"biocarta",
"kegg",
"reactome"
]
for filename in filenames:
fld1 = PATH + "/sysmalvac_results_wgcna/" + filename
if not os.path.exists(fld1): os.mkdir(fld1)
for geneset in genesets:
fld2 = fld1 + "/" + geneset
if not os.path.exists(fld2): os.mkdir(fld2)
# Prepare input files
os.chdir(SCRATCH)
TMPFILE = SCRATCH + "/" + str(uuid.uuid4())
with open(TMPFILE, "w") as f:
S = 0
for x in filenames:
for y in genesets:
f.write("%s---%s\n" % (x,y))
S += 1
t = math.ceil(float(S)/granularity)
subprocess.Popen("./setupArrayJob.py -x -N wmalenrich -l %s -t %d %s %s" % (TMPFILE, t, CMD, SCRIPT), shell = True).wait()
s = subprocess.check_output("qsub -q all.q,fast.q job-wmalenrich.sh", shell = True)
job_id = int(s.split("job-array ")[1].split(".")[0])