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 4 Next »

Overview


Library design

The OpenCGA client file can be found in https://github.com/opencb/jsorolla/blob/develop/src/core/clients/opencga-client.js. The file can be divided into two main parts, the configuration and the actual client. The OpenCGAClientConfig configuration class is a really small class containing some fields to know mainly, where the REST host can be found. Additionally, the developer can choose whether to let the OpenCGA client to use cookies to store the main credentials allowing to easily refresh the page without loosing the authentication credentials and set a cookie prefix. 

// Initialise the OpenCGA config
let myConfig = new OpenCGAClientConfig("localhost:8080/opencga");


The second part of the file is composed by the actual OpenCGA client. The same approach followed to implement the Java client was followed here. We have implemented an OpenCGAClient class that acts as a resource factory. There exist one class for each available resource (user, project, study) that can be invoked through the OpenCGAClient instance as shown in the example.

// Initialise the OpenCGAClient
let openCGAClient = new OpenCGAClient(myConfig);


// Get an instance of all the possible resources
let userClient = openCGAClient.users();
let projectClient = openCGAClient.projects();
let studyClient = openCGAClient.studies();
let fileClient = openCGAClient.files();
let jobClient = openCGAClient.jobs();
let sampleClient = openCGAClient.samples();
let individualClient = openCGAClient.individuals();
let familyClient = openCGAClient.families();
let cohortClient = openCGAClient.cohorts();
let clinicalAnalysisClient = openCGAClient.clinical();
let variableSetClient = openCGAClient.variables();
let alignmentClient = openCGAClient.alignments();
let variantClient = openCGAClient.variants();


How to use the Javascript client

https://www.npmjs.com/~opencb

In order to use the Javascript client, developers will only need to include two files which can be found in https://github.com/opencb/jsorolla/blob/develop/src/core/clients

<script type="text/javascript" src="rest-client.js"></script>
<script type="text/javascript" src="opencga-client.js"></script>

Using cookies?

If the developer chooses to use cookies, 

Table of Contents:


  • No labels