Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Data in Synapse can be downloaded using the programmatic clients (Python, R, and command line) as well as the web client. In this guide, you will learn the basic commands to download data programmatically. For instructions on how to download data from the web, see Downloading files in our quick start guide.

Downloading

...

files

Before you begin, it is important to understand that most items in Synapse have a unique identifier associated with them. This identifier is called a Synapse ID, or a synID. The synID format is the prefix “syn” followed by 8 numbers (for example, syn12345678). Items that have unique synIDs in Synapse are: files, folders, projects, tables, views, wikis, links, and Docker repositories. You can use synIDs to refer to specific items when working with Synapse programmatically.

...

Code Block
languager
filepath <- entity$path

Downloading a specific version

If there are multiple versions of a file, a specific version can be downloaded by passing the version parameter.

...

See /wiki/spaces/DOCS/pages/2668134540 for more details.

Links

When you click on a link on the Synapse website, it will redirect you to the linked entity. The followLink parameter will have to be specified when using the programmatic clients or you will only retrieve the link itself without downloading the linked entity.

...

Code Block
library(synapser)
synLogin()
linkEnt = synGet("syn1234")
entity = synGet("syn1234", followLink=TRUE)

Download location

To override the default download location, you can specify the downloadLocation parameter.

...

Code Block
entity <- synGet("syn00123", downloadLocation="/path/to/folder")

Finding and downloading files

Files can be annotated in Synapse to help organize your data and make files findable. In order to search the annotations, a /wiki/spaces/DOCS/pages/2011070739 must be created first.

...

Code Block
languager
results <- synTableQuery('select * from syn7511263 where dataType="mRNA" AND fileType="fastq" AND Cell_Type_of_Origin="CD34+ cells"')
df <- as.data.frame(results)
entity <- lapply(df$file.id, function(x) synGet(x))

Recursive downloads

The folder structure that is present on Synapse can be maintained by recursive downloading.

...

Code Block
# Unfortunately, this feature is not available in the R client

Download wikis

The structure of a wiki page can be extracted through the R and Python clients. The ID, title, and parent wiki page of each sub-wiki page is also determined through the same method.

...

Code Block
entity <- synGet("syn00123")
wiki <- synGetWiki(entity, 12345)

Downloading in bulk

Files can be downloaded in bulk using the syncFromSynapse function found in the synapseutils helper package. This function crawls all the subfolders of the project or folder that you specify and retrieves all the files that have not been downloaded. By default, the files will be downloaded into your synapseCache, but a different download location can be specified with the path parameter. If you do download to a location out side of synapseCache, this function will also create a tab-delimited manifest of all the files along with their metadata (path, provenance, annotations, etc).

...