-
Notifications
You must be signed in to change notification settings - Fork 1
/
tardis.nf
179 lines (147 loc) · 3.87 KB
/
tardis.nf
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/usr/bin/env nextflow
params.data_set = "USA"
params.nsamples = 10
params.gensize = 100
params.nbatches = 1
params.ncores = 2
params.ngenerations = 10
params.fracnew = 0.14
params.fracevolved = 0.85
params.fracelite = 0.01
params.wdiv = 1
params.wtem = 1
params.distopt = "max"
params.seeds = "data/seeds.txt"
params.distances = "jc.distance.precalc.csv"
params.metadata = "metadata.csv"
params.outdir = "output/${params.data_set}"
params.afile = ""
init = Channel.from(0)
incr = Channel.create()
endg = Channel.from(-1)
batches = Channel.from(1..params.nbatches)
process Init {
executor "local"
memory "1G"
input:
val zero from init
output:
val zero into start
"""
#!/bin/bash
#if [ ! -d "${workflow.launchDir}/data/${params.data_set}" ];
#then
# echo "Error: this program expects a subdirectory called data/${params.data_set} in the current directory."
# exit 1
#fi
checkParams.py ${params.fracnew} ${params.fracevolved} ${params.fracelite} ${params.gensize} ${params.distopt}
"""
}
Channel
.from incr
.map { it + 1 }
.until { it >= params.ngenerations }
.set { igens }
generations = start.concat(igens).concat(endg)
process Generation {
executor "local"
memory "1G"
input:
val gen from generations
output:
val gen into combo
val gen into terminate
"""
#!/bin/bash
echo Starting generation: $gen
"""
}
Channel
.from combo
.combine(batches)
.set { genround }
process DoIt {
input:
tuple gen, batch from genround
output:
tuple gen, batch into genend
when:
gen >= 0
"""
#!/bin/bash
echo "Generation $gen, Batch $batch"
if [ "$gen" == "0" ];
then
fnew=1; fevo=0; feli=0
else
fnew=${params.fracnew}; fevo=${params.fracevolved}; feli=${params.fracelite}
fi
# echo Rscript ${workflow.projectDir}/bin/make.gen.R \
# --frac.new \$fnew \
# --frac.evo \$fevo \
# --frac.eli \$feli \
# --n.samples ${params.nsamples} \
# --gen.size ${params.gensize} \
# --tot.batches ${params.nbatches} \
# --n.cores ${params.ncores} \
# --data.set ${params.data_set} \
# --w.div ${params.wdiv} \
# --w.tem ${params.wtem} \
# --generation $gen \
# --batch $batch \
# --dist.opt ${params.distopt} \
# --seeds ${workflow.launchDir}/${params.seeds} \
# --distance ${params.distances} \
# --metadata ${params.metadata} \
# --out.dir ${workflow.launchDir}/${params.outdir} > ${workflow.launchDir}/make.gen.${gen}.cmd
Rscript ${workflow.projectDir}/bin/make.gen.R \
--frac.new \$fnew \
--frac.evo \$fevo \
--frac.eli \$feli \
--n.samples ${params.nsamples} \
--gen.size ${params.gensize} \
--tot.batches ${params.nbatches} \
--n.cores ${params.ncores} \
--data.set ${params.data_set} \
--w.div ${params.wdiv} \
--w.tem ${params.wtem} \
--generation $gen \
--batch $batch \
--dist.opt ${params.distopt} \
--seeds ${workflow.launchDir}/${params.seeds} \
--distance ${params.distances} \
--metadata ${params.metadata} \
--out.dir ${workflow.launchDir}/${params.outdir}
"""
}
Channel
.from genend
.groupTuple(size: params.nbatches)
.set { gensummary }
process Collect {
executor "local"
memory "1G"
input:
tuple gen, batches from gensummary
output:
val gen into incr
"""
#!/bin/bash
echo "Collecting generation $gen, Batches $batches"
"""
}
process Conclusion {
executor "local"
memory "1G"
input:
val gen from terminate
when:
gen == -1
script:
"""
#!/bin/bash
extractSeqs.py ${workflow.launchDir}/${params.outdir} ${params.afile} ${params.ngenerations} ${params.nbatches} ${params.nsamples} GA.${params.data_set}
Rscript ${workflow.projectDir}/bin/print.results.R -s ${params.data_set} -d ${params.distances} --metadata ${params.metadata} \
--outdir ${workflow.launchDir}/${params.outdir} --ngenerations ${params.ngenerations} --n.batches ${params.nbatches}
"""
}