Skip to content

Commit

Permalink
Fix some issues with the bgzip file dialog driver and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Sep 13, 2018
1 parent 6b76611 commit 07d5dde
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/JBrowse/Browser.js
Expand Up @@ -1370,7 +1370,6 @@ openFasta: function() {
alert('Unindexed file too large. You must have an index file (.fai) for sequence files larger than 100 MB.')
return reject('sequence file too large')
}
console.log(storeConf)

const store = new storeClass(
Object.assign({ browser: this }, storeConf)
Expand Down
Expand Up @@ -40,7 +40,7 @@ return declare( null, {
for( var n in configs ) {
var c = configs[n];
if( Util.basename( c[this.indexConfKey] ? c[this.indexConfKey ].url || c[this.indexConfKey].blob.name : c[this.indexUrlConfKey], this.indexExtensionMap ) == basename ||
Util.basename( c[this.doubleIndexConfKey] ? c[this.doubleIndexConfKey ].url || c[this.doubleIndexConfKey].blob.name : c[this.doubleIndexUrlConfKey], this.doubleExtensionMap ) == basename ) {
Util.basename( c[this.doubleIndexConfKey] ? c[this.doubleIndexConfKey ].url || c[this.doubleIndexConfKey].blob.name : c[this.doubleIndexUrlConfKey], this.doubleIndexExtensionMap ) == basename ) {

// it's a match, put it in
c[this.fileConfKey] = this._makeBlob( resource );
Expand Down Expand Up @@ -70,7 +70,7 @@ return declare( null, {
for( var n in configs ) {
var c = configs[n];
if( Util.basename( c[this.fileConfKey] ? c[this.fileConfKey ].url || c[this.fileConfKey].blob.name : c[this.fileConfKey], this.fileExtensionMap ) == basename ||
Util.basename( c[this.doubleIndexConfKey] ? c[this.doubleIndexConfKey ].url || c[this.doubleIndexConfKey].blob.name : c[this.doubleIndexUrlConfKey], this.doubleExtensionMap ) == basename ) {
Util.basename( c[this.doubleIndexConfKey] ? c[this.doubleIndexConfKey ].url || c[this.doubleIndexConfKey].blob.name : c[this.doubleIndexUrlConfKey], this.doubleIndexExtensionMap ) == basename ) {

// it's a match, put it in
c[this.indexConfKey] = this._makeBlob( resource );
Expand Down Expand Up @@ -133,7 +133,6 @@ return declare( null, {
var v2 = (conf[this.fileConfKey] || conf[this.fileUrlConfKey])
var v3 = (conf[this.doubleIndexConfKey] || conf[this.doubleIndexUrlConfKey])
if(!(v1 && v2 && v3)) {
console.log(configs[n], configs, n)
delete configs[n]
}
}
Expand Down
24 changes: 23 additions & 1 deletion tests/js_tests/spec/AddFiles.spec.js
Expand Up @@ -121,7 +121,7 @@ describe( 'FileDialog drivers', function() {
expect( confs.foo.fasta.blob.name ).toEqual( 'zee.fa' );
});

it( 'BGZIP FASTA file', function( ) {
it( 'BGZIP FASTA file variant 1', function( ) {
var confs = { foo: { bgzfa: { blob: { name :'zee.fa.gz'} } } };
var driver = new BgzipIndexedFastaDriver();
expect( driver.tryResource( confs, { type: 'fasta.gz.fai', file: { name: 'zee.fa.gz.fai'} } ) ).toBeTruthy();
Expand All @@ -131,6 +131,28 @@ describe( 'FileDialog drivers', function() {
expect( confs.foo.gzi.blob.name ).toEqual( 'zee.fa.gz.gzi' );
expect( confs.foo.bgzfa.blob.name ).toEqual( 'zee.fa.gz' );
});

it( 'BGZIP FASTA file variant 2', function( ) {
var confs = { foo: { fai: { blob: { name :'zee.fa.gz.fai'} } } };
var driver = new BgzipIndexedFastaDriver();
expect( driver.tryResource( confs, { type: 'fasta.gz', file: { name: 'zee.fa.gz'} } ) ).toBeTruthy();
expect( driver.tryResource( confs, { type: 'gzi', file: { name: 'zee.fa.gz.gzi'} } ) ).toBeTruthy();
driver.finalizeConfiguration(confs);
expect( confs.foo.fai.blob.name ).toEqual( 'zee.fa.gz.fai' );
expect( confs.foo.gzi.blob.name ).toEqual( 'zee.fa.gz.gzi' );
expect( confs.foo.bgzfa.blob.name ).toEqual( 'zee.fa.gz' );
});

it( 'BGZIP FASTA file variant 3', function( ) {
var confs = { foo: { bgzfa: { blob: { name :'zee.fa.gz'} } } };
var driver = new BgzipIndexedFastaDriver();
expect( driver.tryResource( confs, { type: 'gzi', file: { name: 'zee.fa.gz.gzi'} } ) ).toBeTruthy();
expect( driver.tryResource( confs, { type: 'fasta.gz.fai', file: { name: 'zee.fa.gz.fai'} } ) ).toBeTruthy();
driver.finalizeConfiguration(confs);
expect( confs.foo.fai.blob.name ).toEqual( 'zee.fa.gz.fai' );
expect( confs.foo.gzi.blob.name ).toEqual( 'zee.fa.gz.gzi' );
expect( confs.foo.bgzfa.blob.name ).toEqual( 'zee.fa.gz' );
});
});
});

0 comments on commit 07d5dde

Please sign in to comment.