Skip to content

Commit

Permalink
Generate categoris using group
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jan 28, 2025
1 parent 7f9afa3 commit 2b2e35b
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 29 deletions.
2 changes: 1 addition & 1 deletion packages/core/util/tracks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export function generateUnsupportedTrackConf(
export function generateUnknownTrackConf(
trackName: string,
trackUrl: string,
categories: string[] | undefined,
categories?: string[],
) {
const conf = {
type: 'FeatureTrack',
Expand Down
17 changes: 14 additions & 3 deletions packages/product-core/src/ui/AboutDialogContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ const AboutDialogContents = observer(function ({
},
},
{ session, config },
) as Record<string, unknown>
) as {
config: { metadata?: Record<string, unknown>; [key: string]: unknown }
}

const ExtraPanel = pluginManager.evaluateExtensionPoint(
'Core-extraAboutPanel',
Expand Down Expand Up @@ -99,11 +101,20 @@ const AboutDialogContents = observer(function ({
</span>
) : null}
<Attributes
attributes={confPostExt}
omit={['displays', 'baseUri', 'refNames', 'formatAbout']}
attributes={confPostExt.config}
omit={['displays', 'baseUri', 'refNames', 'formatAbout', 'metadata']}
hideUris={hideUris}
/>
</BaseCard>
{confPostExt.config.metadata ? (
<BaseCard title="Metadata">
<Attributes
attributes={confPostExt.config.metadata}
omit={['displays', 'baseUri', 'refNames', 'formatAbout']}
hideUris={hideUris}
/>
</BaseCard>
) : null}
{ExtraPanel ? (
<BaseCard title={ExtraPanel.name}>
<ExtraPanel.Component config={config} />
Expand Down
17 changes: 12 additions & 5 deletions plugins/data-management/src/UCSCTrackHub/doConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown>[]) => void
Expand All @@ -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: `<a href="${resolve(genome.data.htmlPath, hubUri)}">${genome.data.htmlPath}</a>`,
}
: {}),
},
trackId: `${genomeName}-${nanoid()}`,
adapter: {
type: 'TwoBitAdapter',
Expand All @@ -58,6 +63,7 @@ export async function doConnect(self: {
trackDbLoc: hubFileLocation,
assemblyName: genomeName,
sequenceAdapter,
baseUrl: hubUri,
})
self.addTrackConfs(tracksNew)
} else {
Expand Down Expand Up @@ -113,6 +119,7 @@ export async function doConnect(self: {
trackDbLoc: loc,
assemblyName: genomeName,
sequenceAdapter,
baseUrl: hubUri,
})
self.addTrackConfs(tracks)
map[genomeName] = tracks.length
Expand Down
50 changes: 30 additions & 20 deletions plugins/data-management/src/UCSCTrackHub/ucscTrackHub.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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',
Expand All @@ -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: `<a href="${resolve(track.data.html, baseUrl)}">${track.data.html}</a>`,
}
: {}),
},
},
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)
Expand All @@ -60,13 +78,11 @@ export function generateTracks({

function makeTrackConfig({
track,
categories,
trackDbLoc,
trackDb,
sequenceAdapter,
}: {
track: RaStanza
categories: string[]
trackDbLoc: FileLocation
trackDb: TrackDbFile
sequenceAdapter: any
Expand Down Expand Up @@ -94,7 +110,6 @@ function makeTrackConfig({
type: 'AlignmentsTrack',
name,
description: data.longLabel,
category: categories,
adapter: {
type: 'BamAdapter',
bamLocation: bigDataLocation,
Expand All @@ -110,7 +125,6 @@ function makeTrackConfig({
type: 'AlignmentsTrack',
name,
description: data.longLabel,
category: categories,
adapter: {
type: 'CramAdapter',
cramLocation: bigDataLocation,
Expand All @@ -125,7 +139,6 @@ function makeTrackConfig({
type: 'QuantitativeTrack',
name,
description: data.longLabel,
category: categories,
adapter: {
type: 'BigWigAdapter',
bigWigLocation: bigDataLocation,
Expand All @@ -136,7 +149,6 @@ function makeTrackConfig({
type: 'FeatureTrack',
name,
description: data.longLabel,
category: categories,
adapter: {
type: 'BigBedAdapter',
bigBedLocation: bigDataLocation,
Expand All @@ -147,7 +159,6 @@ function makeTrackConfig({
type: 'VariantTrack',
name,
description: data.longLabel,
category: categories,
adapter: {
type: 'VcfTabixAdapter',
vcfGzLocation: bigDataLocation,
Expand All @@ -163,7 +174,6 @@ function makeTrackConfig({
type: 'HicTrack',
name,
description: data.longLabel,
category: categories,
adapter: {
type: 'HicAdapter',
hicLocation: bigDataLocation,
Expand All @@ -184,7 +194,7 @@ function makeTrackConfig({
// case 'bedRnaElements':
// case 'broadPeak':
// case 'coloredExon':
return generateUnknownTrackConf(name, baseTrackType, categories)
return generateUnknownTrackConf(name, baseTrackType)
}
}

Expand Down
4 changes: 4 additions & 0 deletions plugins/data-management/src/UCSCTrackHub/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 2b2e35b

Please sign in to comment.