Skip to content

Commit 4486c57

Browse files
committed
Bug fix -- hub.txt session defaults were not set
1 parent c7444ee commit 4486c57

File tree

6 files changed

+35
-22
lines changed

6 files changed

+35
-22
lines changed

dev/ucsc/hub.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636

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

@@ -45,6 +45,7 @@
4545

4646
const igvConfig = {
4747
locus: hub.getDefaultPosition(),
48+
showChromosomeWidget: false,
4849
reference: ref
4950
}
5051

js/browser.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import Hub from "./ucsc/ucscHub.js"
5555
import MultiTrackSelectButton from "./ui/multiTrackSelectButton.js"
5656
import MenuUtils from "./ui/menuUtils.js"
5757
import Genome from "./genome/genome.js"
58+
import {setDefaults} from "./igv-create.js"
5859

5960
// css - $igv-scrollbar-outer-width: 14px;
6061
const igv_scrollbar_outer_width = 14
@@ -454,6 +455,9 @@ class Browser {
454455
*/
455456
async loadSession(options) {
456457

458+
// UCSC hub hack
459+
const chromosomeSelectWidget = this.chromosomeSelectWidget
460+
457461
this.sampleInfo.initialize()
458462

459463
// TODO: deprecated
@@ -490,13 +494,17 @@ class Browser {
490494

491495
} else if (filename.endsWith("hub.txt")) {
492496
const hub = await Hub.loadHub(options)
497+
if(chromosomeSelectWidget) {
498+
chromosomeSelectWidget.hide()
499+
}
493500
const genomeConfig = hub.getGenomeConfig(options.includeTracks)
494501
const initialLocus = hub.getDefaultPosition()
495-
return {
502+
const config = {
496503
showChromosomeWidget: false,
497504
locus: initialLocus,
498505
reference: genomeConfig
499506
}
507+
return setDefaults(config)
500508
} else if (filename.endsWith(".json")) {
501509
return igvxhr.loadJson(urlOrFile)
502510
} else {
@@ -516,6 +524,7 @@ class Browser {
516524

517525
// prepare to load a new session, discarding DOM and state
518526
this.cleanHouseForSession()
527+
this.config = session
519528

520529
// Check for juicebox session
521530
if (session.browsers) {

js/genome/genome.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,21 @@ class Genome {
143143

144144
async loadChromosome(chr) {
145145

146-
if (this.chromAlias) { // Try alias
147-
const chromAliasRecord = await this.chromAlias.search(chr)
148-
if (chromAliasRecord) {
149-
chr = chromAliasRecord.chr
150-
}
151-
}
152-
153146
if (!this.chromosomes.has(chr)) {
154147
const sequenceRecord = await this.sequence.getSequenceRecord(chr)
155148
if (sequenceRecord) {
156149
const chromosome = new Chromosome(chr, 0, sequenceRecord.bpLength)
157150
this.chromosomes.set(chr, chromosome)
158151
} else {
152+
// Try alias
153+
if (this.chromAlias) {
154+
const chromAliasRecord = await this.chromAlias.search(chr)
155+
if (chromAliasRecord) {
156+
const chromosome = new Chromosome(chromAliasRecord.chr, 0, sequenceRecord.bpLength)
157+
this.chromosomes.set(chr, chromosome)
158+
}
159+
}
160+
159161
this.chromosomes.set(chr, undefined) // Prevents future attempts
160162
}
161163
}

js/igv-create.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ function setDefaults(config) {
199199
config.tracks = []
200200
}
201201

202+
return config
203+
202204
}
203205

204206

@@ -282,4 +284,4 @@ async function createTrack(config, browser) {
282284
return await Browser.prototype.createTrack.call(browser, config)
283285
}
284286

285-
export {createTrack, createBrowser, removeBrowser, removeAllBrowsers, getAllBrowsers, visibilityChange}
287+
export {createTrack, createBrowser, removeBrowser, removeAllBrowsers, getAllBrowsers, visibilityChange, setDefaults}

js/referenceFrame.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ class ReferenceFrame {
129129
const centerBP = undefined === centerBPOrUndefined ? (this.start + this.toBP(viewportWidth / 2.0)) : centerBPOrUndefined
130130

131131
// save initial start and bpp
132-
const {start, bpPerPixel} = this.start
133-
134-
const {bpLength} = this.getChromosome()
132+
const initialStart = this.start
133+
const initialBpPerPixel = this.bpPerPixel
134+
const bpLength = this.getChromosome().bpLength
135135
const bppThreshold = scaleFactor < 1.0 ? browser.minimumBases() / viewportWidth : bpLength / viewportWidth
136136

137137
// update bpp
@@ -148,7 +148,7 @@ class ReferenceFrame {
148148

149149
this.end = this.start + widthBP
150150

151-
const viewChanged = start !== this.start || bpPerPixel !== this.bpPerPixel
151+
const viewChanged = initialStart !== this.start || initialBpPerPixel !== this.bpPerPixel
152152
if (viewChanged) {
153153
await browser.updateViews(true)
154154
}

js/ucsc/ucscHub.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ class Hub {
3131
}
3232

3333
static supportedTypes = new Set(["bigBed", "bigWig", "bigGenePred"])
34-
static filterTracks = new Set(["cytoBandIdeo"])
35-
36-
//["cytoBandIdeo", "assembly", "gap", "gapOverlap", "allGaps",
37-
// "cpgIslandExtUnmasked", "windowMasker"])
34+
static filterTracks = new Set(["cytoBandIdeo", "assembly", "gap", "gapOverlap", "allGaps",
35+
"cpgIslandExtUnmasked", "windowMasker"])
3836

3937
constructor(url, stanzas, groups) {
4038

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

0 commit comments

Comments
 (0)