forked from SamStudio8/asklepian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgo_db.sh
executable file
·42 lines (31 loc) · 1.15 KB
/
go_db.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
#!/usr/bin/bash
source /cephfs/covid/software/eagle-owl/scripts/hootstrap.sh
source "$EAGLEOWL_CONF/common.sh"
source "$EAGLEOWL_CONF/asklepian/conf.sh"
# Activate env
eval "$(conda shell.bash hook)"
conda activate $CONDA_ASKLEPIAN
set -euo pipefail
cd $ASKLEPIAN_PUBDIR
# Get latest date
LAST_DIR_NAME=`readlink latest`
LAST_DIR_DATE=`basename $LAST_DIR_NAME`
# Init new database
touch asklepian.${LAST_DIR_DATE}.db
chmod 600 asklepian.${LAST_DIR_DATE}.db
sqlite3 asklepian.${LAST_DIR_DATE}.db < $ASKLEPIAN_DIR/sqlite3.cmd
# Get line count (probably a little time consuming)
LINE_COUNT=$(wc -l < /cephfs/covid/bham/results/variants/latest/naive_variant_table.csv)
LINE_COUNT=$((LINE_COUNT-1)) # Subtract header
# Get new db row count
ROW_COUNT=`echo 'SELECT COUNT(*) from variants;' | sqlite3 asklepian.${LAST_DIR_DATE}.db`
if [ "$LINE_COUNT" -eq "$ROW_COUNT" ]; then
OLD_DB=`readlink -f asklepian.latest.db`
# Update symlink
chmod 644 $ASKLEPIAN_PUBDIR/asklepian.${LAST_DIR_DATE}.db
ln -fn -s $ASKLEPIAN_PUBDIR/asklepian.${LAST_DIR_DATE}.db $ASKLEPIAN_PUBDIR/asklepian.latest.db
# Remove previous database
rm ${OLD_DB}
else
exit 2
fi