From 2cac0d40bf1c71e80cfd8950450ea1d2af4d1411 Mon Sep 17 00:00:00 2001 From: Sehi L'Yi Date: Thu, 7 Jul 2022 13:01:37 -0400 Subject: [PATCH 1/2] chore: add entry point for using plugin data fetchers --- schema/gosling.schema.json | 27 +++++++++++++++++++++++++++ src/core/gosling-to-higlass.ts | 33 +++++++++++++++------------------ src/core/gosling.schema.ts | 15 ++++++++++++++- 3 files changed, 56 insertions(+), 19 deletions(-) diff --git a/schema/gosling.schema.json b/schema/gosling.schema.json index 017e24572..9e8303589 100644 --- a/schema/gosling.schema.json +++ b/schema/gosling.schema.json @@ -534,6 +534,9 @@ }, { "$ref": "#/definitions/VCFData" + }, + { + "$ref": "#/definitions/PluginData" } ] }, @@ -5562,6 +5565,30 @@ }, "type": "object" }, + "PluginData": { + "additionalProperties": false, + "description": "A data spec to use plugin data fetcher that are defined externally", + "properties": { + "name": { + "description": "The name of the plugin data that should match the `type` of a plugin data fetcher", + "type": "string" + }, + "options": { + "description": "All custom options used in the plugin data fetcher", + "type": "object" + }, + "type": { + "const": "experimentalPlugin", + "type": "string" + } + }, + "required": [ + "type", + "name", + "options" + ], + "type": "object" + }, "PredefinedColors": { "enum": [ "viridis", diff --git a/src/core/gosling-to-higlass.ts b/src/core/gosling-to-higlass.ts index 0711a6c0c..5d9e2fcd4 100644 --- a/src/core/gosling-to-higlass.ts +++ b/src/core/gosling-to-higlass.ts @@ -109,24 +109,21 @@ export function goslingToHiGlass( } }; - if ( - firstResolvedSpec.data && - IsDataDeep(firstResolvedSpec.data) && - (firstResolvedSpec.data.type === 'csv' || - firstResolvedSpec.data.type === 'json' || - firstResolvedSpec.data.type === 'bigwig' || - firstResolvedSpec.data.type === 'bam' || - firstResolvedSpec.data.type === 'vcf') - ) { - // use gosling's custom data fetchers - hgTrack.data = { - ...firstResolvedSpec.data, - // Additionally, add assembly, otherwise, a default genome build is used - assembly - // TODO: should look all sub tracks' `dataTransform` and apply OR operation. - // Add a data transformation spec so that the fetcher can properly sample datasets - // filter: (firstResolvedSpec as any).dataTransform?.filter((f: DataTransform) => f.type === 'filter') - }; + if (firstResolvedSpec.data && IsDataDeep(firstResolvedSpec.data)) { + const dataType = firstResolvedSpec.data.type; + if ( + dataType === 'csv' || + dataType === 'json' || + dataType === 'bigwig' || + dataType === 'bam' || + dataType === 'vcf' + ) { + // This means, we are using custom data fetchers defined internally + hgTrack.data = { ...firstResolvedSpec.data, assembly }; + } else if (dataType === 'experimentalPlugin') { + // This means, we are using external data fetchers that the user implemented + hgTrack.data = { ...firstResolvedSpec.data.options, type: firstResolvedSpec.data.name, assembly }; + } } // We use higlass 'heatmap' track instead of 'gosling-track' for rendering performance. diff --git a/src/core/gosling.schema.ts b/src/core/gosling.schema.ts index d140d3380..ea20235b8 100644 --- a/src/core/gosling.schema.ts +++ b/src/core/gosling.schema.ts @@ -759,7 +759,8 @@ export type DataDeep = | VectorData | MatrixData | BAMData - | VCFData; + | VCFData + | PluginData; /** Values in the form of JSON. */ export interface Datum { @@ -1058,6 +1059,18 @@ export interface MatrixData { binSize?: number; } +/** A data spec to use plugin data fetcher that are defined externally */ +export interface PluginData { + // TODO (7-Jul-2022): change to 'plugin' for official support + type: 'experimentalPlugin'; + + /** The name of the plugin data that should match the `type` of a plugin data fetcher */ + name: string; + + /** All custom options used in the plugin data fetcher */ + options: Record; +} + /* ----------------------------- DATA TRANSFORM ----------------------------- */ export type DataTransform = From 41ec318773ae003c402f5c53bb1e3df3f2388674 Mon Sep 17 00:00:00 2001 From: Sehi L'Yi Date: Thu, 7 Jul 2022 14:50:36 -0400 Subject: [PATCH 2/2] chore: comment statements --- src/core/gosling-to-higlass.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/gosling-to-higlass.ts b/src/core/gosling-to-higlass.ts index 5d9e2fcd4..ed5dc5e2b 100644 --- a/src/core/gosling-to-higlass.ts +++ b/src/core/gosling-to-higlass.ts @@ -118,10 +118,10 @@ export function goslingToHiGlass( dataType === 'bam' || dataType === 'vcf' ) { - // This means, we are using custom data fetchers defined internally + // This means we use data fetchers that are implemented in Gosling hgTrack.data = { ...firstResolvedSpec.data, assembly }; } else if (dataType === 'experimentalPlugin') { - // This means, we are using external data fetchers that the user implemented + // This means we use an external data fetcher that a user implemented hgTrack.data = { ...firstResolvedSpec.data.options, type: firstResolvedSpec.data.name, assembly }; } }