Skip to content

Commit

Permalink
Track Hubs - Now using genome.getTrackConfigurations()
Browse files Browse the repository at this point in the history
  • Loading branch information
turner committed Oct 27, 2023
1 parent 49d742e commit 5799be4
Showing 1 changed file with 19 additions and 36 deletions.
55 changes: 19 additions & 36 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
createTrackWidgetsWithTrackRegistry,
dropboxButtonImageBase64,
dropboxDropdownItem,
EventBus,
GenomeFileLoad,
googleDriveButtonImageBase64,
googleDriveDropdownItem,
Expand Down Expand Up @@ -111,16 +110,7 @@ async function main(container, config) {

if (browser) {
Globals.browser = browser

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

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

Expand Down Expand Up @@ -235,18 +225,14 @@ async function initializationHelper(browser, container, options) {
}

const sessionLoader = async config => {

try {
await browser.loadSession(config)
} catch (e) {
console.error(e)
AlertSingleton.present(e)
}

if (false === isFile(config.url) && config.url.endsWith('hub.txt')) {
const hub = await igv.Hub.loadHub(config.url)
await updateTrackMenusWithTrackHub(hub)
}


}

createSessionWidgets($igvMain,
Expand All @@ -273,23 +259,6 @@ async function initializationHelper(browser, container, options) {

createAppBookmarkHandler($('#igv-app-bookmark-button'))

const genomeChangeListener = async event => {

const {data: genomeID} = event

if (currentGenomeId !== genomeID) {

currentGenomeId = genomeID

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'))
}
}

if (true === options.enableCircularView) {

const {x: minX, y: minY} = document.querySelector('#igv-main').getBoundingClientRect()
Expand Down Expand Up @@ -342,10 +311,24 @@ async function initializationHelper(browser, container, options) {

}

const genomeChangeListener = async genome => {

if (currentGenomeId !== genome.id) {

currentGenomeId = genome.id

let trackConfigurations = await getPathsWithTrackRegistryFile(genome.id, options.trackRegistryFile)

if (undefined === trackConfigurations) {
trackConfigurations = genome.getTrackConfigurations()
}
await updateTrackMenusWithTrackConfigurations(genome.id, undefined, trackConfigurations, $('#igv-app-track-dropdown-menu'))
}
}

EventBus.globalBus.subscribe("DidChangeGenome", genomeChangeListener)
browser.on('genomechange', genomeChangeListener)

EventBus.globalBus.post({type: "DidChangeGenome", data: browser.genome.id})
browser.fireEvent('genomechange', [ browser.genome ])
}

async function updateTrackMenusWithTrackHub(hub) {
Expand Down

0 comments on commit 5799be4

Please sign in to comment.