#!/bin/bash  

# define resource
resource=atlas_oglcnac

# add the time stamped folder
cd /data/projects/glygen/downloads/$resource/

new_dir=$(date +%Y_%m_%d)
mkdir $new_dir

# download files to new folder
cd /data/projects/glygen/downloads/$resource/$new_dir

# update file names here if the version changes
wget -O ambiguous_sites.csv "https://oglcnac.org/home/bach/O-GlcNAcDB/static/dataset/Ambiguous_AtlasV3.0.csv" &
sleep 5
wget -O unambiguous_sites.csv "https://oglcnac.org/home/bach/O-GlcNAcDB/static/dataset/Unambiguous_AtlasV3.0.csv" &

wait # Wait until all downloads are complete

# update new folder permissions
chmod -R 775 /data/shared/glygen/downloads/$resource/$new_dir/

# create symbolic link
cd /data/projects/glygen/downloads/$resource/
rm current
ln -s $new_dir current
