.. contents::
PyOpenCGA
==========
This Python client package makes use of the comprehensive RESTful web services API implemented for the `OpenCGA`_ platform.
OpenCGA is an open-source project that implements a high-performance, scalable and secure platform for Genomic data analysis and visualisation
OpenCGA implements a secure and high performance platform for Big Data analysis and visualisation in current genomics.
OpenCGA uses the most modern and advanced technologies to scale to petabytes of data. OpenCGA is designed and implemented to work with
few million genomes. It is built on top of three main components: Catalog, Variant and Alignment Storage and Analysis.
More info about this project in the `OpenCGA Docs`_
Installation
------------
Cloning
```````
PyOpenCGA can be cloned in your local machine by executing in your terminal::
$ git clone https://github.com/opencb/opencga.git
Once you have downloaded the project you can install the library. We recommend to install it inside a `virtual environment`_::
$ cd opencga/tree/develop/opencga-client/src/main/python/pyOpenCGA
$ python setup.py install
Pip install
```````````
Run the following command in the shell::
$ pip install pyopencga
Usage
-----
Import pyOpenCGA package
````````````````````````
The first step is to import the ClientConfiguration and OpenCGAClient from pyOpenCGA:
.. code-block:: python
>>> from pyopencga.opencga_config import ClientConfiguration
>>> from pyopencga.opencga_client import OpenCGAClient
Setting up server host configuration
````````````````````````````````````
The second step is to generate a ClientConfiguration instance by passing a configuration dictionary containing the host to point to or a client-configuration.yml file:
.. code-block:: python
>>> config = ClientConfiguration('/opt/opencga/conf/client-configuration.yml')
>>> config = ClientConfiguration({
"rest": {
"host": "http://bioinfo.hpc.cam.ac.uk/opencga-demo"
}
})
Log in to OpenCGA host server
`````````````````````````````
With this configuration you can initialize the OpenCGAClient, and log in:
.. code-block:: python
>>> oc = OpenCGAClient(config)
>>> oc.login('user')
For scripting or using Jupyter Notebooks is preferable to load user credentials from an external JSON file.
Once you are logged in, it is mandatory to use the token of the session to propagate the access of the clients to the host server:
.. code-block:: python
>>> token = oc.token
>>> print(token)
eyJhbGciOi...
>>> oc = OpenCGAClient(configuration=config_dict, token=token)
Examples
````````
The next step is to get an instance of the clients we may want to use:
.. code-block:: python
>>> projects = oc.projects # Project client
>>> studies = oc.studies # Study client
>>> samples = oc.samples # Sample client
>>> cohorts = oc.cohorts # Cohort client
Now you can start asking to the OpenCGA RESTful service with pyOpenCGA:
.. code-block:: python
>>> for project in projects.search(owner=user).get_results():
... print(project['id'])
project1
project2
[...]
There are two different ways to access to the query response data:
.. code-block:: python
>>> foo_client.method().get_results() # Iterates over all the results of all the QueryResults
>>> foo_client.method().get_responses() # Iterates over all the responses
Data can be accessed specifying comma-separated IDs or a list of IDs:
.. code-block:: python
>>> samples = 'NA12877,NA12878,NA12879'
>>> samples_list = ['NA12877','NA12878','NA12879']
>>> sc = oc.samples
>>> for result in sc.info(query_id=samples, study='user@project1:study1').get_results():
... print(result['id'], result['attributes']['OPENCGA_INDIVIDUAL']['disorders'])
NA12877 [{'id': 'OMIM6500', 'name': "Chron's Disease"}]
NA12878 []
NA12879 [{'id': 'OMIM6500', 'name': "Chron's Disease"}]
>>> for result in sc.info(query_id=samples_list, study='user@project1:study1').get_results():
... print(result['id'], result['attributes']['OPENCGA_INDIVIDUAL']['disorders'])
NA12877 [{'id': 'OMIM6500', 'name': "Chron's Disease"}]
NA12878 []
NA12879 [{'id': 'OMIM6500', 'name': "Chron's Disease"}]
Optional filters and extra options can be added as key-value parameters (where the values can be a comma-separated string or a list).
What can I ask for?
```````````````````
The best way to know which data can be retrieved for each client check `OpenCGA web services`_ swagger.
.. _OpenCGA: https://github.com/opencb/opencga
.. _OpenCGA Docs: http://docs.opencb.org/display/opencga
.. _virtual environment: https://help.dreamhost.com/hc/en-us/articles/115000695551-Installing-and-using-virtualenv-with-Python-3
.. _OpenCGA web services: http://bioinfodev.hpc.cam.ac.uk/opencga/webservices/
Raw data
{
"_id": null,
"home_page": "https://github.com/opencb/opencga/tree/develop/opencga-client/src/main/python/pyopencga",
"name": "pyopencga",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "opencb opencga bioinformatics genomic database",
"author": "David Gomez-Peregrina, Pablo Marin-Garcia, Daniel Perez-Gil",
"author_email": "david.gomez@mgviz.org, pmarin@kanteron.com, dp529@cam.ac.uk",
"download_url": "https://files.pythonhosted.org/packages/2b/14/936827e953f83b62835302c9340d5267987b06fcfc774988782227d75ee1/pyopencga-3.0.0.tar.gz",
"platform": null,
"description": ".. contents::\n\nPyOpenCGA\n==========\n\nThis Python client package makes use of the comprehensive RESTful web services API implemented for the `OpenCGA`_ platform.\nOpenCGA is an open-source project that implements a high-performance, scalable and secure platform for Genomic data analysis and visualisation\n\nOpenCGA implements a secure and high performance platform for Big Data analysis and visualisation in current genomics.\nOpenCGA uses the most modern and advanced technologies to scale to petabytes of data. OpenCGA is designed and implemented to work with\nfew million genomes. It is built on top of three main components: Catalog, Variant and Alignment Storage and Analysis.\n\nMore info about this project in the `OpenCGA Docs`_\n\nInstallation\n------------\n\nCloning\n```````\nPyOpenCGA can be cloned in your local machine by executing in your terminal::\n\n $ git clone https://github.com/opencb/opencga.git\n\nOnce you have downloaded the project you can install the library. We recommend to install it inside a `virtual environment`_::\n\n $ cd opencga/tree/develop/opencga-client/src/main/python/pyOpenCGA\n $ python setup.py install\n\nPip install\n```````````\nRun the following command in the shell::\n\n $ pip install pyopencga\n\nUsage\n-----\n\nImport pyOpenCGA package\n````````````````````````\n\nThe first step is to import the ClientConfiguration and OpenCGAClient from pyOpenCGA:\n\n.. code-block:: python\n\n >>> from pyopencga.opencga_config import ClientConfiguration\n >>> from pyopencga.opencga_client import OpenCGAClient\n\nSetting up server host configuration\n````````````````````````````````````\n\nThe second step is to generate a ClientConfiguration instance by passing a configuration dictionary containing the host to point to or a client-configuration.yml file:\n\n.. code-block:: python\n\n >>> config = ClientConfiguration('/opt/opencga/conf/client-configuration.yml')\n >>> config = ClientConfiguration({\n \"rest\": {\n \"host\": \"http://bioinfo.hpc.cam.ac.uk/opencga-demo\"\n }\n })\n\nLog in to OpenCGA host server\n`````````````````````````````\n\nWith this configuration you can initialize the OpenCGAClient, and log in:\n\n.. code-block:: python\n\n >>> oc = OpenCGAClient(config)\n >>> oc.login('user')\n\nFor scripting or using Jupyter Notebooks is preferable to load user credentials from an external JSON file.\n\nOnce you are logged in, it is mandatory to use the token of the session to propagate the access of the clients to the host server:\n\n.. code-block:: python\n\n >>> token = oc.token\n >>> print(token)\n eyJhbGciOi...\n\n >>> oc = OpenCGAClient(configuration=config_dict, token=token)\n\nExamples\n````````\n\nThe next step is to get an instance of the clients we may want to use:\n\n.. code-block:: python\n\n >>> projects = oc.projects # Project client\n >>> studies = oc.studies # Study client\n >>> samples = oc.samples # Sample client\n >>> cohorts = oc.cohorts # Cohort client\n\nNow you can start asking to the OpenCGA RESTful service with pyOpenCGA:\n\n.. code-block:: python\n\n >>> for project in projects.search(owner=user).get_results():\n ... print(project['id'])\n project1\n project2\n [...]\n\nThere are two different ways to access to the query response data:\n\n.. code-block:: python\n\n >>> foo_client.method().get_results() # Iterates over all the results of all the QueryResults\n >>> foo_client.method().get_responses() # Iterates over all the responses\n\nData can be accessed specifying comma-separated IDs or a list of IDs:\n\n.. code-block:: python\n\n >>> samples = 'NA12877,NA12878,NA12879'\n >>> samples_list = ['NA12877','NA12878','NA12879']\n >>> sc = oc.samples\n\n >>> for result in sc.info(query_id=samples, study='user@project1:study1').get_results():\n ... print(result['id'], result['attributes']['OPENCGA_INDIVIDUAL']['disorders'])\n NA12877 [{'id': 'OMIM6500', 'name': \"Chron's Disease\"}]\n NA12878 []\n NA12879 [{'id': 'OMIM6500', 'name': \"Chron's Disease\"}]\n\n >>> for result in sc.info(query_id=samples_list, study='user@project1:study1').get_results():\n ... print(result['id'], result['attributes']['OPENCGA_INDIVIDUAL']['disorders'])\n NA12877 [{'id': 'OMIM6500', 'name': \"Chron's Disease\"}]\n NA12878 []\n NA12879 [{'id': 'OMIM6500', 'name': \"Chron's Disease\"}]\n\nOptional filters and extra options can be added as key-value parameters (where the values can be a comma-separated string or a list).\n\nWhat can I ask for?\n```````````````````\nThe best way to know which data can be retrieved for each client check `OpenCGA web services`_ swagger.\n\n\n.. _OpenCGA: https://github.com/opencb/opencga\n.. _OpenCGA Docs: http://docs.opencb.org/display/opencga\n.. _virtual environment: https://help.dreamhost.com/hc/en-us/articles/115000695551-Installing-and-using-virtualenv-with-Python-3 \n.. _OpenCGA web services: http://bioinfodev.hpc.cam.ac.uk/opencga/webservices/\n",
"bugtrack_url": null,
"license": "Apache Software License",
"summary": "A REST client for OpenCGA REST web services",
"version": "3.0.0",
"project_urls": {
"Bug Reports": "https://github.com/opencb/opencga/issues",
"Documentation": "http://docs.opencb.org/display/opencga/Python",
"Homepage": "https://github.com/opencb/opencga/tree/develop/opencga-client/src/main/python/pyopencga",
"OpenCGA": "https://github.com/opencb/opencga",
"OpenCGA Documentation": "http://docs.opencb.org/display/opencga",
"Source": "https://github.com/opencb/opencga/tree/develop/opencga-client/src/main/python/pyopencga"
},
"split_keywords": [
"opencb",
"opencga",
"bioinformatics",
"genomic",
"database"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "15ff76f59b3501b59d26300b6dcd1f3c71819be076b9c5724648b00429ac6703",
"md5": "e850a947acef51b449abd9b3b1947309",
"sha256": "60f65c046a341b0cd0f87b440371c2a8933fb899a61e01b0bd27f4e6f5f51269"
},
"downloads": -1,
"filename": "pyopencga-3.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e850a947acef51b449abd9b3b1947309",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 86568,
"upload_time": "2024-03-07T17:49:15",
"upload_time_iso_8601": "2024-03-07T17:49:15.374460Z",
"url": "https://files.pythonhosted.org/packages/15/ff/76f59b3501b59d26300b6dcd1f3c71819be076b9c5724648b00429ac6703/pyopencga-3.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2b14936827e953f83b62835302c9340d5267987b06fcfc774988782227d75ee1",
"md5": "c4a35a2b37fa3556a011b8eff92ce73b",
"sha256": "e03dcc0c76f89dfb7e8be8f44827046111bb3cf7c91999c5a14e899bb43ef380"
},
"downloads": -1,
"filename": "pyopencga-3.0.0.tar.gz",
"has_sig": false,
"md5_digest": "c4a35a2b37fa3556a011b8eff92ce73b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 63623,
"upload_time": "2024-03-07T17:49:17",
"upload_time_iso_8601": "2024-03-07T17:49:17.118361Z",
"url": "https://files.pythonhosted.org/packages/2b/14/936827e953f83b62835302c9340d5267987b06fcfc774988782227d75ee1/pyopencga-3.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-07 17:49:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "opencb",
"github_project": "opencga",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pyopencga"
}