Skip to content

Commit

Permalink
Edits for Track Hubs
Browse files Browse the repository at this point in the history
  • Loading branch information
turner committed Oct 24, 2023
1 parent cfea764 commit d72adaf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
37 changes: 33 additions & 4 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ import {
GenomeFileLoad,
googleDriveButtonImageBase64,
googleDriveDropdownItem,
updateTrackMenus
getPathsWithTrackRegistryFile,
updateTrackMenusWithTrackConfigurations
} from '../node_modules/igv-widgets/dist/igv-widgets.js'
import Globals from "./globals.js"
import {createGenomeWidgets, initializeGenomeWidgets, loadGenome} from './genomeWidgets.js'
Expand All @@ -59,7 +60,7 @@ async function main(container, config) {
$('#igv-app-version').text(`IGV-Web app version ${version()}`)
$('#igv-igvjs-version').text(`igv.js version ${igv.version()}`)

const doEnableGoogle = undefined === config.clientId ? false : true
const doEnableGoogle = undefined !== config.clientId

if (doEnableGoogle) {

Expand Down Expand Up @@ -110,7 +111,20 @@ async function main(container, config) {

if (browser) {
Globals.browser = browser
await initializationHelper(browser, container, config)

const paramHash = parseURLParams(window.location.href)
let hub
let trackConfigs
if (paramHash.hubURL) {
hub = await igv.Hub.loadHub(paramHash.hubURL)
trackConfigs = hub.getTrackConfigurations()
}

if (trackConfigs) {
console.log(trackConfigs)
}

await initializationHelper(browser, container, trackConfigs ? Object.assign(config, { trackConfigs }) : config)
}
}

Expand Down Expand Up @@ -244,8 +258,12 @@ async function initializationHelper(browser, container, options) {

currentGenomeId = genomeID

await updateTrackMenus(genomeID, undefined, options.trackRegistryFile, $('#igv-app-track-dropdown-menu'))
let trackConfigurations = await getPathsWithTrackRegistryFile(genomeID, options.trackRegistryFile)

if (undefined === trackConfigurations && options.trackConfigs) {
trackConfigurations = options.trackConfigs
}
await updateTrackMenusWithTrackConfigurations(genomeID, undefined, trackConfigurations, $('#igv-app-track-dropdown-menu'))
}
}

Expand Down Expand Up @@ -307,6 +325,17 @@ async function initializationHelper(browser, container, options) {
EventBus.globalBus.post({type: "DidChangeGenome", data: browser.genome.id})
}

function parseURLParams(url) {
const searchParams = new URL(url).searchParams;
const params = {};

for (const [key, value] of searchParams) {
params[key] = value;
}

return params;
}

function configureGoogleSignInButton() {

if (true === googleEnabled) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"devDependencies": {
"fs-extra": "^8.1.0",
"igv": "github:igvteam/igv.js",
"igv-widgets": "github:igvteam/igv-widgets",
"igv-widgets": "github:igvteam/igv-widgets#dat_track_hub",
"google-utils": "github:igvteam/google-utils#v1.0.2",
"rollup": "^2.28.1",
"rollup-plugin-copy": "^3.3.0",
Expand Down

0 comments on commit d72adaf

Please sign in to comment.