-
Notifications
You must be signed in to change notification settings - Fork 14
/
predict.sh
executable file
·76 lines (55 loc) · 2.56 KB
/
predict.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
#!/bin/bash
export COMPUTERNAME=DOCKER-LIGHT
export MSNOVELIST_BASE=/msnovelist
export TF_CPP_MIN_LOG_LEVEL=3
export JAVA_HOME=/usr
if [[ "$NAMING" != "" ]]
then
NAMING_ARG="--naming-convention=$NAMING"
fi
SIRIUS_SETTINGS=${2:-"${NAMING_ARG} formula fingerprint structure"}
# Get input directory user to adjust all files to that user,
# to avoid rooted files that the user can't delete
USER=`stat -c "%u:%g" /msnovelist-data`
RUNID=`date +%s`
mkdir -p /msnovelist-data/results-$RUNID
cp /msnovelist/config.DOCKER-LIGHT.yaml /msnovelist-data/msnovelist-config-$RUNID.yaml
chown $USER /msnovelist-data/msnovelist-config-$RUNID.yaml
# If this is a file with spectra: process with SIRIUS and use resulting path as input path for MSNovelist
if [[ ! -d "/msnovelist-data/$1" ]]
then
HOME=/tmp sirius.sh --log=WARNING -i "/msnovelist-data/$1" -o "/msnovelist-data/sirius-$RUNID" $SIRIUS_SETTINGS
chown -R $USER /msnovelist-data/sirius-$RUNID
echo "sirius_project_input: /msnovelist-data/sirius-$RUNID" >> /msnovelist-data/msnovelist-config-$RUNID.yaml
# Otherwise use input directory as input path for MSNovelist
else
echo "sirius_project_input: /msnovelist-data/$1" >> /msnovelist-data/msnovelist-config-$RUNID.yaml
chown -R $USER /msnovelist-data/$1
fi
# Write new eval_id into config file
yq e 'del(.eval_id)' -i /msnovelist-data/msnovelist-config-$RUNID.yaml
yq e 'del(.eval_counter)' -i /msnovelist-data/msnovelist-config-$RUNID.yaml
yq e 'del(.eval_folder)' -i /msnovelist-data/msnovelist-config-$RUNID.yaml
# Note: check how yq deals with $, could be done directly above
echo "eval_id: '$RUNID'" >> /msnovelist-data/msnovelist-config-$RUNID.yaml
echo "eval_counter: '0'" >> /msnovelist-data/msnovelist-config-$RUNID.yaml
echo "eval_folder: '/msnovelist-data/results-$RUNID/'" >> /msnovelist-data/msnovelist-config-$RUNID.yaml
if [[ -f "/msnovelist-data/fingerprint_cache.db" ]]
then
echo "fingerprint_cache: '/msnovelist-data/fingerprint_cache.db'" >> /msnovelist-data/msnovelist-config-$RUNID.yaml
fi
# Run de novo prediction
cd /msnovelist
python "$MSNOVELIST_BASE/predict.py" -c \
/msnovelist/data/weights/config.yaml \
/msnovelist-data/msnovelist-config-$RUNID.yaml
# If required, also export database results for comparison (set EXPORT_DB_BASE=1)
if [[ "$EXPORT_DB_BASE" == "1" ]]
then
python "$MSNOVELIST_BASE/evaluation/applied_sirius_comparison.py" -c \
/msnovelist/data/weights/config.yaml \
/msnovelist-data/msnovelist-config-$RUNID.yaml
fi
# Set correct ownership for the results
chown -R $USER /msnovelist-data/results-$RUNID
chown -R $USER /msnovelist-data/fingerprint_cache.db