Skip to content

Instantly share code, notes, and snippets.

@suqingdong
Created November 1, 2019 09:27
Show Gist options
  • Save suqingdong/5cb2c69bdc436dc3721fdf936a9edfde to your computer and use it in GitHub Desktop.
Save suqingdong/5cb2c69bdc436dc3721fdf936a9edfde to your computer and use it in GitHub Desktop.
COSMIC Data Downloader
username=your_username
password=your_password
auth_string=$(echo $username:$password | base64)
echo "# auth string: $auth_string"
cosmic_url=https://cancer.sanger.ac.uk/cosmic
# ===================
# get current version
# ===================
release=$(curl -s $cosmic_url/download | grep -oP 'Data Downloads \(release .+?\)')
current_version=$(echo $release | grep -oP 'v\d+')
echo "# current version: $current_version"
# ===================
# list file names
# ===================
files=$(curl -s $cosmic_url/download | grep -oP '"https://cancer.sanger.ac.uk/cosmic/file_download_info.+?"')
for file in $files;do
echo ${file##*%2F} | cut -d '"' -f 1
done > file.list
# ===================
# get download url
# ===================
ref_versions="GRCh37 GRCh38"
for ref_version in $ref_versions;do
echo mkdir $ref_version
while read file;do
url=$(
curl -sH "Authorization: Basic $auth_string" $cosmic_url/file_download/$ref_version/cosmic/$current_version/$file |
grep -oP '"https://.+"'
)
echo wget -c $url -O $ref_version/$file
done < file.list
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment