Mercurial > repos > iuc > ebi_metagenomics_run_downloader
diff download_ebi_metagenomics_run_data @ 0:e2e9fae080ad draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 7a9c88c1c80b80aaa63e55e9d9125b6a4dd695ac
author | iuc |
---|---|
date | Thu, 01 Dec 2016 15:27:59 -0500 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/download_ebi_metagenomics_run_data Thu Dec 01 15:27:59 2016 -0500 @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +set -e + +python_script=$1 +run_id=$2 +information_type=$3 +information_to_download=$4 +chunk_type=$5 +output_file=$6 + +touch $output_file + +run_link=$(python $python_script getRunLink $run_id) +run_link="$run_link/$information_type/$information_to_download" + +if [[ $chunk_type == 'multiple_chunks' ]]; then + chunk_nb=$(curl "$run_link/chunks") + + if [[ "$chunk_nb" < 1 ]]; then + >&2 echo "-----" + >&2 echo "ERROR" + >&2 echo "-----" + >&2 echo "No data are found for this link:" + >&2 echo "$run_link/chunks" + >&2 echo "-----" + exit 6 + fi + + for i in $(seq "$chunk_nb"); do + curl "$run_link/chunks/$i" | gunzip >> $output_file + done +else + curl "$run_link" >> $output_file +fi + +if [ ! -s $output_file ]; then + >&2 echo "-----" + >&2 echo "ERROR" + >&2 echo "-----" + >&2 echo "The output file is empty probably because the following link is not working:" + >&2 echo "$run_link" + >&2 echo "-----" + exit 6 +fi