Created
February 1, 2017 16:42
-
-
Save pontikos/034cc66af9f7d919c0ab719b2fef897a to your computer and use it in GitHub Desktop.
Basespace downloader, obtains urls which you can then wget
This file contains hidden or 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
import sys | |
import requests | |
# print urls of fastq files to download | |
# obtain access token by following instructions here: | |
# https://support.basespace.illumina.com/knowledgebase/articles/403618-python-run-downloader | |
AccessToken=sys.argv[1] | |
# user | |
ep='/v1pre3/users/current' | |
r2 = requests.get('https://api.basespace.illumina.com/'+ep,{'access_token':AccessToken}) | |
r=r2.json() | |
# projects | |
ep=r['Response']['HrefProjects'] | |
r2 = requests.get('https://api.basespace.illumina.com/'+ep,{'access_token':AccessToken}) | |
r=r2.json() | |
for x in r['Response']['Items']: | |
pid=x['Id'] | |
ep='/v1pre3/projects/%s/samples' % pid | |
r2 = requests.get('https://api.basespace.illumina.com/'+ep,{'access_token':AccessToken}) | |
r=r2.json() | |
r=r['Response'] | |
if 'Items' not in r: continue | |
for x in r['Items']: | |
id=x['Id'] | |
ep='/v1pre3/samples/%s/files' % id | |
r2 = requests.get('https://api.basespace.illumina.com/'+ep,{'access_token':AccessToken}) | |
r=r2.json() | |
r=r['Response'] | |
if 'Items' not in r: continue | |
for x2 in r['Items']: | |
ep=x2['HrefContent'] | |
path=x2['Path'] | |
print 'wget https://api.basespace.illumina.com/'+ep+'?access_token='+str(AccessToken)+' -O '+str(path) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment