From 03f2c23bf2f4b2c6d008695ded02b57cd3a8096b Mon Sep 17 00:00:00 2001 From: Colin Diesh Date: Tue, 28 Jan 2025 12:15:54 -0500 Subject: [PATCH] Add more track metadata to UCSC assembly hub loading (#4798) --- packages/core/util/tracks.ts | 2 +- .../src/ui/AboutDialogContents.tsx | 17 +++++-- .../src/UCSCTrackHub/doConnect.ts | 17 +++++-- .../src/UCSCTrackHub/ucscTrackHub.ts | 50 +++++++++++-------- .../data-management/src/UCSCTrackHub/util.ts | 4 ++ 5 files changed, 61 insertions(+), 29 deletions(-) diff --git a/packages/core/util/tracks.ts b/packages/core/util/tracks.ts index 5e733e7f34..5a4830e4d7 100644 --- a/packages/core/util/tracks.ts +++ b/packages/core/util/tracks.ts @@ -247,7 +247,7 @@ export function generateUnsupportedTrackConf( export function generateUnknownTrackConf( trackName: string, trackUrl: string, - categories: string[] | undefined, + categories?: string[], ) { const conf = { type: 'FeatureTrack', diff --git a/packages/product-core/src/ui/AboutDialogContents.tsx b/packages/product-core/src/ui/AboutDialogContents.tsx index f0af5a5245..f9dc57cb85 100644 --- a/packages/product-core/src/ui/AboutDialogContents.tsx +++ b/packages/product-core/src/ui/AboutDialogContents.tsx @@ -61,7 +61,9 @@ const AboutDialogContents = observer(function ({ }, }, { session, config }, - ) as Record + ) as { + config: { metadata?: Record; [key: string]: unknown } + } const ExtraPanel = pluginManager.evaluateExtensionPoint( 'Core-extraAboutPanel', @@ -99,11 +101,20 @@ const AboutDialogContents = observer(function ({ ) : null} + {confPostExt.config.metadata ? ( + + + + ) : null} {ExtraPanel ? ( diff --git a/plugins/data-management/src/UCSCTrackHub/doConnect.ts b/plugins/data-management/src/UCSCTrackHub/doConnect.ts index ecd4cda4c7..d0d6760b1f 100644 --- a/plugins/data-management/src/UCSCTrackHub/doConnect.ts +++ b/plugins/data-management/src/UCSCTrackHub/doConnect.ts @@ -5,15 +5,11 @@ import { openLocation } from '@jbrowse/core/util/io' import { nanoid } from '@jbrowse/core/util/nanoid' import { generateTracks } from './ucscTrackHub' -import { fetchGenomesFile, fetchTrackDbFile } from './util' +import { fetchGenomesFile, fetchTrackDbFile, resolve } from './util' import type { AnyConfigurationModel } from '@jbrowse/core/configuration' import type { FileLocation } from '@jbrowse/core/util' -function resolve(uri: string, baseUri: string) { - return new URL(uri, baseUri).href -} - export async function doConnect(self: { configuration: AnyConfigurationModel addTrackConfs: (arg: Record[]) => void @@ -38,6 +34,15 @@ export async function doConnect(self: { name: genomeName, sequence: { type: 'ReferenceSequenceTrack', + metadata: { + // eslint-disable-next-line @typescript-eslint/no-misused-spread + ...genome, + ...(genome.data.htmlPath + ? { + htmlPath: `${genome.data.htmlPath}`, + } + : {}), + }, trackId: `${genomeName}-${nanoid()}`, adapter: { type: 'TwoBitAdapter', @@ -58,6 +63,7 @@ export async function doConnect(self: { trackDbLoc: hubFileLocation, assemblyName: genomeName, sequenceAdapter, + baseUrl: hubUri, }) self.addTrackConfs(tracksNew) } else { @@ -113,6 +119,7 @@ export async function doConnect(self: { trackDbLoc: loc, assemblyName: genomeName, sequenceAdapter, + baseUrl: hubUri, }) self.addTrackConfs(tracks) map[genomeName] = tracks.length diff --git a/plugins/data-management/src/UCSCTrackHub/ucscTrackHub.ts b/plugins/data-management/src/UCSCTrackHub/ucscTrackHub.ts index 247bfd0418..7330c5a066 100644 --- a/plugins/data-management/src/UCSCTrackHub/ucscTrackHub.ts +++ b/plugins/data-management/src/UCSCTrackHub/ucscTrackHub.ts @@ -1,7 +1,7 @@ import { isUriLocation, notEmpty, objectHash } from '@jbrowse/core/util' import { generateUnknownTrackConf } from '@jbrowse/core/util/tracks' -import { makeLoc2, makeLoc, makeLocAlt } from './util' +import { makeLoc2, makeLoc, makeLocAlt, resolve } from './util' import type { RaStanza, TrackDbFile } from '@gmod/ucsc-hub' import type { FileLocation } from '@jbrowse/core/util' @@ -11,11 +11,13 @@ export function generateTracks({ trackDbLoc, assemblyName, sequenceAdapter, + baseUrl, }: { trackDb: TrackDbFile trackDbLoc: FileLocation assemblyName: string sequenceAdapter: any + baseUrl: string }) { const parentTrackKeys = new Set([ 'superTrack', @@ -38,16 +40,32 @@ export function generateTracks({ parentTracks.push(trackDb.data[currentTrackName]) } } while (currentTrackName) - return makeTrackConfig({ - track, - trackDbLoc, - trackDb, - sequenceAdapter, - categories: parentTracks - .reverse() - .map(p => p?.data.shortLabel) - .filter((f): f is string => !!f), - }) + parentTracks.reverse() + + return { + metadata: { + ucscConfig: { + ...track.data, + ...(track.data.html + ? { + html: `${track.data.html}`, + } + : {}), + }, + }, + category: [ + track.data.group, + ...parentTracks + .map(p => p?.data.group) + .filter((f): f is string => !!f), + ].filter(f => !!f), + ...makeTrackConfig({ + track, + trackDbLoc, + trackDb, + sequenceAdapter, + }), + } } }) .filter(notEmpty) @@ -60,13 +78,11 @@ export function generateTracks({ function makeTrackConfig({ track, - categories, trackDbLoc, trackDb, sequenceAdapter, }: { track: RaStanza - categories: string[] trackDbLoc: FileLocation trackDb: TrackDbFile sequenceAdapter: any @@ -94,7 +110,6 @@ function makeTrackConfig({ type: 'AlignmentsTrack', name, description: data.longLabel, - category: categories, adapter: { type: 'BamAdapter', bamLocation: bigDataLocation, @@ -110,7 +125,6 @@ function makeTrackConfig({ type: 'AlignmentsTrack', name, description: data.longLabel, - category: categories, adapter: { type: 'CramAdapter', cramLocation: bigDataLocation, @@ -125,7 +139,6 @@ function makeTrackConfig({ type: 'QuantitativeTrack', name, description: data.longLabel, - category: categories, adapter: { type: 'BigWigAdapter', bigWigLocation: bigDataLocation, @@ -136,7 +149,6 @@ function makeTrackConfig({ type: 'FeatureTrack', name, description: data.longLabel, - category: categories, adapter: { type: 'BigBedAdapter', bigBedLocation: bigDataLocation, @@ -147,7 +159,6 @@ function makeTrackConfig({ type: 'VariantTrack', name, description: data.longLabel, - category: categories, adapter: { type: 'VcfTabixAdapter', vcfGzLocation: bigDataLocation, @@ -163,7 +174,6 @@ function makeTrackConfig({ type: 'HicTrack', name, description: data.longLabel, - category: categories, adapter: { type: 'HicAdapter', hicLocation: bigDataLocation, @@ -184,7 +194,7 @@ function makeTrackConfig({ // case 'bedRnaElements': // case 'broadPeak': // case 'coloredExon': - return generateUnknownTrackConf(name, baseTrackType, categories) + return generateUnknownTrackConf(name, baseTrackType) } } diff --git a/plugins/data-management/src/UCSCTrackHub/util.ts b/plugins/data-management/src/UCSCTrackHub/util.ts index a4d7b4d4e7..0e96336b51 100644 --- a/plugins/data-management/src/UCSCTrackHub/util.ts +++ b/plugins/data-management/src/UCSCTrackHub/util.ts @@ -38,3 +38,7 @@ export function makeLoc2(first: string, alt?: string) { locationType: 'UriLocation', } } + +export function resolve(uri: string, baseUri: string) { + return new URL(uri, baseUri).href +}