File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import ChromAliasDefaults from "./chromAliasDefaults.js"
20
20
class Genome {
21
21
22
22
#wgChromosomeNames
23
+ #aliasRecordCache = new Map ( )
23
24
24
25
static async createGenome ( options , browser ) {
25
26
@@ -162,11 +163,9 @@ class Genome {
162
163
163
164
async loadChromosome ( chr ) {
164
165
165
- if ( this . chromAlias ) {
166
- const chromAliasRecord = await this . chromAlias . search ( chr )
167
- if ( chromAliasRecord ) {
168
- chr = chromAliasRecord . chr
169
- }
166
+ const chromAliasRecord = await this . getAliasRecord ( chr )
167
+ if ( chromAliasRecord ) {
168
+ chr = chromAliasRecord . chr
170
169
}
171
170
172
171
if ( ! this . chromosomes . has ( chr ) ) {
@@ -183,8 +182,16 @@ class Genome {
183
182
}
184
183
185
184
async getAliasRecord ( chr ) {
185
+ if ( this . #aliasRecordCache. has ( chr ) ) {
186
+ return this . #aliasRecordCache. get ( chr )
187
+ }
186
188
if ( this . chromAlias ) {
187
- return this . chromAlias . search ( chr )
189
+ let aliasRecord = await this . chromAlias . search ( chr )
190
+ if ( ! aliasRecord && chr !== chr . toLowerCase ( ) ) {
191
+ aliasRecord = await this . chromAlias . search ( chr . toLowerCase ( ) )
192
+ }
193
+ this . #aliasRecordCache. set ( chr , aliasRecord ) // Set even if undefined to prevent recurrent searches
194
+ return aliasRecord
188
195
}
189
196
}
190
197
You can’t perform that action at this time.
0 commit comments