diff --git a/bin/generate-names.pl b/bin/generate-names.pl index 0cb2cd903c..1b6f34ebe4 100755 --- a/bin/generate-names.pl +++ b/bin/generate-names.pl @@ -211,7 +211,7 @@ =head1 OPTIONS } # store the list of tracks that have names -$nameStore->set( 'JBROWSE_TRACKS_WITH_NAMES', \@tracksWithNames ); +$nameStore->{meta}{track_names} = \@tracksWithNames; # set up the name store in the trackList.json $gdb->modifyTrackList( sub { diff --git a/src/JBrowse/Browser.js b/src/JBrowse/Browser.js index a4439f110a..28d69ae2ef 100644 --- a/src/JBrowse/Browser.js +++ b/src/JBrowse/Browser.js @@ -1290,6 +1290,11 @@ Browser.prototype.showRegion = function( location ) { start: location.start - flank, end: location.end + flank }); + + // if the location has a track associated with it, show it + if( location.tracks ) { + this.showTracks( location.tracks ); + } }; /** @@ -1398,7 +1403,7 @@ Browser.prototype.navigateToLocation = function( location ) { * view location to any that match. */ Browser.prototype.searchNames = function( /**String*/ loc ) { - var brwsr = this; + var thisB = this; this.nameStore.query({ name: loc }) .then( function( nameMatches ) { @@ -1435,16 +1440,13 @@ Browser.prototype.searchNames = function( /**String*/ loc ) { if( goingTo.location ) { //go to location, with some flanking region - brwsr.showRegion( goingTo.location ); - - // var tracks = (brwsr.names.extra||{})[goingTo][ post1_4 ? 1 : 0 ]]; - // brwsr.showTracks(brwsr.names.extra[goingTo][ post1_4 ? 1 : 0 ]]); + thisB.showRegion( goingTo.location ); } // otherwise, pop up a dialog with a list of the locations to choose from else if( goingTo.multipleLocations ) { new LocationChoiceDialog( { - browser: brwsr, + browser: thisB, locationChoices: goingTo.multipleLocations, title: 'Choose '+goingTo.name+' location', prompt: '"'+goingTo.name+'" is found in multiple locations. Please choose a location to view.' diff --git a/src/JBrowse/Model/Location.js b/src/JBrowse/Model/Location.js index 3921ff025f..e1191d556e 100644 --- a/src/JBrowse/Model/Location.js +++ b/src/JBrowse/Model/Location.js @@ -13,6 +13,7 @@ return Util.fastDeclare( this.start = args.start; this.end = args.end; this.strand = args.strand; + this.tracks = args.tracks; } }, toString: function() { diff --git a/src/JBrowse/Store/Names/Hash.js b/src/JBrowse/Store/Names/Hash.js index bb8b715473..98470048b5 100644 --- a/src/JBrowse/Store/Names/Hash.js +++ b/src/JBrowse/Store/Names/Hash.js @@ -52,7 +52,8 @@ return declare( HashStore, item.location = new Location({ ref: nameRecord[3], start: parseInt( nameRecord[4] ), - end: parseInt( nameRecord[5] ) + end: parseInt( nameRecord[5] ), + tracks: [ (this.track_names||{})[ nameRecord[1] ] ] }); } else { item.name = nameRecord; diff --git a/src/perl5/Bio/JBrowse/HashStore.pm b/src/perl5/Bio/JBrowse/HashStore.pm index 492ba0d488..b897de9e94 100644 --- a/src/perl5/Bio/JBrowse/HashStore.pm +++ b/src/perl5/Bio/JBrowse/HashStore.pm @@ -76,7 +76,8 @@ sub DESTROY { CORE::open my $out, '>', $meta_path or die "$! writing $meta_path"; $out->print( JSON::to_json( { - hash_bits => $self->{hash_bits} + hash_bits => $self->{hash_bits}, + %{ $self->{meta} || {} } } )) or die "$! writing $meta_path"; }