Skip to content

Python client

javild edited this page Jun 10, 2016 · 16 revisions

(Under construction)

Note: Python client available from version 4.1 onwards (current develop branch)

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:

Command Line Interface

The client provides a CLI which can be accessed through the executable at:

$ python3 cellbase/clients/python/pycellbase.py -h
usage: pycellbase.py [-h] --type T --method M [--id I [I ...]] [--species S]
                     [--options O [O ...]] [--conf I]

CellBase client 1.0

optional arguments:
  -h, --help           show this help message and exit
  --type T             String indicating the type of data to be queried
  --method 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
  --options O [O ...]  String with a list of &-separated filtering options.
                       For example: source=clinvar&skip=10&limit=200
  --conf I             Path to a .json file containing CellBase client
                       configuration (if needed)

The CLI will access CellBase data through the REST API and implements all its functionality. Please, see below allowed values for --type and --method parameters:

--type

Available options: "clinical","exon","gene","variant","chromosome","meta","protein","snp","tf","id"

--method

Available methods depend on selected data type at the previous --type parameter:

clinical: "all", "help", "listAcc", "phenotype-gene"

exon: "stats", "first", "help", "model", "count", "aminos", "info", "region", "sequence", "transcript"

gene: "tfbs", "biotype", "count", "first", "help", "list", "model", "stats", "clinical", "info", "mirna_target", "mutation", "next", "ppi", "protein", "snp", "stats", "all", "transcript", "count", "first", "fullinfo", "function_prediction", "gene", "mutation", "region", "sequence", "variation"

chromosome: "all", "help", "list", "model", "ctyoband", "info", "size"

meta: "help", "species", "versions"

protein: "gene", "help", "model", "fullinfo", "all", "info", "name", "reference", "sequence", "transcript"

region: "exon", "help", "model", "clinical", "conservation", "conserved_region", "cpg_island", "cytoband", "tfbs", "gene", "mutation", "phenotype", "regulatory", "sequence", "snp", "structural_variation", "transcript"

snp: "xref", "consequence_types", "count", "first", "help", "model", "sequence", "phenotypes", "regulatory", "stats", "info", "next", "phenotype", "population_frequency", "consequence_type"

species: "help", "info"

tf: "annotation", "help", "tfbs"

id: "help", "model", "contains", "gene", "info", "snp", "starts_with", "xref"

Configuration

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": "v3",
  "apiVersion": "v3.1",
  "wiki": "https://github.com/opencb/cellbase/wiki",
  "database": {
	"host": "bioinfodev.hpc.cam.ac.uk",
    "port": 80
  }
}
Clone this wiki locally