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..ed5dc5e2b 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 use data fetchers that are implemented in Gosling + hgTrack.data = { ...firstResolvedSpec.data, assembly }; + } else if (dataType === 'experimentalPlugin') { + // This means we use an external data fetcher that a 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 =