OpenCGA
OverviewInstallationUsing OpenCGA
v2.1
v2.1
  • Home
  • Overview
    • Features
    • Architecture Diagram
    • Security
    • Metadata and Clinical Data
    • Data Models
      • Sample
      • Individual
    • Alignment and Coverage
    • Variant Query and Analysis
    • Clinical Data Analysis
    • Running Analysis
    • Scalability and Performance
    • Sizing OpenCGA
  • OpenCGA Architecture
    • Catalog
    • Alignment and Coverage
    • Variant Storage Engine
      • Variant Data Model
    • Clinical Analysis
    • Analysis Framework
  • Data Models
    • User
    • Project
    • Study
    • File
    • Sample
    • Individual
    • Family
    • Cohort
    • Job
    • Clinical Analysis
  • Case Studies
    • Genomics England Research
    • Microsoft Azure
  • User Manual
    • Installation
      • Kubernetes Cluster
        • Azure
        • Configuration
      • On-Premise HPC Cluster
        • Server Configuration
        • Getting OpenCGA
        • Choosing Variant Storage Engine
        • Configuration
      • Running Docker
    • Login
    • Using OpenCGA
      • REST Web Service API
      • IVA Web App
      • Client Libraries
        • pyopencga - Python Library
        • opencgaR - R library
        • Java
        • JavaScript
      • Command Line
        • Configuration
      • Public Demo
    • Managing Data
      • Sharing and Permissions
        • Users and Groups
        • Study ACLs
      • Create Projects and Studies
      • Load VCF Files to a Study
      • Working with Files
      • Population of Metadata
        • Adding Custom Metadata
        • Data Versioning
    • Alignment Engine
      • BAM Index
      • Alignment Read Query
      • Working with Coverage
      • Alignment Analysis
    • Variant Storage Engine
      • Variant Query
      • Variant Aggregation Stats
      • Variant Analysis
    • Clinical Genomics
      • Clinical Interpretation
      • Clinical Analysis
    • Using JupyterLab
    • Administrator
      • User Management
      • Templates / Manifest
  • About
    • Roadmap
    • Release Notes
    • Community
Powered by GitBook
On this page

Was this helpful?

  1. User Manual
  2. Using OpenCGA
  3. Client Libraries

JavaScript

PreviousJavaNextCommand Line

Last updated 3 years ago

Was this helpful?

The OpenCGA JavaScript Client is provided as part of . Some examples of basic usage can be found in directory.

Example:

Fetching the first 10 variants of the Study of interest using a token

import {OpenCGAClient} from "./opencga-client.js";

const HOST = "";      // add your host
const STUDY = "";     // add your study of interest
const TOKEN = "";     // add a valid token

const client = new OpenCGAClient({
    host: HOST,
    version: "v2",
    cookies: {active: false},
    token: TOKEN
});


(async () => {
    try {
        const restResponse = await client.variants().query({study: STUDY, limit:10});
        console.table(restResponse.getResults());
    } catch (response) {
        if (response instanceof RestResponse) {
            console.error(response.getEvents())
        } else {
            console.error(response)
        }
    }
})();

Fetching the first 10 variants of the Study of interest using OpenCGA credentials.

In this case an Opencga Session is created. The Opencga Study being used is the default one for the user.

import {OpenCGAClient} from "./opencga-client.js";

const HOST = "";      // add your host
const STUDY = "";     // add your study of interest
const USERNAME = "";     // add your username
const PASSWORD = "";     // add your username

const client = new OpenCGAClient({
    host: HOST,
    version: "v2",
    cookies: {active: false}
});
(async () => {
    try {
        await client.login(USERNAME, PASSWORD)
        const session = await client.createSession();
        const restResponse = await session.opencgaClient.variants().query({limit:10, study: session.study.fqn});
        console.table(restResponse.getResults());

    } catch (e) {
        console.error(e)
    }
})();
JSorolla
examples