Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

OpenCGA RESTful Web Services

HGVA is powered by the Open Computational Genomic Analysis (OpenCGA) project. OpenCGA implements an extensive API that enables numerous operations over metadata, samples and genomic data. The whole API specification can be accessed at:

http://bioinfodev.hpc.cam.ac.uk/hgva-1.0/webservices

A description on of the API and URLs design can be found at the OpenCGA RESTful Web Services documentation.

The tutorial Using RESTful Web Services URL shows practical examples on how to directly query the RESTful API. It focuses on those end points of the API which are of more interest for HGVA users, giving examples of their use and pin pointing certain peculiarities of the parameters for HGVA. Data is hierarchically organised in Projects and Studies. Please, in order to understand the API behaviour, have a look at Datasets and Studies in order to understand first how data is organized: Projects, Studies and Cohorts . For details on the query parameters, please refer to the Swagger documentation linked above.

Clients

Likewise, a number of client libraries are provided which make intensive use of the OpenCGA RESTful API. They provide fast programmatic access for genome-scale data analysis, therefore discouraging massive downloads of data to local computers. Currently supported languages include Python, R, Java and JavaScript. Again, all of them provide an exhaustive API for accessing the whole OpenCGA API. Please, find below details on how to download, install and , configure the libraries . Also, find as well as practical examples on how to use the methods which are of particular interest for HGVA users within the corresponding Tutorials.

Python client pyCGA

pyCGA is the Python client library for OpenCGA RESTful Web Services, all the web services are accessible through this client, and it offers a quick way to query OpenCGA projects programmatically from custom scripts

Installing pyCGA

You can easily install pyCGA using pip tool: 

Code Block
languagebash
themeMidnight
titleHow To Install pyCGA
cd 'path/to/pyCGA folder/'
[sudo] pip install .  [ --upgrade ]

Configuring pyCGA for HGVA

Configuration parameters can be passed as a JSON file, YAML file or a Python Dictionary:

Code Block
languagetext
themeConfluence
titleConfiguration File - JSON format
{ "version": "v1", "rest": { "hosts": [ "bioinfodev

.

hpc.cam.ac.uk/hgva-1.0" ] } }

Code Block
languagetext
themeConfluence
titleConfiguration File - YAML format
---
version: v1
rest:
  hosts:
  - bioinfodev.hpc.cam.ac.uk/hgva-1.0

Code Block
languagepy
themeRDark
titleConfiguration Dictionary Python
configuration = {
    'version': 'v1',
    'rest': {
        'hosts': [
            'bioinfodev.hpc.cam.ac.uk/hgva-1.0'
        ]
    }
}

Load the configuration will be the first step, to use the python client. We will use the ConfigClient class, passing the name of the path of the configuration file or the dictionary with the configuration. After that the instance created will be passed to the Client.

Code Block
languagepy
themeRDark
titleLoading the configuration
linenumberstrue
from pyCGA.opencgaconfig import ConfigClient
from pyCGA.opencgarestclients import Studies, AnalysisVariant, Projects, Samples, Cohorts



# configuration = '/path/to/configuration_file.json'
# configuration = '/path/to/configuration_file.yaml'
configuration = {
    'version': 'v1',
    'rest': {
        'hosts': [
            '10.5.5.4:8080/opencga-test'
        ]
    }
}

# Initialise configuration
conf = ConfigClient(configuration)


# conf instance should be passed to the clients
study_client = Studies(conf)

General usage

After the above described steps, the library will be ready for starting calling its methods. Please, refer to the tutorial Using the Python REST client in order to get detailed instructions for installing and configuring it, as well as a list of the methods which are of more interest for HGVA users and practical examples on how to use them.

JavaScript client

opencga-client.jsOpencgaClient is the Javascript client library for OpenCGA RESTful Web Services, all the web services are accessible through this client, and it offers a quick way to query OpenCGA projects through web interface.



Table of Contents:

Table of Contents
indent20px