Skip to content

Commit b07e613

Browse files
committed
hub updates
1 parent 789b072 commit b07e613

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

dev/ucsc/hub.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</option>
1818
<option value="https://hgdownload.soe.ucsc.edu/hubs/GCF/013/103/735/GCF_013103735.1/hub.txt">24 large chromosomes
1919
</option>
20-
<option value="https://hgdownload.soe.ucsc.edu/hubs/GCA/009/914/755/GCA_009914755.4/hub.txt">T2T</option>
20+
<option value="">T2T</option>
2121
</select>
2222

2323
<label>
@@ -43,7 +43,7 @@
4343
includeTracks: true
4444
}
4545

46-
const hub = await Hub.loadHub("https://hgdownload.soe.ucsc.edu/hubs/GCA/009/914/755/GCA_009914755.4/hub.txt", hubOptions)
46+
const hub = await Hub.loadHub("", hubOptions)
4747

4848
const igvConfig = {
4949
reference: hub.getGenomeConfig(),

js/bigwig/trix.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ export default class Trix {
100100
const indexes = await this.getIndex(opts)
101101
for (let i = 0; i < indexes.length; i++) {
102102
const [key, value] = indexes[i]
103-
const trimmedKey = key.slice(0, searchWord.length)
103+
const trimmedEnd = Math.min(key.length, searchWord.length)
104+
const trimmedKey = key.slice(0, trimmedEnd)
104105
if (trimmedKey < searchWord) {
105106
start = value
106107
end = value + 65536

js/genome/fasta.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import ChromSizes from "./chromSizes.js"
55
import Twobit from "./twobit.js"
66
import CachedSequence from "./cachedSequence.js"
77

8+
/**
9+
* Create a sequence object. The referenced object can include multiple sequence references, in particular
10+
* fasta and 2bit URLs. This is for backward compatibility, the 2bit URL has preference.
11+
*
12+
* @param reference
13+
* @returns {Promise<CachedSequence|ChromSizes|NonIndexedFasta>}
14+
*/
815
async function loadSequence(reference) {
916

1017
let fasta

js/genome/genome.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ class Genome {
4242

4343
this.sequence = await loadSequence(config)
4444

45-
if (config.chromSizes) {
45+
if (config.chromSizesURL) {
4646
// a chromSizes file is neccessary for 2bit sequences for whole-genome view or chromosome pulldown
47-
this.chromosomes = await loadChromSizes(config.chromSizes)
47+
this.chromosomes = await loadChromSizes(config.chromSizesURL)
4848
} else {
4949
// if the sequence defines chromosomes use them (fasta does, 2bit does not)
50-
this.chromosomes = this.sequence.chromosomes || new Map() // This might be undefined, depending on sequence type
50+
this.chromosomes = this.sequence.chromosomes || new Map()
5151
}
5252

5353
if (this.chromosomes.size > 0) {
@@ -144,9 +144,8 @@ class Genome {
144144

145145
async loadChromosome(chr) {
146146

147-
let chromAliasRecord
148147
if (this.chromAlias) {
149-
chromAliasRecord = await this.chromAlias.search(chr)
148+
const chromAliasRecord = await this.chromAlias.search(chr)
150149
if(chromAliasRecord) {
151150
chr = chromAliasRecord.chr
152151
}

test/testUCSC.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ suite("ucsc utilities", function () {
1414
const trix = new Trix(ixxFile, ixFile)
1515
const results = await trix.search("ykoX")
1616
assert.ok(results)
17+
1718
const exactMatches = results.get('ykox')
1819
assert.ok(exactMatches)
1920
assert.ok(exactMatches[0].startsWith('NP_389226.1'))
2021
console.log(results)
22+
23+
const nomatches = await trix.search("zzzz");
24+
assert.isUndefined(nomatches);
2125
})
2226

2327
test("test gene bb extra index search", async function () {

0 commit comments

Comments
 (0)