A python client for Sage Synapse, a collaborative compute space that allows scientists to share and analyze data together. Please visit the Getting Started Guide to Synapse page for more information.
The Python client can be used as a library for development of software that communicates with Synapse or as a command-line utility. See also the Synapse R client.
Note: This version of the Python client is necessary for compatibility with the January 25th, 2013 release of the Synapse platform. This platform update includes back-end changes and requires upgrading to the latest versions of the clients.
The python synapse client has been tested on python 2.7.
The Python Synapse Client is on PyPI and can be installed with pip:
pip install synapseclient
Clone the source code repository.
git clone git://github.com/Sage-Bionetworks/synapsePythonClient.git
cd synapsePythonClient
python setup.py install
The synapse client can be used from the shell command prompt. Valid commands include: query, get, cat, add, update, delete, and onweb. A few examples are shown.
querying for entities that are part of the Synapse Commons Repository
synapse -u me@nowhere.com -p secret query 'select id, name from entity where parentId=="syn150935"'
querying for a test entity
The test entity is tagged with an attribute test_data whose value is "bogus". We'll use the ID of this entity in the next example.
synapse -u me@nowhere.com -p secret query 'select id, name, parentId from entity where test_data=="bogus"'
synapse -u me@nowhere.com -p secret get syn1528299
synapse -h
Note that a synapse account is required.
The synapse client can be used to write software that interacts with the Sage Synapse repository.
import synapseclient
s = synapseclient.Synapse()
s.login('me@nowhere.com', 'secret')
e = s.getEntity('syn1528299')
print e['name']
print e['description']
print e['files']
querying for entities that are part of the Synapse Commons Repository
syn.query('select id, name from entity where parentId=="syn150935"')
querying for entities that are part of the TCGA that are also RNA-Seq data
syn.query('select id, name from entity where freeze=="tcga_pancancer_v4" and platform=="IlluminaHiSeq_RNASeqV2"')
Authentication toward synapse can be specified in three ways:
-
By passing username and password to the login function (or using the -u and -p parameters on the command line)
-
Creating a configuration file in the home directory called .synapseConfig that contains the username and password. See example below.
-
Using cached authentication. Everytime the client authenticates the credentials are cached for 24 hours. Meaning that subsequent interactions do not need the username and password credentials.
###Example config file stored in ~/.synapseConfig [authentication] username: me@nowhere.com password: secret
© Copyright 2012 Sage Bionetworks
This software is licensed under the Apache License, Version 2.0.