Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor Browser.openFasta, fixes #1043
- Loading branch information
Showing
5 changed files
with
140 additions
and
114 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
62 changes: 62 additions & 0 deletions
62
src/JBrowse/View/FileDialog/TrackList/_OptionallyIndexedFileDriver.js
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,62 @@ | ||
define([ | ||
'dojo/_base/declare', | ||
'JBrowse/Util', | ||
'./_IndexedFileDriver', | ||
], | ||
function( declare, Util, _IndexedFileDriver ) { | ||
return declare( _IndexedFileDriver, { | ||
|
||
// try to merge any singleton file and index stores. currently can only do this if there is one of each | ||
finalizeConfiguration: function( configs ) { | ||
var singletonIndexes = {}; | ||
var singletonIndexCount = 0; | ||
var singletonFiles = {}; | ||
var singletonFileCount = 0; | ||
for( var n in configs ) { | ||
var conf = configs[n]; | ||
if( conf.type === this.storeType ) { | ||
if( (conf[this.indexConfKey] || conf[this.indexUrlConfKey]) && ! ( conf[this.fileConfKey] || conf[this.fileUrlConfKey] ) ) { | ||
// singleton Index | ||
singletonIndexCount++; | ||
singletonIndexes[n] = conf; | ||
} | ||
else if(( conf[this.fileConfKey] || conf[this.fileUrlConfKey] ) && ! ( conf[this.indexConfKey] || conf[this.indexUrlConfKey]) ) { | ||
// singleton File | ||
singletonFileCount++; | ||
singletonFiles[n] = conf; | ||
} | ||
} | ||
} | ||
|
||
// if we have a single File and single Index left at the end, | ||
// stick them together and we'll see what happens | ||
if( singletonFileCount == 1 && singletonIndexCount == 1 ) { | ||
for( var indexName in singletonIndexes ) { | ||
for( var fileName in singletonFiles ) { | ||
if( singletonIndexes[indexName][this.indexUrlConfKey] ) | ||
singletonFiles[fileName][this.indexUrlConfKey] = singletonIndexes[indexName][this.indexUrlConfKey]; | ||
if( singletonIndexes[indexName][this.indexConfKey] ) | ||
singletonFiles[fileName][this.indexConfKey] = singletonIndexes[indexName][this.indexConfKey]; | ||
|
||
delete configs[indexName]; | ||
} | ||
} | ||
} | ||
|
||
// delete any remaining singleton Indexes, since they don't have | ||
// a hope of working | ||
for( var indexName in singletonIndexes ) { | ||
delete configs[indexName]; | ||
} | ||
|
||
// make any remaining singleton data files be unindexed stores | ||
for( var fileName in singletonFiles ) { | ||
configs[fileName].type = this.unindexedStoreType; | ||
} | ||
}, | ||
|
||
confIsValid: function( conf ) { | ||
return (conf[this.fileConfKey] || conf[this.fileUrlConfKey]); | ||
} | ||
}); | ||
}); |
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