-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·109 lines (85 loc) · 2.73 KB
/
run
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
#!/bin/bash
#
# template based on: https://github.com/scitran-apps/fsl-bet/blob/master/run
#
#
CONTAINER="[histoQC]"
echo -e "$CONTAINER Initiated"
###############################################################################
## Built to flywheel-v0 spec.
FLYWHEEL_BASE=/flywheel/v0
OUTPUT_DIR=$FLYWHEEL_BASE/output_temp
input_im_DIR=$FLYWHEEL_BASE/input/input_image
config_DIR=$FLYWHEEL_BASE/input/config
MANIFEST=$FLYWHEEL_BASE/manifest.json
CONFIG_FILE=$FLYWHEEL_BASE/config.json
###############################################################################
## Configure the ENV
export USER=Flywheel
###############################################################################
## Execute the main processes
function jsonValue() {
KEY=$1
num=$2
awk -F"[,:}]" '{for(i=1;i<=NF;i++){if($i~/'$KEY'\042/){print $(i+1)}}}' | tr -d '"' | sed -n ${num}p
}
## get all user configurations
# if [[ -f $CONFIG_FILE ]]; then
# echo "$CONTAINER $CONFIG_FILE found. Loading config..."
# config_fn="$(cat $CONFIG_FILE | jsonValue config_file)"
# else
# echo "$CONTAINER $CONFIG_FILE not found. Using default QC pipeline (v2.1)"
# config_fn=v2.1
# fi
## Find the input files
input_im_file=$(find $input_im_DIR/* -maxdepth 0 -type f -name "*.svs*")
echo "$input_im_file"
file=$(basename "${input_im_file}")
echo "$file"
user_config_file=$(find $config_DIR/* -maxdepth 0 -type f -name "*.ini*")
echo "$user_config_file"
echo "config-file =" $(basename "${user_config_file}")
## If necessary input files are found, run the thing
if [[ -f $input_im_file ]] ; then
HistoQC_dir=$FLYWHEEL_BASE/HistoQC # path to install (in Docker container)
echo "$CONTAINER Running HistoQC"
if [[ -f $user_config_file ]]; then
python3 -m histoqc -c ${user_config_file} -n 3 "${input_im_file}" -o ${OUTPUT_DIR}
else
python3 -m histoqc -c v2.1 -n 3 "${input_im_file}" -o ${OUTPUT_DIR}
fi
# move output directories to temp for Flywheel container
for d in output_temp/* ; do
if [[ -d ${d} ]] ; then
echo ${d}
mv ${d}/* ./output_temp
rm -r ${d}
fi
done
# check for results file to check the status
if test -f /flywheel/v0/output_temp/results.tsv; then
echo "File exists."
# create new acq and move all the output along with the file metadata to slide file
export bashvar=$file
export output=$OUTPUT_DIR
my_value=$(python3 create_acq.py)
echo $my_value
exit 0
else
echo $STATUS
exit 1
fi
################# Finish up #################
STATUS=$?
else
echo "$CONTAINER Input files not found!"
exit 1
fi
# Check exit status
if [[ $STATUS == 0 ]]
then
echo -e "$CONTAINER Done!"
else
echo "$CONTAINER command returned a non-zero exit code = [$STATUS]."
exit 1
fi