The Java client provides an API to the whole OpenCGA RESTful layer. We will here only focus on those methods which are of most interest for HGVA users. In order to understand how to create queries using these methods, it would be interesting to have a look at the Datasets and Studies section before.

Getting the Java client code

As previously said, the Java client code is distributed together with the rest of the OpenCGA code.

The OpenCGA code can be cloned in your machine by executing in your terminal:

Initializing the Java client

The OpenCGAClient constructor requires a ClientConfiguration object to be passed as a parameter. This ClientConfiguration object will contain basic connection details, namely the URL that points to HGVA web services. The best way to obtain a ClientConfiguration object is to create a .yml configuration file that will later be passed to the load static method of the ClientConfiguration class to generate a new ClientConfiguration object. A client-configuration.yml template is provided within the OpenCGA code. If you have cloned the OpenCGA code, you will find the client-configuration.yml file at:

The OpenCGAClient will, in turn, be able to generate different data client types that will provide methods for accessing the different data types. The most relevant data client types for HGVA users will be the VariantClient, ProjectClient, StudyClient, CohortClient and SampleClient, that you can create by simply doing:

The params parameter can be provided as a QueryOptions object, which works as a Map by providing a put method that enables to add pairs (filter, value) that form the actual query. Available filters and possible values for them are those described at the Swagger specification for the corresponding web service. For example, get TTN variants from the Genome of the Netherlands study, which is framed within the reference_grch37 project. We will also limit the number of returned results to 3:

projectId: String containing the project alias or project name. You can get available project alias at the Datasets and Studies section.

options: QueryOptions object which will contain the pairs (filter, value) that form the query. QueryOptions objects work as a Map object, by providing a put method that enables to add the (filter, value) pairs. Available filters and possible values for them are those described at the Swagger specification for the corresponding web service.

For example, getting all studies and their metadata for the cancer_grch37 project:

Getting information about studies

Get all available studies and their metadata.Please note, of special interestwill be here the field alias which contains the study identifier to be used as an input whenever a study must be passed as a parameter. You can use the search method of the StudyClient class:

query: Query object which will contain the pairs (filter, value) that form the query. Query objects work as a Map object, by providing a put method that enables to add the (filter, value) pairs. Available filters and possible values for them are those described at the Swagger specification for the corresponding web service.

studyId: String containing the study alias or study name. You can get available study aliases/names by using the method above.

options: QueryOptions object which will contain the pairs (filter, value) that form the query. QueryOptions objects work as a Map object, by providing a put method that enables to add the (filter, value) pairs. Available filters and possible values for them are those described at the Swagger specification for the corresponding web service.

For example, getting summary data for study 1kG_phase3 which is framed within project reference_grch37:

studyId: String containing the study alias or study name. You can get available study aliases/names by using the method above.

options: QueryOptions object which will contain the pairs (filter, value) that form the query. QueryOptions objects work as a Map object, by providing a put method that enables to add the (filter, value) pairs. Available filters and possible values for them are those described at the Swagger specification for the corresponding web service.

For example, getting all samples metadata for study 1kG_phase3 which is framed within project reference_grch37. Please, note that not all studies contain samples data, e.g. GONL, ExAC, among others, only provide variant lists and aggregated frequencies, i.e. no sample genotypes.

options: QueryOptions object which will contain the pairs (filter, value) that form the query. QueryOptions objects work as a Map object, by providing a put method that enables to add the (filter, value) pairs. Available filters and possible values for them are those described at the Swagger specification for the corresponding web service.

For example, get all samples metadata for cohort GBR from study 1kG_phase3 which is framed within project reference_grch37: