-
Notifications
You must be signed in to change notification settings - Fork 52
Python client
Python client code is implemented for Python 3 and distributed together with the rest of the CellBase code. Client code can be found at:
cellbase/clients/python
Both a Python library for programmatic access and a CLI are provided:
The Python library code can be accessed at https://github.com/opencb/cellbase/tree/develop/clients/python/lib Programmatic API is provided by the CellBaseClient class. This class can be configured by means of a configuration.json file. CellBaseClient class will access the RESTful Web Services through the get method it implements. Thus, this method needs to be provided with those parameters which are required by the URL: appropriate species name (e.g. hsapiens), subcategory of data to query (e.g. gene, category is not required since can be inferred from the subcategory value), id to search for (e.g. HGNC symbol) and method to query (e.g. search). Not all of these values are required for al possible queries. Please, for more details on possible values and value-combinations for these parameters refer to http://bioinfo.hpc.cam.ac.uk/cellbase/webservices and https://github.com/opencb/cellbase/wiki/RESTful-web-services.
Please, find more details on how to install the python package and how to use the python library at: Using the Python client
The client provides a CLI which can be accessed through the executable at:
cellbase$ python3 clients/python/cellbase-client.py -h
usage: cellbase-client.py [-h] --type T [-o OUTPUT] --resource M
[--id I [I ...]] [--species S] [--conf I]
[--include F [F ...] | --exclude X [X ...]]
[--limit LIMIT] [--skip SKIP]
CellBase client 1.0
optional arguments:
-h, --help show this help message and exit
--type T String indicating the subcategory of the IDs to be
queried
-o OUTPUT, --output OUTPUT
store the results to a json file
--resource M String indicating the method to be queried
--id I [I ...] String indicating the id(s) to be queried (if needed)
--species S String indicating the species to query
--conf I Path to a .json file containing CellBase client
configuration (if needed)
--include F [F ...] String indicating the field to be returned
--exclude X [X ...] String indicating the field to be excluded
--limit LIMIT Integer indicating the number of results to be
returned (if neede)
--skip SKIP Integer indicating the number of results to skip (if
needed)
The CLI will access CellBase data through the REST API and implements all its functionality. Please, for more details on possible values and value-combinations for these parameters refer to http://bioinfo.hpc.cam.ac.uk/cellbase/webservices and https://github.com/opencb/cellbase/wiki/RESTful-web-services.
Client configuration parameters can be found at:
cellbase/clients/python/lib/resources/configuration.json
Main configuration parameters have to do with the CellBase version the client will query, host url and host port. Please see below an example of the configuration.json content:
{
"version": "v4",
"apiVersion": "v4.0",
"wiki": "https://github.com/opencb/cellbase/wiki",
"database": {
"hosts": {
"first": "bioinfodev.hpc.cam.ac.uk",
"second": ""
},
"port": 80
}
}