Created
November 1, 2019 09:27
-
-
Save suqingdong/5cb2c69bdc436dc3721fdf936a9edfde to your computer and use it in GitHub Desktop.
COSMIC Data Downloader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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