Skip to content

Commit c3fd5d2

Browse files
committed
fix problem with genome name aliasing
1 parent 04d986a commit c3fd5d2

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

js/genome/genome.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Genome {
4747
}
4848

4949
// For backward compatibility
50-
if(this.chromosomes.size > 0) {
50+
if (this.chromosomes.size > 0) {
5151
this.chromosomeNames = Array.from(this.chromosomes.keys())
5252
}
5353

@@ -59,7 +59,7 @@ class Genome {
5959

6060
if (config.cytobandBbURL) {
6161
this.cytobandSource = new CytobandFileBB(config.cytobandBbURL, Object.assign({}, config), this)
62-
} else if(config.cytobandURL) {
62+
} else if (config.cytobandURL) {
6363
this.cytobandSource = new CytobandFile(config.cytobandURL, Object.assign({}, config))
6464
}
6565

@@ -85,7 +85,6 @@ class Genome {
8585
}
8686

8787

88-
8988
get description() {
9089
return this.config.description || `${this.id}\n${this.name}`
9190
}
@@ -143,23 +142,21 @@ class Genome {
143142
async loadChromosome(chr) {
144143

145144
if (!this.chromosomes.has(chr)) {
145+
let chromosome
146146
let sequenceRecord = await this.sequence.getSequenceRecord(chr)
147147
if (sequenceRecord) {
148-
const chromosome = new Chromosome(chr, 0, sequenceRecord.bpLength)
149-
this.chromosomes.set(chr, chromosome)
148+
chromosome = new Chromosome(chr, 0, sequenceRecord.bpLength)
150149
} else {
151150
// Try alias
152151
if (this.chromAlias) {
153152
const chromAliasRecord = await this.chromAlias.search(chr)
154153
if (chromAliasRecord) {
155154
sequenceRecord = await this.sequence.getSequenceRecord(chromAliasRecord.chr)
156-
const chromosome = new Chromosome(chromAliasRecord.chr, 0, sequenceRecord.bpLength)
157-
this.chromosomes.set(chr, chromosome)
155+
chromosome = new Chromosome(chromAliasRecord.chr, 0, sequenceRecord.bpLength)
158156
}
159157
}
160-
161-
this.chromosomes.set(chr, undefined) // Prevents future attempts
162158
}
159+
this.chromosomes.set(chr, chromosome) // <= chromosome might be undefined, setting it prevents future attempts
163160
}
164161

165162
return this.chromosomes.get(chr)

0 commit comments

Comments
 (0)