diff --git a/js/feature/textFeatureSource.js b/js/feature/textFeatureSource.js index 0e0edbe23..58dca2669 100644 --- a/js/feature/textFeatureSource.js +++ b/js/feature/textFeatureSource.js @@ -196,7 +196,7 @@ class TextFeatureSource extends BaseFeatureSource { // indicating whole chromosome should be read at once. if ((!visibilityWindow || visibilityWindow <= 0) && this.config.expandQuery !== false) { // Whole chromosome - const chromosome = this.genome ? this.genome.getChromosome(queryChr) : undefined + const chromosome = this.genome ? this.genome.getChromosome(chr) : undefined intervalStart = 0 intervalEnd = Math.max(chromosome ? chromosome.bpLength : Number.MAX_SAFE_INTEGER, end) } else if (visibilityWindow > (end - start) && this.config.expandQuery !== false) { diff --git a/js/genome/chromAliasBB.js b/js/genome/chromAliasBB.js index 2b1d16b64..1a034f1a4 100644 --- a/js/genome/chromAliasBB.js +++ b/js/genome/chromAliasBB.js @@ -1,4 +1,5 @@ import BWReader from "../bigwig/bwReader.js" +import ChromAliasDefaults from "./chromAliasDefaults.js" /** * Chromosome alias source backed by a UCSC bigbed file @@ -62,6 +63,7 @@ class ChromAliasBB { if (!this.aliasRecordCache.has(alias)) { const aliasRecord = await this.reader.search(alias) if (aliasRecord) { + ChromAliasDefaults.addCaseAliases(aliasRecord) for (let key of Object.keys(aliasRecord)) { if ("start" !== key && "end" !== key) { this.aliasRecordCache.set(aliasRecord[key], aliasRecord) diff --git a/js/genome/chromAliasDefaults.js b/js/genome/chromAliasDefaults.js index b0423adbf..a49d7a36b 100644 --- a/js/genome/chromAliasDefaults.js +++ b/js/genome/chromAliasDefaults.js @@ -137,12 +137,12 @@ class ChromAliasDefaults { } } + for (let rec of aliasRecords) { + ChromAliasDefaults.addCaseAliases(rec) for (let a of Object.values(rec)) { this.aliasRecordCache.set(a, rec) } - this.aliasRecordCache.set(rec.chr.toLowerCase(), rec) - this.aliasRecordCache.set(rec.chr.toUpperCase(), rec) } } @@ -162,6 +162,24 @@ class ChromAliasDefaults { return tokens[tokens.length - 1] } + static addCaseAliases(aliasRecord) { + + // Add some aliases for case insensitivy + const upper = aliasRecord.chr.toUpperCase() + const lower = aliasRecord.chr.toLowerCase() + const cap = aliasRecord.chr.charAt(0).toUpperCase() + aliasRecord.chr.slice(1) + if(aliasRecord.chr !== upper) { + aliasRecord["_uppercase"] = upper + } + if(aliasRecord.chr !== lower) { + aliasRecord["_lowercase"] = lower + } + if(aliasRecord.chr !== cap) { + aliasRecord["_cap"] = cap + } + + } + } export default ChromAliasDefaults diff --git a/js/genome/chromAliasFile.js b/js/genome/chromAliasFile.js index 0842c3f45..4acd43078 100644 --- a/js/genome/chromAliasFile.js +++ b/js/genome/chromAliasFile.js @@ -9,8 +9,9 @@ * @param config * @returns {Promise<*[]>} */ -import {isNumber, buildOptions} from "../util/igvUtils.js" +import {buildOptions} from "../util/igvUtils.js" import {igvxhr, StringUtils} from "../../node_modules/igv-utils/src/index.js" +import ChromAliasDefaults from "./chromAliasDefaults.js" class ChromAliasFile { @@ -73,14 +74,16 @@ class ChromAliasFile { } const aliasRecord = {chr} + ChromAliasDefaults.addCaseAliases(aliasRecord) for (let i = 0; i < tokens.length; i++) { const key = this.headings ? this.headings[i] : i aliasRecord[key] = tokens[i] - this.aliasRecordCache.set(tokens[i], aliasRecord) } - this.aliasRecordCache.set(chr.toLowerCase(), aliasRecord) - this.aliasRecordCache.set(chr.toUpperCase(), aliasRecord) + for (let a of Object.values(aliasRecord)) { + this.aliasRecordCache.set(a, aliasRecord) + } + } } } diff --git a/js/genome/genome.js b/js/genome/genome.js index b5a5cf0b8..3da733d87 100644 --- a/js/genome/genome.js +++ b/js/genome/genome.js @@ -190,6 +190,21 @@ class Genome { if (!aliasRecord && chr !== chr.toLowerCase()) { aliasRecord = await this.chromAlias.search(chr.toLowerCase()) } + if(aliasRecord) { + // Add some aliases for case insensitivy + const upper = aliasRecord.chr.toUpperCase() + const lower = aliasRecord.chr.toLowerCase() + const cap = aliasRecord.chr.charAt(0).toUpperCase() + aliasRecord.chr.slice(1) + if(aliasRecord.chr !== upper) { + aliasRecord["_uppercase"] = upper + } + if(aliasRecord.chr !== lower) { + aliasRecord["_lowercase"] = lower + } + if(aliasRecord.chr !== cap) { + aliasRecord["_cap"] = cap + } + } this.#aliasRecordCache.set(chr, aliasRecord) // Set even if undefined to prevent recurrent searches return aliasRecord }