Skip to content

Commit

Permalink
make location-choice dialog show what track(s(s) are associated with …
Browse files Browse the repository at this point in the history
…each location
  • Loading branch information
rbuels committed Jan 21, 2013
1 parent c00fea7 commit 78365cd
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/JBrowse/Browser.js
Expand Up @@ -365,12 +365,13 @@ Browser.prototype.loadNames = function() {
conf.url = Util.resolveUrl( conf.baseUrl, conf.url );

if( conf.type == 'Hash' )
this.nameStore = new NamesHashStore( conf );
this.nameStore = new NamesHashStore( dojo.mixin({ browser: this }, conf) );
else
// wrap the older LazyTrieDojoDataStore with
// dojo.store.DataStore to conform with the dojo/store API
this.nameStore = new DojoDataStore({
store: new NamesLazyTrieDojoDataStore({
browser: this,
namesTrie: new LazyTrie( conf.url, "lazy-{Chunk}.json"),
stopPrefixes: conf.stopPrefixes,
resultLimit: conf.resultLimit || 15,
Expand Down Expand Up @@ -1293,7 +1294,7 @@ Browser.prototype.showRegion = function( location ) {

// if the location has a track associated with it, show it
if( location.tracks ) {
this.showTracks( location.tracks );
this.showTracks( array.map( location.tracks, function( t ) { return t && (t.label || t.name) || t; } ));
}
};

Expand Down
2 changes: 2 additions & 0 deletions src/JBrowse/Store/Hash.js
Expand Up @@ -26,6 +26,8 @@ return declare( null, {

this.meta = {};

this.browser = args.browser;

// this.ready is a Deferred that will be resolved when we have
// read the meta.json file with the params of this hashstore
this.ready = this._readMeta();
Expand Down
20 changes: 19 additions & 1 deletion src/JBrowse/Store/Names/Hash.js
Expand Up @@ -49,11 +49,12 @@ return declare( HashStore,
var item = {};
if( typeof nameRecord == 'object' ) {
item.name = nameRecord[0];
var trackConfig = this._findTrackConfig( ((this.meta||{}).track_names||{})[ nameRecord[1] ] );
item.location = new Location({
ref: nameRecord[3],
start: parseInt( nameRecord[4] ),
end: parseInt( nameRecord[5] ),
tracks: [ ((this.meta||{}).track_names||{})[ nameRecord[1] ] ]
tracks: [ trackConfig ]
});
} else {
item.name = nameRecord;
Expand All @@ -62,6 +63,23 @@ return declare( HashStore,
}
},

// look in the browser's track configuration for the track with the given label
_findTrackConfig: function( trackLabel ) {
if( ! trackLabel )
return null;

var track = null;
var i = array.some( this.browser.config.tracks, function( t ) {
if( t.label == trackLabel ) {
track = t;
return true;
}
return false;
});

return track;
},

_makeResults: function( nameRecords ) {
// convert the name records into dojo.store-compliant data
// items, sort them by name and location
Expand Down
13 changes: 13 additions & 0 deletions src/JBrowse/View/LocationList.js
Expand Up @@ -32,6 +32,19 @@ return declare(null,{
{ label: 'End', field: 'end' }
];

if( args.locations && args.locations.length && args.locations[0].tracks )
columns.push({
label: 'Track',
field: 'tracks',
formatter: function(tracks) {
return array.map( array.filter( tracks, function(t) { return t; }), // remove nulls
function(t) {
return t.key || t.name || t.label || t;
})
.join(', ');
}
});

if( array.some( args.locations || [], function(l) { return l.label; }) ) {
columns.unshift( { label: 'Name', field: 'label' } );
}
Expand Down

0 comments on commit 78365cd

Please sign in to comment.