Skip to main content

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:

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

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

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

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

Metadata

Release files for pyopencga 6.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyopencga 6.0.0
File Size Uploaded Provenance Actions
pyopencga-6.0.0.tar.gz 85.6 kB Without provenance Details for pyopencga-6.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyopencga 6.0.0
File Interpreter ABI Platform Actions
pyopencga-6.0.0-py3-none-any.whl Python 3 none any Details for pyopencga-6.0.0-py3-none-any.whl

Total release size: 195.9 kB

Release files / pyopencga-6.0.0.tar.gz

Download URL pyopencga-6.0.0.tar.gz
Size 85.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4e909e1b958e7852e65521f86f059ebd7092827b5b67905d68f05bf93d693cec
BLAKE2b-256 checksum
How to use checksums
4b217dbf6ccc09a46ec2022302c41dbd1817531098378bf1de488bb799ea2a1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / pyopencga-6.0.0-py3-none-any.whl

Download URL pyopencga-6.0.0-py3-none-any.whl
Size 110.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ffbf38718900ad0c7044d943079e5edb7958b3c3e0c57138ac3a5b87ad31e8d
BLAKE2b-256 checksum
How to use checksums
6e086efd7df4443b11b9a516e0bc26bf80d5ae03d9f1bb5ecb36ca2c0035a1bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for pyopencga 6.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

6.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page