Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add helper script for downloading dataset+sidecars #1664

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions scripts/get-dataset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
# A simple, non-battle-hardened, script to help downloading a dataset
# and corresponding sidecars for testing locally with auspice.
#
# Examples:
# ./scripts/get-dataset.sh nextstrain.org/zika data
# ./scripts/get-dataset.sh nextstrain.org/community/joverlee521/nextstrain-testing/flu/seasonal/h1n1pdm/ha/09-17 datasets
echo "Getting dataset + sidecars associated with $1 and downloading them to $2"

if [ ! -d "${2}" ]; then
echo "Directory ${2} doesn't exist!";
exit 2;
fi

dataset_suffix=${1#*nextstrain.org/}
dataset_underscores=${dataset_suffix//\//_}
dest="${2%/}/${dataset_underscores}.json"

main="https://nextstrain.org/charon/getDataset?prefix=${dataset_suffix}"
if [[ $( curl -iI -sw "%{http_code}" "${main}" -o /dev/null ) == 200 ]]; then
curl "${main}" --compressed --output "${dest}"
echo Downloaded main JSON to "${dest}"
else
echo "Cannot download main JSON. Fatal!"
exit 3
fi

sidecar="tip-frequencies"
if [[ $( curl -iI -sw "%{http_code}" "${main}&type=${sidecar}" -o /dev/null ) == 200 ]]; then
curl "${main}&type=${sidecar}" --compressed --output "${dest%.json}_${sidecar}.json"
echo Downloaded ${sidecar} JSON to "${dest%.json}_${sidecar}.json"
else
echo "Cannot download ${sidecar} JSON. Continuing..."
fi

sidecar="root-sequence"
if [[ $( curl -iI -sw "%{http_code}" "${main}&type=${sidecar}" -o /dev/null ) == 200 ]]; then
curl "${main}&type=${sidecar}" --compressed --output "${dest%.json}_${sidecar}.json"
echo Downloaded ${sidecar} JSON to "${dest%.json}_${sidecar}.json"
else
echo "Cannot download ${sidecar} JSON. Continuing..."
fi

sidecar="measurements"
if [[ $( curl -iI -sw "%{http_code}" "${main}&type=${sidecar}" -o /dev/null ) == 200 ]]; then
curl "${main}&type=${sidecar}" --compressed --output "${dest%.json}_${sidecar}.json"
echo Downloaded ${sidecar} JSON to "${dest%.json}_${sidecar}.json"
else
echo "Cannot download ${sidecar} JSON. Continuing..."
fi