Skip to content

Commit

Permalink
Bug fix -- hub.txt session defaults were not set
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinso committed Oct 23, 2023
1 parent c7444ee commit 4486c57
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 22 deletions.
3 changes: 2 additions & 1 deletion dev/ucsc/hub.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


const hubOptions = {
url: "https://hgdownload.soe.ucsc.edu/hubs/GCA/009/914/755/GCA_009914755.4/hub.txt",
url: "https://hgdownload.soe.ucsc.edu/hubs/GCA/018/471/515/GCA_018471515.1/hub.txt",
includeTracks: "all"
}

Expand All @@ -45,6 +45,7 @@

const igvConfig = {
locus: hub.getDefaultPosition(),
showChromosomeWidget: false,
reference: ref
}

Expand Down
11 changes: 10 additions & 1 deletion js/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import Hub from "./ucsc/ucscHub.js"
import MultiTrackSelectButton from "./ui/multiTrackSelectButton.js"
import MenuUtils from "./ui/menuUtils.js"
import Genome from "./genome/genome.js"
import {setDefaults} from "./igv-create.js"

// css - $igv-scrollbar-outer-width: 14px;
const igv_scrollbar_outer_width = 14
Expand Down Expand Up @@ -454,6 +455,9 @@ class Browser {
*/
async loadSession(options) {

// UCSC hub hack
const chromosomeSelectWidget = this.chromosomeSelectWidget

this.sampleInfo.initialize()

// TODO: deprecated
Expand Down Expand Up @@ -490,13 +494,17 @@ class Browser {

} else if (filename.endsWith("hub.txt")) {
const hub = await Hub.loadHub(options)
if(chromosomeSelectWidget) {
chromosomeSelectWidget.hide()
}
const genomeConfig = hub.getGenomeConfig(options.includeTracks)
const initialLocus = hub.getDefaultPosition()
return {
const config = {
showChromosomeWidget: false,
locus: initialLocus,
reference: genomeConfig
}
return setDefaults(config)
} else if (filename.endsWith(".json")) {
return igvxhr.loadJson(urlOrFile)
} else {
Expand All @@ -516,6 +524,7 @@ class Browser {

// prepare to load a new session, discarding DOM and state
this.cleanHouseForSession()
this.config = session

// Check for juicebox session
if (session.browsers) {
Expand Down
16 changes: 9 additions & 7 deletions js/genome/genome.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,21 @@ class Genome {

async loadChromosome(chr) {

if (this.chromAlias) { // Try alias
const chromAliasRecord = await this.chromAlias.search(chr)
if (chromAliasRecord) {
chr = chromAliasRecord.chr
}
}

if (!this.chromosomes.has(chr)) {
const sequenceRecord = await this.sequence.getSequenceRecord(chr)
if (sequenceRecord) {
const chromosome = new Chromosome(chr, 0, sequenceRecord.bpLength)
this.chromosomes.set(chr, chromosome)
} else {
// Try alias
if (this.chromAlias) {
const chromAliasRecord = await this.chromAlias.search(chr)
if (chromAliasRecord) {
const chromosome = new Chromosome(chromAliasRecord.chr, 0, sequenceRecord.bpLength)
this.chromosomes.set(chr, chromosome)
}
}

this.chromosomes.set(chr, undefined) // Prevents future attempts
}
}
Expand Down
4 changes: 3 additions & 1 deletion js/igv-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ function setDefaults(config) {
config.tracks = []
}

return config

}


Expand Down Expand Up @@ -282,4 +284,4 @@ async function createTrack(config, browser) {
return await Browser.prototype.createTrack.call(browser, config)
}

export {createTrack, createBrowser, removeBrowser, removeAllBrowsers, getAllBrowsers, visibilityChange}
export {createTrack, createBrowser, removeBrowser, removeAllBrowsers, getAllBrowsers, visibilityChange, setDefaults}
8 changes: 4 additions & 4 deletions js/referenceFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ class ReferenceFrame {
const centerBP = undefined === centerBPOrUndefined ? (this.start + this.toBP(viewportWidth / 2.0)) : centerBPOrUndefined

// save initial start and bpp
const {start, bpPerPixel} = this.start

const {bpLength} = this.getChromosome()
const initialStart = this.start
const initialBpPerPixel = this.bpPerPixel
const bpLength = this.getChromosome().bpLength
const bppThreshold = scaleFactor < 1.0 ? browser.minimumBases() / viewportWidth : bpLength / viewportWidth

// update bpp
Expand All @@ -148,7 +148,7 @@ class ReferenceFrame {

this.end = this.start + widthBP

const viewChanged = start !== this.start || bpPerPixel !== this.bpPerPixel
const viewChanged = initialStart !== this.start || initialBpPerPixel !== this.bpPerPixel
if (viewChanged) {
await browser.updateViews(true)
}
Expand Down
15 changes: 7 additions & 8 deletions js/ucsc/ucscHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ class Hub {
}

static supportedTypes = new Set(["bigBed", "bigWig", "bigGenePred"])
static filterTracks = new Set(["cytoBandIdeo"])

//["cytoBandIdeo", "assembly", "gap", "gapOverlap", "allGaps",
// "cpgIslandExtUnmasked", "windowMasker"])
static filterTracks = new Set(["cytoBandIdeo", "assembly", "gap", "gapOverlap", "allGaps",
"cpgIslandExtUnmasked", "windowMasker"])

constructor(url, stanzas, groups) {

Expand Down Expand Up @@ -128,9 +126,10 @@ isPcr dynablat-01.soe.ucsc.edu 4040 dynamic GCF/000/186/305/GCF_000186305.1
if (this.genomeStanza.hasProperty("twoBitBptUrl")) {
config.twoBitBptURL = this.baseURL + this.genomeStanza.getProperty("twoBitBptUrl")
}
if (this.genomeStanza.hasProperty("chromSizes")) {
config.chromSizes = this.baseURL + this.genomeStanza.getProperty("chromSizes")
}
// chromSizes can take a very long time to load, and is not useful with the default WGV = off
// if (this.genomeStanza.hasProperty("chromSizes")) {
// config.chromSizes = this.baseURL + this.genomeStanza.getProperty("chromSizes")
// }
if (this.genomeStanza.hasProperty("description")) {
config.description += `\n${this.genomeStanza.getProperty("description")}`
}
Expand Down Expand Up @@ -370,7 +369,7 @@ async function loadStanzas(options) {
startNewNode = true
} else {
const key = line.substring(indent, i)
if(key.startsWith("#")) continue
if (key.startsWith("#")) continue
const value = line.substring(i + 1)
if (startNewNode) {
// Start a new node -- indent is currently ignored as igv.js does not support sub-tracks,
Expand Down

0 comments on commit 4486c57

Please sign in to comment.