Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 27 Next »

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 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, have a look at Datasets and Studies in order to understand 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 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 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: 

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

Configuration File - JSON format
{
    "version": "v1",
    "rest": {
        "hosts": [
            "bioinfodev.hpc.cam.ac.uk/hgva-1.0"
        ]
    }
}


Configuration File - YAML format
---
version: v1
rest:
  hosts:
  - bioinfodev.hpc.cam.ac.uk/hgva-1.0


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

Loading the configuration
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 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.js 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. 

Creating Javascript client for HGVA

Javascript client of OpenCGA expects an Opencga Client configuration object to create. The configuration object is of the following structure

OpenCGA Client Configuration
class OpenCGAClientConfig {

    constructor(host = "bioinfodev.hpc.cam.ac.uk/hgva-1.0", version = "v1", useCookies = true, cookiePrefix = "hgva") {
       
    }
}
OpenCGAClientConfig = new OpenCGAClientConfig(this.config.opencga.host, this.config.opencga.version, true, "iva");


this.opencgaClientConfig = new OpenCGAClientConfig(this.config.opencga.host, this.config.opencga.version, true, "iva");
this.opencgaClient = new OpenCGAClient(this.opencgaClientConfig);


Table of Contents:

  • No labels