Skip to content

Commit

Permalink
Enable case-insensitive search for chromosomes if canonical name is l…
Browse files Browse the repository at this point in the history
…ower case.
  • Loading branch information
jrobinso committed Nov 21, 2024
1 parent 1eb0438 commit 3d8d250
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions js/genome/genome.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import ChromAliasDefaults from "./chromAliasDefaults.js"
class Genome {

#wgChromosomeNames
#aliasRecordCache = new Map()

static async createGenome(options, browser) {

Expand Down Expand Up @@ -162,11 +163,9 @@ class Genome {

async loadChromosome(chr) {

if (this.chromAlias) {
const chromAliasRecord = await this.chromAlias.search(chr)
if (chromAliasRecord) {
chr = chromAliasRecord.chr
}
const chromAliasRecord = await this.getAliasRecord(chr)
if (chromAliasRecord) {
chr = chromAliasRecord.chr
}

if (!this.chromosomes.has(chr)) {
Expand All @@ -183,8 +182,16 @@ class Genome {
}

async getAliasRecord(chr) {
if (this.#aliasRecordCache.has(chr)) {
return this.#aliasRecordCache.get(chr)
}
if (this.chromAlias) {
return this.chromAlias.search(chr)
let aliasRecord = await this.chromAlias.search(chr)
if (!aliasRecord && chr !== chr.toLowerCase()) {
aliasRecord = await this.chromAlias.search(chr.toLowerCase())
}
this.#aliasRecordCache.set(chr, aliasRecord) // Set even if undefined to prevent recurrent searches
return aliasRecord
}
}

Expand Down

0 comments on commit 3d8d250

Please sign in to comment.