Skip to content

Commit

Permalink
hub updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinso committed Dec 1, 2023
1 parent 789b072 commit b07e613
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions dev/ucsc/hub.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</option>
<option value="https://hgdownload.soe.ucsc.edu/hubs/GCF/013/103/735/GCF_013103735.1/hub.txt">24 large chromosomes
</option>
<option value="https://hgdownload.soe.ucsc.edu/hubs/GCA/009/914/755/GCA_009914755.4/hub.txt">T2T</option>
<option value="">T2T</option>
</select>

<label>
Expand All @@ -43,7 +43,7 @@
includeTracks: true
}

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

const igvConfig = {
reference: hub.getGenomeConfig(),
Expand Down
3 changes: 2 additions & 1 deletion js/bigwig/trix.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ export default class Trix {
const indexes = await this.getIndex(opts)
for (let i = 0; i < indexes.length; i++) {
const [key, value] = indexes[i]
const trimmedKey = key.slice(0, searchWord.length)
const trimmedEnd = Math.min(key.length, searchWord.length)
const trimmedKey = key.slice(0, trimmedEnd)
if (trimmedKey < searchWord) {
start = value
end = value + 65536
Expand Down
7 changes: 7 additions & 0 deletions js/genome/fasta.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import ChromSizes from "./chromSizes.js"
import Twobit from "./twobit.js"
import CachedSequence from "./cachedSequence.js"

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

let fasta
Expand Down
9 changes: 4 additions & 5 deletions js/genome/genome.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ class Genome {

this.sequence = await loadSequence(config)

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

if (this.chromosomes.size > 0) {
Expand Down Expand Up @@ -144,9 +144,8 @@ class Genome {

async loadChromosome(chr) {

let chromAliasRecord
if (this.chromAlias) {
chromAliasRecord = await this.chromAlias.search(chr)
const chromAliasRecord = await this.chromAlias.search(chr)
if(chromAliasRecord) {
chr = chromAliasRecord.chr
}
Expand Down
4 changes: 4 additions & 0 deletions test/testUCSC.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ suite("ucsc utilities", function () {
const trix = new Trix(ixxFile, ixFile)
const results = await trix.search("ykoX")
assert.ok(results)

const exactMatches = results.get('ykox')
assert.ok(exactMatches)
assert.ok(exactMatches[0].startsWith('NP_389226.1'))
console.log(results)

const nomatches = await trix.search("zzzz");
assert.isUndefined(nomatches);
})

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

0 comments on commit b07e613

Please sign in to comment.