-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathYDR_preTraces.py
87 lines (83 loc) · 3.32 KB
/
YDR_preTraces.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from glob import glob
from numpy.core.fromnumeric import transpose
import YDR_aux as aux
import YDR_gene as drv
import YDR_land as lnd
from datetime import datetime
from joblib import Parallel, delayed
import MoNeT_MGDrivE as monet
import compress_pickle as pkl
import matplotlib.pyplot as plt
plt.rcParams.update({
"figure.facecolor": (1.0, 0.0, 0.0, 0.0), # red with alpha = 30%
"axes.facecolor": (0.0, 1.0, 0.0, 0.0), # green with alpha = 50%
"savefig.facecolor": (0.0, 0.0, 1.0, 0.0), # blue with alpha = 20%
})
if monet.isNotebook():
(USR, SET, DRV, AOI) = ('dsk', 'shredder', 'YXS', 'WLD')
else:
(USR, SET, DRV, AOI) = (sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
JOB = aux.JOB_SRV
if USR=='dsk' or USR=='lab':
JOB = aux.JOB_DSK
###############################################################################
# Setting up paths and style
###############################################################################
EXPS = aux.EXPS
exp=EXPS[0]
for exp in EXPS:
(drive, land) = (
drv.driveSelector(DRV, AOI, popSize=aux.POP_SIZE),
lnd.landSelector('SPA')
)
(gene, fldr) = (drive.get('gDict'), drive.get('folder'))
(PT_ROT, PT_IMG, PT_DTA, PT_PRE, PT_OUT, PT_MTR) = aux.selectPath(
USR, SET, fldr, exp
)
PT_IMG = PT_IMG + 'preTraces/'
monet.makeFolder(PT_IMG)
###########################################################################
# Style
###########################################################################
(CLR, YRAN) = (drive.get('colors'), (0, drive.get('yRange')))
STYLE = {
"width": .075, "alpha": .1, "dpi": 1000, "legend": True,
"aspect": .25, "colors": CLR, "xRange": aux.XRAN, "yRange": YRAN
}
STYLE['aspect'] = monet.scaleAspect(1, STYLE)
tS = datetime.now()
monet.printExperimentHead(
PT_PRE, PT_IMG, tS,
aux.XP_ID+' PreTraces [{}:{}:{}]'.format(DRV, exp, AOI)
)
###########################################################################
# Load preprocessed files lists
###########################################################################
tyTag = ('sum', 'srp')
(fltrPattern, globPattern) = ('dummy', PT_PRE+'*'+AOI+'*'+'{}'+'*')
if aux.FZ:
fltrPattern = PT_PRE + aux.patternForReleases('homing', '00', AOI, '*')
fLists = monet.getFilteredTupledFiles(fltrPattern, globPattern, tyTag)
###########################################################################
# Process files
###########################################################################
(xpNum, digs) = monet.lenAndDigits(fLists)
Parallel(n_jobs=JOB)(
delayed(monet.exportPreTracesPlotWrapper)(
exIx, fLists, STYLE, PT_IMG,
xpNum=xpNum, digs=digs,
border=True, borderColor='#8184a7AA', borderWidth=2,
transparent=True,
vLines=[0, 0, 0, 365*2.5, 365*5, 365*7.5, 365*10],
hLines=[0, 1250, 2500, 3750, 5000]
) for exIx in range(0, len(fLists))
)
# Export gene legend ------------------------------------------------------
# sumDta = pkl.load(fLists[-1][0])
# monet.exportGeneLegend(
# sumDta['genotypes'], [i[:-2]+'cc' for i in CLR],
# PT_IMG+'/legend_{}.png'.format(AOI), 500
# )