-
Notifications
You must be signed in to change notification settings - Fork 3
/
BioNetFit.pbs
438 lines (359 loc) · 8.45 KB
/
BioNetFit.pbs
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
#!/bin/bash
#
# Version 1.1
# Written by Joshua Colvin
#
# Function used to log every command that is executed.
# Takes two or three arguments:
# - Directory command should be executed in.
# - Command to execute.
#
# Note that it is important to surround entire command with quotes
# so that pipes and redirects are handled properly.
#
# - If optional third argument is present, it contains the name of the file
# to create if the program fails.
# (make sure file doesn't exist before running)
#
# Example:
# echo_and_exec $PBS_O_WORKDIR "wc -l *.fastq > fastq_line_count.txt"
#
#
echo_and_exec()
{
cd $1
echo ""
echo "In $1"
echo "Running: $2"
if [ ! "$test" ]
then
eval "$2"
fi
status=$?
if [ ! $status == 0 ]
then
if [ "$3" ]
then
touch $3
fi
echo "Previous command returned error: $status"
exit 1;
fi
}
# Same but fork process so it runs in the background.
echo_and_exec_fork()
{
cd $1
cmd=${2//%%%/$1}
echo ""
echo "In $1"
echo "Running: $cmd"
eval "$cmd" &
status=$?
if [ ! $status == 0 ]
then
if [ "$3" ]
then
eval $3
fi
echo "Previous command returned error: $status"
exit 1;
fi
}
# List of variable names that are required to continue
# (names only, do not include '$')
#
# Example:
# require_var foo bar
#
require_var()
{
for var in $*
do
eval if [ ! "\"\$$var\"" ]\; then echo "Oops, need variable $var\!"\; failed=1\; fi\;
done
if [ "$failed" ]
then
exit 1;
fi
}
if [ ! $PBS_O_WORKDIR ]
then
# Called from command line, not in PBS.
PBS_O_WORKDIR="$PWD"
fi
if [ $SGE_O_WORKDIR ]
then
PBS_O_WORKDIR="$SGE_O_WORKDIR"
fi
cd ${PBS_O_WORKDIR}
if [ -n "$command" ];
then
echo_and_exec "$PBS_O_WORKDIR" "$command" "$touch_on_error"
fi
if [ -n "$command0" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command0" "$touch_on_error0"
fi
if [ -n "$command1" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command1" "$touch_on_error1"
fi
if [ -n "$command2" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command2" "$touch_on_error2"
fi
if [ -n "$command3" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command3" "$touch_on_error3"
fi
if [ -n "$command4" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command4" "$touch_on_error4"
fi
if [ -n "$command5" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command5" "$touch_on_error5"
fi
if [ -n "$command6" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command6" "$touch_on_error6"
fi
if [ -n "$command7" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command7" "$touch_on_error7"
fi
if [ -n "$command8" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command8" "$touch_on_error8"
fi
if [ -n "$command9" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command9" "$touch_on_error9"
fi
if [ -n "$command10" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command10" "$touch_on_error10"
fi
if [ -n "$command11" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command11" "$touch_on_error11"
fi
if [ -n "$command12" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command12" "$touch_on_error12"
fi
if [ -n "$command13" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command13" "$touch_on_error13"
fi
if [ -n "$command14" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command14" "$touch_on_error14"
fi
if [ -n "$command15" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command15" "$touch_on_error15"
fi
if [ -n "$command16" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command16" "$touch_on_error16"
fi
if [ -n "$command17" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command17" "$touch_on_error17"
fi
if [ -n "$command18" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command18" "$touch_on_error18"
fi
if [ -n "$command19" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command19" "$touch_on_error19"
fi
if [ -n "$command20" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command20" "$touch_on_error20"
fi
if [ -n "$command21" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command21" "$touch_on_error21"
fi
if [ -n "$command22" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command22" "$touch_on_error22"
fi
if [ -n "$command23" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command23" "$touch_on_error23"
fi
if [ -n "$command24" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command24" "$touch_on_error24"
fi
if [ -n "$command25" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command25" "$touch_on_error25"
fi
if [ -n "$command26" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command26" "$touch_on_error26"
fi
if [ -n "$command27" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command27" "$touch_on_error27"
fi
if [ -n "$command28" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command28" "$touch_on_error28"
fi
if [ -n "$command29" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command29" "$touch_on_error29"
fi
if [ -n "$command30" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command30" "$touch_on_error30"
fi
if [ -n "$command31" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command31" "$touch_on_error31"
fi
if [ -n "$command32" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command32" "$touch_on_error32"
fi
if [ -n "$command33" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command33" "$touch_on_error33"
fi
if [ -n "$command34" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command34" "$touch_on_error34"
fi
if [ -n "$command35" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command35" "$touch_on_error35"
fi
if [ -n "$command36" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command36" "$touch_on_error36"
fi
if [ -n "$command37" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command37" "$touch_on_error37"
fi
if [ -n "$command38" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command38" "$touch_on_error38"
fi
if [ -n "$command39" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command39" "$touch_on_error39"
fi
if [ -n "$command40" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command40" "$touch_on_error40"
fi
if [ -n "$command41" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command41" "$touch_on_error41"
fi
if [ -n "$command42" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command42" "$touch_on_error42"
fi
if [ -n "$command43" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command43" "$touch_on_error43"
fi
if [ -n "$command44" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command44" "$touch_on_error44"
fi
if [ -n "$command45" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command45" "$touch_on_error45"
fi
if [ -n "$command46" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command46" "$touch_on_error46"
fi
if [ -n "$command47" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command47" "$touch_on_error47"
fi
if [ -n "$command48" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command48" "$touch_on_error48"
fi
if [ -n "$command49" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command49" "$touch_on_error49"
fi
if [ -n "$command50" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command50" "$touch_on_error50"
fi
if [ -n "$command51" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command51" "$touch_on_error51"
fi
if [ -n "$command52" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command52" "$touch_on_error52"
fi
if [ -n "$command53" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command53" "$touch_on_error53"
fi
if [ -n "$command54" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command54" "$touch_on_error54"
fi
if [ -n "$command55" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command55" "$touch_on_error55"
fi
if [ -n "$command56" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command56" "$touch_on_error56"
fi
if [ -n "$command57" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command57" "$touch_on_error57"
fi
if [ -n "$command58" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command58" "$touch_on_error58"
fi
if [ -n "$command59" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command59" "$touch_on_error59"
fi
if [ -n "$command60" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command60" "$touch_on_error60"
fi
if [ -n "$command61" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command61" "$touch_on_error61"
fi
if [ -n "$command62" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command62" "$touch_on_error62"
fi
if [ -n "$command63" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command63" "$touch_on_error63"
fi
if [ -n "$command64" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command64" "$touch_on_error64"
fi
if [ -n "$command65" ];
then
echo_and_exec_fork "$PBS_O_WORKDIR" "$command65" "$touch_on_error65"
fi
wait