Skip to content

Instantly share code, notes, and snippets.

@cbare
Created April 2, 2014 19:45
Show Gist options
  • Select an option

  • Save cbare/9941685 to your computer and use it in GitHub Desktop.

Select an option

Save cbare/9941685 to your computer and use it in GitHub Desktop.
Demonstrate how to script file download from Synapse
import os
import synapseclient
syn = synapseclient.Synapse()
syn.login() # insert credentials here, unless you have a cached API key.
## ADChallenge_WorkingGroup (syn2343636) Files » ADNI » Genetics » GWAS
folder_id = 'syn2362101'
## Get all children of the parent folder
results = syn.chunkedQuery('select id,name,concreteType from entity where parentId=="%s"' % folder_id)
## Where would we like the files to go?
project_dir = '/Users/chris/Documents/work/projects/alzheimers_challenge'
destination_directory = os.path.join(project_dir, 'data/adni/gwas')
## download all files in the folder
entities = []
for result in results:
print "downloading", result['entity.id'], result['entity.name']
e = syn.get(result['entity.id'], downloadLocation=destination_directory)
entities.append(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment