Skip to content
Snippets Groups Projects
Commit 09587489 authored by Marc's avatar Marc
Browse files

databases will be downloaded without testing on availability at the first run;...

databases will be downloaded without testing on availability at the first run; while downloading a lockfile is created to stop other psot instances from downloading at the same time
parent 6c70e050
No related branches found
No related tags found
No related merge requests found
......@@ -7,15 +7,27 @@ S3BUCKET='psot-databases'
# list of database folders, downloaded as tar-archives
list='ghostx uniprot pfam-31'
function make_datadir_and_sync () {
echo "Synchronizing databases because of first run"
mkdir -p $DATADIR
sync_data "$list"
}
function test_datadir () {
if ! [[ -e $DATADIR && -d $DATADIR ]]; then
mkdir $DATADIR
echo "Could not find databases in config given path"
mkdir -p $DATADIR
sync_data "$list"
elif ! all_folders_in_datadir "test_true"; then
echo "Missing databases in config given path"
sync_data "$(all_folders_in_datadir 'return_missing')"
fi
}
function all_folders_in_datadir () {
......@@ -37,27 +49,32 @@ function all_folders_in_datadir () {
else
echo "$new_list"
fi
}
function sync_data () {
echo "Could not find databases in config given path"
echo "Download databases... "
echo "Downloading databases... "
cd $DATADIR
download_list=$1
for ele in $download_list; do
wget -q "https://${S3BUCKET}.s3.computational.bio.uni-giessen.de/${ele}.tar.gz"
tar -zxf "${ele}.tar.gz"
rm "${ele}.tar.gz"
done
ln -s -f 'pfam-31/' 'pfam'
echo "[$(date)] psot (PID $$) downloaded databases to $DATADIR" >> $LOGFILE
if [[ -e lockfile ]]; then
while [[ -e lockfile ]]; do
sleep 0.01
done
else
echo "[$(date)] lockfile created from psot (PID $$)" > lockfile
download_list=$1
for ele in $download_list; do
wget -q "https://${S3BUCKET}.s3.computational.bio.uni-giessen.de/${ele}.tar.gz"
tar -zxf "${ele}.tar.gz"
rm "${ele}.tar.gz"
done
ln -s -f 'pfam-31/' 'pfam'
echo "[$(date)] psot (PID $$) downloaded databases to $DATADIR" >> $LOGFILE
rm lockfile
fi
}
function fail () {
......@@ -71,5 +88,5 @@ if [[ -e $LOGFILE ]]; then
test_datadir
else
echo "[$(date)] logfile created from psot (PID $$)" > $LOGFILE
test_datadir
make_datadir_and_sync
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment