Skip to content

Instantly share code, notes, and snippets.

@joachimjacob
Created January 23, 2013 15:50
Show Gist options
  • Save joachimjacob/4608477 to your computer and use it in GitHub Desktop.
Save joachimjacob/4608477 to your computer and use it in GitHub Desktop.
Aspera download script
#! /bin/bash
# Batch Download files from NCBI SRA using Aspera ascp on Mac / Linux
# to 'current_folder'/aspera_download
# remove space in 'Aspera\ connect'
# Stéphane Plaisance - VIB-BITS - Jan-2010 v1.0
# updated path to the user copy of the package (2011-02-28) v1.1
# –Q (for adaptive flow control) – needed for disk throttling!
# –T to disable encryption
# –k1 enable resume of failed transfers
# –l (maximum bandwidth of request, try 200M and go up from there)
# –r recursive copy
# –i <private key file>
##########################################
# edit path below here to fit your machine
##########################################
# findout which OS
thisos=`uname -a`
if [[ "$thisos" =~ "Linux" ]]; then
exefile="~/.aspera/connect/bin/ascp"
puttyfile="~/.aspera/connect/etc/asperaweb_id_dsa.putty"
echo "you run this script with Linux"
elif [[ $thisos =~ "Darwin" ]]; then
# remove space in App file name !!!
exefile="/Applications/AsperaConnect.app/Contents/Resources/ascp"
puttyfile="/Applications/AsperaConnect.app/Contents/Resources/asperaweb_id_dsa.putty"
echo "you run this script with macOSX"
else
echo "could not figure out your OS!"
exit 1
fi
# create folder if noy exist
dest=`pwd`
mkdir -p ${dest}
# get URL from browser
# ftp://ftp-trace.ncbi.nlm.nih.gov
# /sra/sra-instant/reads/ByExp/litesra/ERX/ERX000/ERX000065
read -p "paste here the link from SRA-lite: " -e url
fullpath="${url##ftp://ftp-trace.ncbi.nlm.nih.gov}"
ori="anonftp@ftp-private.ncbi.nlm.nih.gov:"${fullpath}
#CMD="${exefile} -i ${puttyfile} -k1 -QTr -l100m ${ori} ${dest}"
CMD="${exefile} -i ${puttyfile} -k1 -QTr -l100m anonftp@ftp-private.ncbi.nlm.nih.gov:/sra/sra-instant/reads/ByExp/litesra/SRX/SRX001/SRX001961 ${dest}"
eval $CMD
#fasp://anonftp@ftp-private.ncbi.nlm.nih.gov:22/sra/sra-instant/reads/ByRun/sra/DRR/DRR000/DRR000543/DRR000543.sra?auth=no&amp;port=33001&amp;bwcap=300000&amp;targetrate=100p&amp;policy=fair&amp;enc=none&amp;lockpolicy=no&amp;locktargetrate=no&amp;lockminrate=no&amp;v=2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment