Skip to content

Commit

Permalink
display autocomplete name completions in the original case. to do thi…
Browse files Browse the repository at this point in the history
…s, needed to add a copy of the name in the original case to the name records in the lazy trie
  • Loading branch information
rbuels committed Jun 1, 2012
1 parent 128f5ac commit 40facbd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 31 deletions.
5 changes: 3 additions & 2 deletions bin/generate-names.pl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ =head1 OPTIONS
my @namearray;

foreach my $ref (@refSeqs) {
push @{$nameHash{lc $ref->{name}}}, [@{$ref}{ qw/length name seqDir start end seqChunkSize/ }];
push @{$nameHash{lc $ref->{name}}}, [ @{$ref}{ qw/ name length name seqDir start end seqChunkSize/ }];
foreach my $track (@tracks) {
my $infile = catfile( $outDir,
"tracks",
Expand All @@ -125,7 +125,8 @@ =head1 OPTIONS
push @tracksWithNames, $track;
}

push @{$nameHash{lc $alias}}, [ $trackHash{$track},
push @{$nameHash{lc $alias}}, [ $alias,
$trackHash{$track},
@{$nameinfo}[2..$#{$nameinfo}]];
}
}
Expand Down
12 changes: 6 additions & 6 deletions js/Browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,26 +694,26 @@ Browser.prototype.searchNames = function( /**String*/ loc ) {

//first check for exact case match
for (i = 0; i < nameMatches.length; i++) {
if (nameMatches[i][1] == loc)
if (nameMatches[i][0] == loc)
goingTo = nameMatches[i];
}
//if no exact case match, try a case-insentitive match
if (!goingTo) {
for (i = 0; i < nameMatches.length; i++) {
if (nameMatches[i][1].toLowerCase() == loc.toLowerCase())
if (nameMatches[i][0].toLowerCase() == loc.toLowerCase())
goingTo = nameMatches[i];
}
}
//else just pick a match
if (!goingTo) goingTo = nameMatches[0];
var startbp = parseInt(goingTo[3]);
var endbp = parseInt(goingTo[4]);
var startbp = parseInt(goingTo[4]);
var endbp = parseInt(goingTo[5]);
var flank = Math.round((endbp - startbp) * .2);
//go to location, with some flanking region
brwsr.navigateTo(goingTo[2]
brwsr.navigateTo(goingTo[3]
+ ":" + (startbp - flank)
+ ".." + (endbp + flank));
brwsr.showTracks(brwsr.names.extra[nameMatches[0][0]]);
brwsr.showTracks(brwsr.names.extra[nameMatches[0][1]]);
});
};

Expand Down
23 changes: 5 additions & 18 deletions js/LazyPatricia.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ function LazyTrie(rootURL, chunkTempl) {
this.rootURL = rootURL;
this.chunkTempl = chunkTempl;
var trie = this;
this.storeArray = [];

dojo.xhrGet({url: rootURL,
handleAs: "json",
Expand Down Expand Up @@ -110,34 +109,22 @@ LazyTrie.prototype.valuesFromPrefix = function(query, callback) {

LazyTrie.prototype.mappingsFromPrefix = function(query, callback) {
var trie = this;
this.storeArray = []; //resets option list everytime input changes
this.findNode(query, function(prefix, node) {
callback(trie.mappingsFromNode(prefix, node));
});
};

// default max number of options are 100
// storeArray is to limit the length
LazyTrie.prototype.mappingsFromNode = function(prefix, node) {
var results = [];
var trie = this;
var lazy;

if (node[1] !== null) {
//results.push([prefix, node[1]]);
this.storeArray.push([prefix, node[1]]);
}
if (node[1] !== null)
results.push([prefix, node[1]]);
for (var i = 2; i < node.length; i++) {
if ("string" == typeof node[i][0]) {
results = results.concat(this.mappingsFromNode(prefix + node[i][0],
node[i]));
} else if ("number" == typeof node[i][0]) {
//if node[i][0] == number -> lazy node : load it!
lazy = prefix+node[i][1];
trie.storeArray.push([node[i][0], lazy]);
};
};
return trie.storeArray;
}
}
return results;
};

LazyTrie.prototype.valuesFromNode = function(node) {
Expand Down
6 changes: 1 addition & 5 deletions js/Model/AutocompleteStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ dojo.declare( 'JBrowse.Model.AutocompleteStore', null,
// use dojo.some so that we can break out of the loop when we hit the limit
dojo.some( tree, function(node) {
if( matchesRemaining-- ) {
if( typeof node[0] == 'number' ) {
matches.push({ name: node[0] + " options for " + node[1] });
} else {
matches.push({ name: node[0] });
}
matches.push({ name: node[1][0][0] });
}
return matchesRemaining < 0;
});
Expand Down

0 comments on commit 40facbd

Please sign in to comment.