Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into 1147_npm_tabix
- Loading branch information
Showing
23 changed files
with
437 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
const LRU = cjsRequire('lru-cache') | ||
const { BgzipIndexedFasta } = cjsRequire('@gmod/indexedfasta') | ||
const { Buffer } = cjsRequire('buffer') | ||
|
||
const fastaIndexedFilesCache = LRU(5) | ||
|
||
const BlobFilehandleWrapper = cjsRequire('../../Model/BlobFilehandleWrapper') | ||
|
||
define( [ 'dojo/_base/declare', | ||
'dojo/_base/lang', | ||
'JBrowse/Model/XHRBlob', | ||
'JBrowse/Store/SeqFeature/IndexedFasta' | ||
], | ||
function( | ||
declare, | ||
lang, | ||
XHRBlob, | ||
IndexedFasta | ||
) { | ||
|
||
return declare( IndexedFasta, | ||
{ | ||
|
||
/** | ||
* Storage backend for sequences in indexed fasta files | ||
* served as static text files. | ||
* @constructs | ||
*/ | ||
constructor: function(args) { | ||
let dataBlob | ||
if (args.bgzfa) | ||
dataBlob = new BlobFilehandleWrapper(args.bgzfa) | ||
else if (args.urlTemplate) | ||
dataBlob = new BlobFilehandleWrapper(new XHRBlob(this.resolveUrl(args.urlTemplate), { expectRanges: true })) | ||
else | ||
dataBlob = new BlobFilehandleWrapper(new XHRBlob('data.fa', { expectRanges: true })) | ||
|
||
let indexBlob | ||
if (args.fai) | ||
indexBlob = new BlobFilehandleWrapper(args.fai) | ||
else if (args.faiUrlTemplate) | ||
indexBlob = new BlobFilehandleWrapper(new XHRBlob(this.resolveUrl(args.faiUrlTemplate))) | ||
else if (args.urlTemplate) | ||
indexBlob = new BlobFilehandleWrapper(new XHRBlob(this.resolveUrl(args.urlTemplate+'.fai'))) | ||
else throw new Error('no index provided, must provide a FASTA index') | ||
|
||
|
||
let gziBlob | ||
if(args.gzi) | ||
gziBlob = new BlobFilehandleWrapper(args.gzi) | ||
else if(args.gziUrlTemplate) | ||
gziBlob = new BlobFilehandleWrapper(new XHRBlob(this.resolveUrl(args.gziUrlTemplate))) | ||
else if (args.urlTemplate) | ||
gziBlob = new BlobFilehandleWrapper(new XHRBlob(this.resolveUrl(args.urlTemplate+'.gzi'))) | ||
else throw new Error('no gzi index provided, must provide a GZI index') | ||
|
||
this.source = dataBlob.toString() | ||
|
||
// LRU-cache the CRAM object so we don't have to re-download the | ||
// index when we switch chromosomes | ||
const cacheKey = `data: ${dataBlob}, index: ${indexBlob}, gzi: ${gziBlob}` | ||
this.fasta = fastaIndexedFilesCache.get(cacheKey) | ||
if (!this.fasta) { | ||
this.fasta = new BgzipIndexedFasta({ | ||
fasta: dataBlob, | ||
fai: indexBlob, | ||
gzi: gziBlob | ||
}) | ||
|
||
fastaIndexedFilesCache.set(cacheKey, this.fasta) | ||
} | ||
this.fasta.getSequenceList().then( | ||
() => this._deferred.features.resolve({success:true}), | ||
() => this._failAllDeferred() | ||
) | ||
}, | ||
saveStore: function() { | ||
return { | ||
urlTemplate: (this.config.file||this.config.blob).url, | ||
faiUrlTemplate: this.config.fai.url, | ||
gziUrlTemplate: this.config.gzi.url | ||
}; | ||
} | ||
|
||
}); | ||
}); |
Oops, something went wrong.