60d9b1d7e95db856ac2a31eb65d5e08f4e732f4e chmalee Fri May 19 10:08:08 2023 -0700 Add short DNA sequence recognition regex to hgSearch/hgGateway so users can paste short sequences into the search box and go right to hgBlat, same as on hgTracks, refs #31292 diff --git src/hg/js/hgGateway.js src/hg/js/hgGateway.js index a2dc94d..232316e 100644 --- src/hg/js/hgGateway.js +++ src/hg/js/hgGateway.js @@ -1550,31 +1550,41 @@ var sqlMatch = position.match(sqlRangeExp); var singleMatch = position.match(singleBaseExp); var positionMatch = canonMatch || gbrowserMatch || lengthMatch || bedMatch || sqlMatch || singleMatch; if (positionMatch !== null || goDirectlyToHgTracks) { // We already have a position from either selecting a suggestion or the user just typed a regular // old position, so go to hgTracks at that location // Show a spinner -- sometimes it takes a while for hgTracks to start displaying. $('.jwGoIcon').removeClass('fa-play').addClass('fa-spinner fa-spin'); // Make a form and submit it. In order for this to work in IE, the form // must be appended to the body. $('body').append($form); $form.submit(); } else { // User has entered a search term with no suggestion, go to the disambiguation // page so the user can choose a position - // but first check if just a plain chromosome name was entered: + // redirect to hgBlat if the input looks like a DNA sequence + // minimum length=19 so we do not accidentally redirect to hgBlat for a gene identifier + // like ATG5 + var dnaRe = new RegExp("^(>[^\n\r ]+[\n\r ]+)?(\\s*[actgnACTGN \n\r]{19,}\\s*)$"); + if (dnaRe.test(searchTerm)) { + var blatUrl = "hgBlat?type=BLAT%27s+guess&userSeq="+searchTerm; + window.location.href = blatUrl; + return false; + } + + // also check if just a plain chromosome name was entered: $('.jwGoIcon').removeClass('fa-play').addClass('fa-spinner fa-spin'); cmd = {getChromName: {'searchTerm': searchTerm, 'db': uiState.db}}; cart.send(cmd, onSuccess, onFail); cart.flush(); } cart.setCgi(oldCgi); } function replaceHgsidInLinks() { // Substitute '$hgsid' with real hgsid in <a> href's. $('a').each(function(ix, aEl) { var href = aEl.getAttribute('href'); if (href && href.indexOf('$hgsid') >= 0) { aEl.setAttribute('href', href.replace('$hgsid', window.hgsid)); }