-
Notifications
You must be signed in to change notification settings - Fork 0
/
slurm_tiling_job.sh
executable file
·61 lines (51 loc) · 1.63 KB
/
slurm_tiling_job.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
#!/bin/bash
#SBATCH --time=4:00:00
#SBATCH -N 1
#SBATCH -n 1
#SBATCH -c 1
#SBATCH --mem=6GB
#SBATCH --mail-type=end,fail
#SBATCH [email protected]
# Receives PROJECT_DIR as a PARAMETER
QUPATH_BIN=/mnt/lustre/scratch/nlsas/home/usc/mg/translational_oncology/QuPath/bin/QuPath
SRC_DIR=/home/usc/mg/ioc/repos/export_tiles
PROJECT_NAME=${PROJECT_DIR##*/}
ANNOTATION=${PROJECT_DIR}/${PROJECT_NAME}.geojson
if grep -q Tumor ${ANNOTATION} 2>/dev/null; then
echo "Tumor tag detected"
else
echo "Tumor tag not detected, inserting"
n_lines=$(grep -n properties ${ANNOTATION} | cut -f1 -d":")
>| ${ANNOTATION}.edit
last_line=1
total_lines=$(grep -c . $ANNOTATION)
for n_line in ${n_lines[@]}; do
tail -n +$((last_line)) ${ANNOTATION} \
| head -n $((n_line-last_line+1)) \
>> ${ANNOTATION}.edit
cat tumor_annotation.txt >> ${ANNOTATION}.edit
last_line=$((n_line + 3))
done
tail -n +$last_line ${ANNOTATION} \
>> ${ANNOTATION}.edit
mv ${ANNOTATION}.edit ${ANNOTATION}
fi
echo "Setting headless parameters"
Xvfb :99 &
export DISPLAY=:99
export JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
echo "Creating empty project"
${QUPATH_BIN} script \
$SRC_DIR/create_project.groovy \
-a ${PROJECT_DIR}
echo "Importing annotation"
${QUPATH_BIN} script \
$SRC_DIR/import_annotation.groovy \
-p ${PROJECT_DIR}/QuPathProject/project.qpproj \
-a ${PROJECT_DIR}/${PROJECT_NAME}.geojson \
-s
echo "Exporting tiles"
${QUPATH_BIN} script \
$SRC_DIR/export_tiles.groovy \
-p ${PROJECT_DIR}/QuPathProject/project.qpproj
${SRC_DIR}/remove_spaces.sh ${PROJECT_DIR}