pyopencga


Namepyopencga JSON
Version 3.3.0 PyPI version JSON
download
home_pagehttps://github.com/opencb/opencga/tree/develop/opencga-client/src/main/python/pyopencga
SummaryA REST client for OpenCGA REST web services
upload_time2024-10-15 17:38:19
maintainerNone
docs_urlNone
authorPablo Marin-Garcia, Daniel Perez-Gil
requires_pythonNone
licenseApache Software License
keywords opencb opencga bioinformatics genomic database
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. 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 `OpenCGA Docs`_

Installation
------------

PyOpenCGA can be installed from the Pypi repository. Make sure you have pip available in your machine. You can check this by running::

   $ python3 -m pip --version


If you don't have Python or pip, please refer to https://packaging.python.org/en/latest/tutorials/installing-packages/

To install PyOpencga, 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 opencga host OR a client-configuration.yml file with that information:

.. code-block:: python

    >>> config = ClientConfiguration('/opt/opencga/conf/client-configuration.yml')
    >>> config = ClientConfiguration({
            "rest": {
                    "host": "https://demo.app.zettagenomics.com/opencga"
            }
        })

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='user', password='pass', organization='organization')

Examples
````````

The first 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
    >>> individuals = oc.individuals  # Individual client
    >>> cohorts = oc.cohorts  # Cohort client

Now you can start querying 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 query response data:

.. code-block:: python

    >>> foo_client.method().get_responses()  # Iterates over all the responses
    >>> foo_client.method().get_results()  # Iterates over all the results of the first response

Data can be accessed specifying comma-separated IDs or a list of IDs.

e.g. Retrieving individual karyotypic sex for a list of individuals:

.. code-block:: python

    >>> for result in oc.samples.info(samples='NA12877,NA12878,NA12889', study='platinum').get_results():
    ...     print(result['id'], result['karyotypicSex'])
    NA12877 XY
    NA12878 XX
    NA12889 XY

    >>> for result in oc.samples.info(samples=['NA12877', 'NA12878', 'NA12889'], study='platinum').get_results():
    ...     print(result['id'], result['karyotypicSex'])
    NA12877 XY
    NA12878 XX
    NA12889 XY

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, log into `OpenCGA Demo`_ and check the **OpenCGA REST API** in the **About** section (at the top right corner of the screen).

.. _OpenCGA: https://github.com/opencb/opencga
.. _OpenCGA Docs: http://docs.opencb.org/display/opencga
.. _OpenCGA REST API: https://demo.app.zettagenomics.com/
.. _OpenCGA Demo: https://demo.app.zettagenomics.com/

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/opencb/opencga/tree/develop/opencga-client/src/main/python/pyopencga",
    "name": "pyopencga",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "opencb opencga bioinformatics genomic database",
    "author": "Pablo Marin-Garcia, Daniel Perez-Gil",
    "author_email": "pablo.marin@zettagenomics.com, daniel.perez@zettagenomics.com",
    "download_url": "https://files.pythonhosted.org/packages/7e/33/5b94c912ce3f4f8d0a0a6773baa1eb1c1595c06655908e7cb06178b63113/pyopencga-3.3.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 few 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 `OpenCGA Docs`_\n\nInstallation\n------------\n\nPyOpenCGA can be installed from the Pypi repository. Make sure you have pip available in your machine. You can check this by running::\n\n   $ python3 -m pip --version\n\n\nIf you don't have Python or pip, please refer to https://packaging.python.org/en/latest/tutorials/installing-packages/\n\nTo install PyOpencga, run the following command in the shell::\n\n   $ pip install pyopencga\n\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 opencga host OR a client-configuration.yml file with that information:\n\n.. code-block:: python\n\n    >>> config = ClientConfiguration('/opt/opencga/conf/client-configuration.yml')\n    >>> config = ClientConfiguration({\n            \"rest\": {\n                    \"host\": \"https://demo.app.zettagenomics.com/opencga\"\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='user', password='pass', organization='organization')\n\nExamples\n````````\n\nThe first 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    >>> individuals = oc.individuals  # Individual client\n    >>> cohorts = oc.cohorts  # Cohort client\n\nNow you can start querying 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 query response data:\n\n.. code-block:: python\n\n    >>> foo_client.method().get_responses()  # Iterates over all the responses\n    >>> foo_client.method().get_results()  # Iterates over all the results of the first response\n\nData can be accessed specifying comma-separated IDs or a list of IDs.\n\ne.g. Retrieving individual karyotypic sex for a list of individuals:\n\n.. code-block:: python\n\n    >>> for result in oc.samples.info(samples='NA12877,NA12878,NA12889', study='platinum').get_results():\n    ...     print(result['id'], result['karyotypicSex'])\n    NA12877 XY\n    NA12878 XX\n    NA12889 XY\n\n    >>> for result in oc.samples.info(samples=['NA12877', 'NA12878', 'NA12889'], study='platinum').get_results():\n    ...     print(result['id'], result['karyotypicSex'])\n    NA12877 XY\n    NA12878 XX\n    NA12889 XY\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, log into `OpenCGA Demo`_ and check the **OpenCGA REST API** in the **About** section (at the top right corner of the screen).\n\n.. _OpenCGA: https://github.com/opencb/opencga\n.. _OpenCGA Docs: http://docs.opencb.org/display/opencga\n.. _OpenCGA REST API: https://demo.app.zettagenomics.com/\n.. _OpenCGA Demo: https://demo.app.zettagenomics.com/\n",
    "bugtrack_url": null,
    "license": "Apache Software License",
    "summary": "A REST client for OpenCGA REST web services",
    "version": "3.3.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": "4a83669f15be1284f469dc3c94915753577f239e29196d4c5439ed30c58cebc0",
                "md5": "fa4ab72aa75510b9a60e4c03076be41b",
                "sha256": "a243462e0128efd9c9dd45d423ebc2bbec0b2657fa3f5a350fb44a4e0a8b2e80"
            },
            "downloads": -1,
            "filename": "pyopencga-3.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fa4ab72aa75510b9a60e4c03076be41b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 81272,
            "upload_time": "2024-10-15T17:38:17",
            "upload_time_iso_8601": "2024-10-15T17:38:17.469718Z",
            "url": "https://files.pythonhosted.org/packages/4a/83/669f15be1284f469dc3c94915753577f239e29196d4c5439ed30c58cebc0/pyopencga-3.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7e335b94c912ce3f4f8d0a0a6773baa1eb1c1595c06655908e7cb06178b63113",
                "md5": "3aa2096ed23f5746f16c91bb0902c0d4",
                "sha256": "08aa46eb09ac7254046b632337b58811ec6bc88cdb2ca7fcf42f2c4e6e967fc9"
            },
            "downloads": -1,
            "filename": "pyopencga-3.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3aa2096ed23f5746f16c91bb0902c0d4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 59419,
            "upload_time": "2024-10-15T17:38:19",
            "upload_time_iso_8601": "2024-10-15T17:38:19.425125Z",
            "url": "https://files.pythonhosted.org/packages/7e/33/5b94c912ce3f4f8d0a0a6773baa1eb1c1595c06655908e7cb06178b63113/pyopencga-3.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-15 17:38:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "opencb",
    "github_project": "opencga",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pyopencga"
}
        
Elapsed time: 0.38568s