Skip to main content

A REST client for OpenCGA enterprise REST web services

Project description

PyXetabase

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

PyXetabase 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 pyXetabase, run the following command in the shell:

$ pip install pyxetabase

Usage

Import pyXetabase package

The first step is to import the ClientConfiguration and OpencgaClient from pyXetabase:

>>> from pyxetabase.opencga_config import ClientConfiguration
>>> from pyxetabase.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:

>>> config = ClientConfiguration('/opt/opencga-enterprise/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:

>>> 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:

>>> 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 pyXetabase:

>>> for project in projects.search(owner=user).get_results():
...    print(project['id'])
project1
project2
[...]

There are two different ways to access query response data:

>>> 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:

>>> 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).

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyxetabase-3.1.0.dev15.tar.gz (74.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyxetabase-3.1.0.dev15-py3-none-any.whl (177.8 kB view details)

Uploaded Python 3

File details

Details for the file pyxetabase-3.1.0.dev15.tar.gz.

File metadata

  • Download URL: pyxetabase-3.1.0.dev15.tar.gz
  • Upload date:
  • Size: 74.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pyxetabase-3.1.0.dev15.tar.gz
Algorithm Hash digest
SHA256 594544187c84549c5b6e1bedafd13fff6e4f834fd8d85534189ca35186a6ce07
MD5 b75c426a0d8e2c7d2feec8890e934fcb
BLAKE2b-256 5b8146ae5c3d425592d325c544ede6ff75c8c42e8d3e62ad28a53116023746c1

See more details on using hashes here.

File details

Details for the file pyxetabase-3.1.0.dev15-py3-none-any.whl.

File metadata

File hashes

Hashes for pyxetabase-3.1.0.dev15-py3-none-any.whl
Algorithm Hash digest
SHA256 db7ec7eaa66fc54a8f6b392f37089a3cbb07284fcd33462c5ae77f48e12a4de2
MD5 c50d505aeec70988bd2c5d56d98eb8a9
BLAKE2b-256 7f995e3078c9684ab594bbd01e37e30c4772daebd518422e2c7ed28b3de6ece9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page