Created
April 2, 2014 19:45
-
-
Save cbare/9941685 to your computer and use it in GitHub Desktop.
Demonstrate how to script file download from Synapse
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 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