-
Notifications
You must be signed in to change notification settings - Fork 5
/
silva-run
executable file
·89 lines (69 loc) · 1.97 KB
/
silva-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
#!/usr/bin/env bash
set -eu
set -o pipefail
source ${SILVA_PATH:-$(dirname $0)}/init.sh
modeldir=$SILVA_PATH/src/models/forest
traineddir=$SILVA_TRAINED
function usage {
cat <<EOF
Usage: $0 OUTDIR
Runs pre-trained model on OUTDIR (created with silva-preprocess)
Pretrained models found in: $traineddir
As necessary, uses TMPDIR='$TMPDIR'
Ranked results printed to stdout.
EOF
exit 1
}
if [[ $# -ne 1 ]]; then
usage
fi
init_message "$0" "$@"
outdir="$(cd -P "$1"; pwd)"
if [[ ! -e $modeldir/test ]]; then
echo "Could not find test script: $modeldir/test" >&2
exit 1
fi
ext=.input
for mat in $outdir/*$ext; do
if [[ ! -e $mat ]]; then
echo "Error: expected $ext file in OUTDIR." >&2
echo "Was silva-preprocess successful?" >&2
exit 1
fi
base=$(basename $mat $ext)
fltfile="$base.flt"
if [[ ! -s $outdir/$fltfile ]]; then
echo "Error: expected $fltfile file in OUTDIR." >&2
echo "Was silva-preprocess successful?" >&2
exit 1
fi
matfile="$base.input"
if [[ ! -s $outdir/$matfile ]]; then
echo "Error: expected $matfile file in OUTDIR." >&2
echo "Was silva-preprocess successful?" >&2
exit 1
fi
for modelfile in $traineddir/*.model; do
pushd $modeldir > /dev/null
if [[ ! -s $modelfile ]]; then
echo "Error: could not find saved model: $modelfile" >&2
echo "Was silva-preprocess successful?" >&2
exit 1
fi
# Run saved model on MAT file and created score file
model=$(basename $modelfile .model)
scorefile=$model.scored
if [[ ! -s $outdir/$scorefile ]]; then
echo "Running model $model..." >&2
./test $modelfile $mat | cut -f 1 > $outdir/.$scorefile \
&& mv $outdir/.$scorefile $outdir/$scorefile
test -e $outdir/$scorefile
fi
popd > /dev/null
done
# Print scored examples to stdout
echo -e "\nPrinting scored variants to stdout..." >&2
$SILVA_PATH/src/util/summarize_scores.py $outdir/$fltfile $outdir/*.scored
break # Only process first MAT file
done
echo "$0: SUCCESS" >&2