-
Notifications
You must be signed in to change notification settings - Fork 6
Developer Usage
John Bradley edited this page Jan 17, 2018
·
6 revisions
Install DukeDSClient and setup your config file
import DukeDS
# Fetch list of all project names
project_names = DukeDS.list_projects()
for project_name in project_names:
print project_name
# Create a project named 'mouse' with description 'Mouse research'
DukeDS.create_project('mouse', 'Mouse research')
# List files in project 'mouse'
remote_file_paths = DukeDS.list_files('mouse')
for remote_file_path in remote_file_paths:
print remote_file_path
# Download the file at remote path 'results/data1.bam' in project 'mouse'
# to 'data1.bam' in the current directory
DukeDS.download_file('mouse', 'results/data1.bam')
# Download the file at remote path 'results/data1.bam' in project 'mouse' to '/tmp/data1.bam'
DukeDS.download_file('mouse', 'results/data1.bam', '/tmp/data1.bam')
# Upload a file to 'results/data2.bam' into project 'mouse' at remote path 'data2.bam'
DukeDS.upload_file('mouse', '/tmp/data2.bam)
# Upload a file to 'results/data2.bam' into project 'mouse' at remote path 'results2/data2.bam'
DukeDS.upload_file('mouse', '/tmp/data2.bam, 'results2/data2.bam')
# Delete the remote file 'results2/data2.bam' in project 'mouse'
DukeDS.delete_file('mouse', 'results2/data2.bam')
# delete the project named 'mouse'
DukeDS.delete_project('mouse')
Users working with large numbers can create a Session object and use all the methods available with DukeDS.
This object caches some data to speed up successive operations.
from ddsc.sdk.dukeds import Session
session = Session()
# Fetch list of all project names
project_names = session.list_projects()
for project_name in project_names:
print project_name
...