biogridpy is a Python client for the BioGRID webservice.
To install, clone the repository
$ git clone https://github.com/arvkevi/biogridpy.git
$ cd biogridpy
$ python setup.py
Before using the client, get a free access key here or if you already have one, see below:
Copy and paste the access key to the existing biogridpyrc file, or you can create a new biogridpyrc file anywhere you like.
$ vi biogridpyrc
biogridpyrc should look like this:
[BioGRID_ak]
access_key = YourAccessKeyHere
Instantiate the BioGRID client:
>>> from biogridpy.biogrid_client import BioGRID
>>> BG = BioGRID(config_filepath='/path/to/biogridpyrc') # provide path to biogridpyrc file
The interactions endpoint is the most commonly utilized. The first and only positional argument is a string that describes the type of result format. Valid keyword arguments are the same parameters from the parameter list. Any parameter that accepts a list of |
separated identifiers can be a Python list type object or a file with one identifier per line.
>>> results = BG.interactions('tab2', geneList=['RB1', 'E2F1'],
evidenceList='examples/evidenceList.list',
includeEvidence='true',
taxId=9606)
There are several attributes to describe and work with the result object:
>>> results.count
11
>>> results.output_format
'tab2'
>>> results.endpoint
'interactions'
>>> results.result #formatted result for downstream use
>>> results.raw_result #unformatted result
Available methods are meant to facilitate downstream analyses or for pipeline development. The export method will save the result object as a file in the proper format according to the format specified previously. The toDataFrame method simply formats the data for easy transformation to a pandas DataFrame object.
>>> results.export(outdir='../examples/example_results',
filename='E2F1_RB1_9606')
>>> import pandas as pd
>>> #you could use the following to transform the results regardless of type
try: #tab2, extendedTab2, tab1
df = pd.read_csv(bg_results.toDataFrame(), sep='\t')
except IOError as e: #json, jsonExtended
df = pd.read_json(bg_results.toDataFrame(), orient='index')
The following non-interaction endpoints are also available:
- evidence
- identifiers
- organisms
- version
Use the result attribute to view the response.
>>> evid = BG.evidence()
>>> evid.result[:5] #first 5 elements
['AFFINITY CAPTURE-LUMINESCENCE',
'AFFINITY CAPTURE-MS',
'AFFINITY CAPTURE-RNA',
'AFFINITY CAPTURE-WESTERN',
'BIOCHEMICAL ACTIVITY']
The IPython notebook walkthrough.ipynb provides in-depth examples of how to use each method.
$ cd biogridpy
$ jupyter notebook notebooks/walkthrough.ipynb
or
$ cd biogridpy
$ ipython notebook notebooks/walkthrough.ipynb
Winter AG, Wildenhain J, Tyers M. BioGRID REST Service, BiogridPlugin2 and BioGRID WebGraph: new tools for access to interaction data at BioGRID. Bioinformatics, 2011 Apr 1.