forked from open2c/distiller-nf
/
setup_test.sh
38 lines (28 loc) · 988 Bytes
/
setup_test.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
#!/bin/bash
# The goal of this script is to download data files hosted an a github repo.
# The script has to work both on Linux and MacOS so we could not use some
# nice Linux-specific features of tar and instead had to manually extract
# necessary files via a temp folder.
set -ex
PROJECT_DIR=$(pwd)/test
mkdir -p ${PROJECT_DIR}
TMPDATADIR=`mktemp -d 2>/dev/null || mktemp -d -t 'TMPDATADIR'`
# check if tmp dir was created
if [[ ! "$TMPDATADIR" || ! -d "$TMPDATADIR" ]]; then
echo "Could not create temp dir"
exit 1
fi
# deletes the temp directory at exit
function cleanup {
rm -rf "$TMPDATADIR"
echo "Deleted temp directory $TMPDATADIR"
}
trap cleanup EXIT
cd ${TMPDATADIR}
curl -LkSs https://api.github.com/repos/mirnylab/distiller-test-data/tarball \
| tar -zxf -
# cd to the first (and the only) folder that was extracted from the tarball
cd $(ls -d */|head -n 1)
mv -n ./genome ${PROJECT_DIR}
mv -n ./fastq ${PROJECT_DIR}
cd ${PROJECT_DIR}