-
Notifications
You must be signed in to change notification settings - Fork 2
/
batchconvert.sh
executable file
·128 lines (105 loc) · 3.18 KB
/
batchconvert.sh
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
#!/usr/bin/env bash
# TODO make SCRIPTPATH an environment variable
SCRIPTPATH=$( dirname -- ${BASH_SOURCE[0]}; );
source $SCRIPTPATH/bin/utils.sh
mkdir -p $HOMEPATH
set -f && \
pythonexe $SCRIPTPATH/bin/parameterise_conversion.py "$@";
if [[ -f $TEMPPATH/.stderr ]];
then
error=$(cat $TEMPPATH/.stderr);
rm $TEMPPATH/.stderr;
fi;
if [[ ${#error} -gt 0 ]];
then
printf "${RED}$error${NORMAL}\n"
printf "${RED}The batchonvert command is invalid. Please try again.${NORMAL}\n"
exit
fi
if [[ -f $TEMPPATH/.stdout ]];
then
result=$(cat $TEMPPATH/.stdout);
rm $TEMPPATH/.stdout;
fi;
if [[ -f $TEMPPATH/.process ]];
then
process=$(cat $TEMPPATH/.process)
else
printf "${RED}The batchonvert command is invalid. Please try again.${NORMAL}\n"
fi
if [[ $result == "inputpatherror" ]];
then
printf "${RED}Error: The input path does not exist.\n${NORMAL}"
exit
elif [[ ${#result} -gt 0 ]];
then
if [[ $process == 'parameters_shown' ]];
then
printf "${NORMAL}$result${NORMAL}\n"
else
printf "${RED}$result${NORMAL}\n"
exit
fi
fi
if [[ -f $TEMPPATH/.afterrun ]];
then
afterrun=$(cat $TEMPPATH/.afterrun)
else
afterrun="nan"
fi
if [[ $process == 'configured_s3' ]];
then
printf "${GREEN}Configuration of the default s3 credentials is complete${NORMAL}\n";
elif [[ $process == 'configured_bia' ]];
then
printf "${GREEN}Configuration of the default bia credentials is complete${NORMAL}\n";
elif [[ $process == 'configured_slurm' ]];
then
printf "${GREEN}Configuration of the default slurm parameters is complete\n${NORMAL}";
elif [[ $process == 'configured_ometiff' ]];
then
printf "${GREEN}Configuration of the default parameters for 'bfconvert' is complete\n${NORMAL}";
elif [[ $process == 'configured_omezarr' ]];
then
printf "${GREEN}Configuration of the default parameters for 'bioformats2raw' is complete\n${NORMAL}";
elif [[ $process == 'configured_from_json' ]];
then
printf "${GREEN}Default parameters have been updated from a json file.\n${NORMAL}";
elif [[ $process == 'resetted' ]];
then
printf "${GREEN}Default parameters have been resetted.\n${NORMAL}";
elif [[ $process == 'parameters_shown' ]];
then
printf "${GREEN}Current default parameters displayed.\n${NORMAL}";
elif [[ $process == 'parameters_exported' ]];
then
printf "${GREEN}Current default parameters successfully exported.\n${NORMAL}";
elif [[ $process == "default_param_set" ]];
then
printf "${GREEN}Default parameter updated.\n${NORMAL}";
elif [[ $process == 'converted' ]];
then
printf "${GREEN}Nextflow script has been created. Workflow is beginning.\n${NORMAL}" && \
chmod +x $BINPATH/run_conversion.py && \
pythonexe $SCRIPTPATH/bin/run_nextflow_cli.py
fi
if [[ -f $TEMPPATH/.process ]];
then
rm $TEMPPATH/.process
fi
if [[ $1 == "ometiff" ]] || [[ $1 == "omezarr" ]];
then
if [[ $afterrun != "noclean" ]];
then
pythonexe $SCRIPTPATH/bin/clean_workdir.py;
fi
fi
if [[ -f $TEMPPATH/.afterrun ]];
then
rm $TEMPPATH/.afterrun
fi
if [[ -d $TEMPPATH/.nextflow ]];
then
rm -rf $TEMPPATH/.nextflow
fi
pythonexe $SCRIPTPATH/bin/cleanup.py &> /dev/null