-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask
203 lines (184 loc) · 7.13 KB
/
task
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
#!/bin/bash
function init() {
load-env
ssh -t head.hpc.zhaw.ch "mkdir -p $REMOTE_PATH/work_area/{data,scripts,data_temp,results}"
echo "The directories are created in the following dir: $REMOTE_PATH/work_area, with following subddirs:"
ssh -t head.hpc.zhaw.ch "ls -l $REMOTE_PATH/work_area/"
}
function list-scripts() {
ls -l ./scripts
}
function run-script() {
load-env
if [ $1 == "r_kraken2_report.sh" ]; then
scp ./scripts/$1 head.hpc.zhaw.ch:$REMOTE_PATH
scp env head.hpc.zhaw.ch:$REMOTE_PATH
echo "Script: $1 and env file are uploaded "
echo "Additional upload of scripts are needed for r_kraken2_report.sh"
scp ./scripts/kraken2_report_stats.R head.hpc.zhaw.ch:$REMOTE_PATH
ssh head.hpc.zhaw.ch "cd $REMOTE_PATH; pwd; sbatch $1"
echo "Script: $1 is running"
elif [ $1 == "r_kraken2_report_nanofilt.sh" ]; then
scp ./scripts/$1 head.hpc.zhaw.ch:$REMOTE_PATH
scp env head.hpc.zhaw.ch:$REMOTE_PATH
echo "Script: $1 and env file are uploaded "
echo "Additional upload of scripts are needed for r_kraken2_report.sh"
scp ./scripts/kraken2_report_stats.R head.hpc.zhaw.ch:$REMOTE_PATH
ssh head.hpc.zhaw.ch "cd $REMOTE_PATH; pwd; sbatch $1"
echo "Script: $1 is running"
elif [ $1 == "job_array_prep.sh" ]; then
scp ./scripts/$1 head.hpc.zhaw.ch:$REMOTE_PATH
scp env head.hpc.zhaw.ch:$REMOTE_PATH
echo "Script: $1 and env file are uploaded "
echo "Additional upload of scripts are needed for pre_basecalling_guppy_array.sh"
scp ./scripts/basecalling_guppy_array.sh head.hpc.zhaw.ch:$REMOTE_PATH
ssh head.hpc.zhaw.ch "cd $REMOTE_PATH; pwd; sbatch $1"
echo "Script: $1 is running"
elif [ $1 == "basecalling_guppy_array.sh" ]; then
scp env head.hpc.zhaw.ch:$REMOTE_PATH
echo "The current script should have been uploaded and adapted with the pre_basecalling_guppy_array.sh script. Check for correct array adaption!"
ssh head.hpc.zhaw.ch "cd $REMOTE_PATH; pwd; sbatch $1"
echo "Script: $1 is running"
else
scp ./scripts/$1 head.hpc.zhaw.ch:$REMOTE_PATH
scp env head.hpc.zhaw.ch:$REMOTE_PATH
echo "Script: $1 and env file are uploaded "
echo "No additional uploads needed"
ssh head.hpc.zhaw.ch "cd $REMOTE_PATH; pwd; sbatch $1"
echo "Script: $1 is running"
fi
}
function run-wf() {
# export $(cat .env)
# echo "Uploading scripts with the workflow name $1 "
# scp ./scripts/$1* head.hpc.zhaw.ch:$REMOTE_PATH
# scp .env head.hpc.zhaw.ch:$REMOTE_PATH
load-env
if [ $1 == "wf_tax_classification.sh" ]; then
scp env head.hpc.zhaw.ch:$REMOTE_PATH
echo "Upload of several scripts"
scp ./scripts/wf_tax_classification.sh head.hpc.zhaw.ch:$REMOTE_PATH
scp ./scripts/basecalling_guppy_array.sh head.hpc.zhaw.ch:$REMOTE_PATH
scp ./scripts/nanoplot_fastq.sh head.hpc.zhaw.ch:$REMOTE_PATH
scp ./scripts/demultiplexing_qcat.sh head.hpc.zhaw.ch:$REMOTE_PATH
scp ./scripts/filter_trim_nanofilt.sh head.hpc.zhaw.ch:$REMOTE_PATH
scp ./scripts/classification_kraken2_nanofilt.sh head.hpc.zhaw.ch:$REMOTE_PATH
scp ./scripts/r_kraken2_report_nanofilt.sh head.hpc.zhaw.ch:$REMOTE_PATH
scp ./scripts/script kraken2_report_stats.R head.hpc.zhaw.ch:$REMOTE_PATH
echo "All files Uploaded"
echo "Executing the workflow script"
ssh head.hpc.zhaw.ch "cd $REMOTE_PATH; pwd; bash $1"
echo "Workflow: wf_tax_classification.sh is running"
elif [ $1 == "wf_basic_processing.sh" ]; then
scp env head.hpc.zhaw.ch:$REMOTE_PATH
echo "Upload of several scripts"
scp ./scripts/wf_basic_processing.sh head.hpc.zhaw.ch:$REMOTE_PATH
scp ./scripts/basecalling_guppy_array.sh head.hpc.zhaw.ch:$REMOTE_PATH
scp ./scripts/nanoplot_fastq.sh head.hpc.zhaw.ch:$REMOTE_PATH
scp ./scripts/demultiplexing_qcat.sh head.hpc.zhaw.ch:$REMOTE_PATH
scp ./scripts/filter_trim_nanofilt.sh head.hpc.zhaw.ch:$REMOTE_PATH
echo "All files Uploaded"
echo "Executing the workflow script"
ssh head.hpc.zhaw.ch "cd $REMOTE_PATH; pwd; bash $1"
echo "Workflow: wf_tax_classification.sh is running"
else
echo "This is not an available workflow"
fi
}
function conn-hpc() {
echo "starting ssh connection to the hpc"
ssh -t head.hpc.zhaw.ch "cd /cfs/earth/scratch/voro/scripts; bash"
}
function load-env() {
export $(cat env)
echo "The env file: $1 is loaded"
}
function hpc-status() {
load-env $2
echo "Get queue status"
ssh head.hpc.zhaw.ch "cd $REMOTE_PATH; pwd; squeue -u voro"
}
function job-status() {
echo "Get job #$1 status"
ssh head.hpc.zhaw.ch "cd $REMOTE_PATH; pwd; sacct -j $1 --format=JobName,CPUTimeRAW,Submit,Start,End,Elapsed"
}
function node-status() {
echo "Get node status"
ssh head.hpc.zhaw.ch "cd $REMOTE_PATH; pwd; sinfo"
}
function cancel-job() {
echo "Cancel the job #$1"
ssh head.hpc.zhaw.ch "cd $REMOTE_PATH; pwd; scancel $1"
}
function dl-data() {
echo "Downloading data from: $1"
scp -r head.hpc.zhaw.ch:$1 ./data_temp
}
function help() {
echo
echo
echo "task commmands:"
echo
echo "(task) command <argument> description"
echo "---------------------------------------------------------------------------------------------"
echo "init Creates project directories at the specified REMOTE_PATH"
echo "list-scripts Returns a List of available scripts and workflows"
echo "run-script <Script Name> Execute a script based on name argument"
echo "run-wf <Workflow Name> Exceute a workflow base on the name argument"
echo "conn-hpc Connect to the head node on the HPC"
echo "load-env Export the variables of the env file"
echo "hpc-status Get an overview the current jobs running on the HPC"
echo "job-status <Job ID> Get overview stats on a job based on its id argument"
echo "node-status Get an overview of the status of the available nodes on the HPC"
echo "cancel-job <Job ID> Cancel a job based on its id argument"
echo "dl-data <Path_to_data> Dowload data based on a path into the local temp_data directory"
echo
echo "Helping commands:"
echo
echo "command description"
echo "--------------------------------------------"
echo "dos2unix Convert dos files into unix files. Apply if a problem comes up"
echo
}
# Switch case for script parameter 1
case "$1" in
start)
start
;;
init)
init
;;
list-scripts)
list-scripts
;;
run-script)
run-script $2
;;
run-wf)
run-wf $2
;;
conn-hpc)
conn-hpc
;;
load-env)
load-env $2
;;
hpc-status)
hpc-status
;;
job-status)
job-status $2
;;
node-status)
node-status
;;
cancel-job)
cancel-job $2
;;
dl-data)
dl-data $2
;;
*)
help help
exit 1
esac