view download_ebi_metagenomics_run_data @ 3:a1ef6c88ee37 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ebi_tools commit 31d1c92a4c12b6a78693dc5091a08536a075285e
author iuc
date Thu, 09 Feb 2017 12:02:47 -0500
parents e2e9fae080ad
children
line wrap: on
line source

#!/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