function disableJsMessage(){ var javascriptMessage = document.getElementById("jsmessage"); if (javascriptMessage != null){ var parent = javascriptMessage.parentNode; parent.removeChild(javascriptMessage); } } function generateBlastWindow(){ var blastWindow = window.open("","BlastResult","height=600,width=900,scrollbars=yes,resizable=yes"); blastWindow.document.write("
The result of your BLAST query will appear in this window.
"); blastWindow.document.write(""); blastWindow.document.close(); blastWindow.focus(); } //Signals whether the user has confirmed the query type by clicking the radio buttons. var validated = "false"; function validateBlast(thisform){ with (thisform){ var jsenabled = document.getElementById("jsenabled"); jsenabled.value = "Y";//tell BlastOutputGenerator not to re-validate var ds = document.getElementById("dataset"); if (ds.options[ds.selectedIndex].value == "default"){ alert("Please select a dataset."); return false; } var query = sequence.value; //get the user's query from the textarea query = trim(query); if (query.length > 50000){ alert("The sequence can have only 50,000 characters."); return false; } if ((query.length == 0) && ((upfile.value == ""))){ alert("Please enter a query or select a file to upload."); return false; } if (isIllegalQuery(query)) { return false; } else { if (validated == "true"){//user set the querytype generateBlastWindow(); validated = "false"; //toggle for next submission return true; } else{ var isKnownQueryType = setQueryType(query); if (isKnownQueryType){; generateBlastWindow(); return true; } else{ return false; } } } } } // Removes leading whitespaces function LTrim( value ) { var re = /\s*((\S+\s*)*)/; return value.replace(re, "$1"); } // Removes ending whitespaces function RTrim( value ) { var re = /((\s*\S+)*)\s*/; return value.replace(re, "$1"); } // Removes leading and ending whitespaces function trim( value ) { return LTrim(RTrim(value)); } //Look for chars that are not allowed in a query function isIllegalQuery(query) { query = removeDefinitionLine(query); //Remove whitespace so that reIllegalChars will work query = query.replace(/[\s+]/g,""); var reIllegalChars = new RegExp("([^*abcdefghiklmnpqrstuvwxyz-])+","gim"); var matches = reIllegalChars.exec(query); if ((matches != null)) { alert("The character '" + matches[1] + "' is not allowed in the query."); return true; } return false; } function removeDefinitionLine(query) { //query should already be trimmed if (query.charAt(0) == '>') { var index = query.indexOf("\n"); query = query.substring(index + 1); } return query; } //Examines chars that are in the query, shows confirmation question when needed, //and sets value of the "querytype" radio button. //Returns true if the query type is known, either by examination or user confirmation. //Returns false if the query type must be confirmed by the user. function setQueryType(query) { var confirmationContainer = document.getElementById("confirmationContainer"); //var re = /[efilpqxz*]/gi; //Does it have chars that are allowed only in protein queries? var re = new RegExp("[efilpqxz*]","gim"); var matchProt = re.exec(query); if (query.match(re)) { //alert("protein"); var proteinRadio = document.getElementById("proteinRadio"); proteinRadio.click(); return true; } else { var reNucWildCards = new RegExp("[bdhkmrsvwy]","gim");//Does it have nuc wildcard chars? var matches = reNucWildCards.exec(query); var nucleotideRadio = document.getElementById("nucleotideRadio"); nucleotideRadio.click();//this is probably a nucleotide query if (matches == null) { //No nuc wildcards. //alert("nucleotide"); return true; } else { //Possible nucleotide query that has wildcard chars. //alert("Possible nucleotide"); if (validated == "false"){ //Ask the user to confirm by selecting the "querytype" radio buttons. showNucleotideQueryConfirmation(); validated = "true"; return false; } else { return true; } } } } //Displays a question that asks the user to confirm the type of query function showNucleotideQueryConfirmation(){ var confirmationContainer = document.getElementById("confirmationContainer"); var submitContainer = document.getElementById("submitContainer"); submitContainer.className = "hide"; confirmationContainer.className = "showAlert"; } //Hides the question that asks the user to confirm the type of query //and sets validated to "true" function hideNucleotideQueryConfirmation(){ var confirmationContainer = document.getElementById("confirmationContainer"); var submitContainer = document.getElementById("submitContainer"); submitContainer.className = "show"; confirmationContainer.className = "hide"; validated = "true"; } var myPlatform = "Macintosh"; var browser = "MSIE"; var userAgent = navigator.userAgent; if( userAgent.match("Netscape") ){ browser = "Netscape"; } else if ( userAgent.match("Safari") ){ browser = "Safari"; } else if ( userAgent.match("Firefox") ){ browser = "Firefox"; } else if ( userAgent.match("Opera") ){ browser = "Opera"; } else if ( userAgent.match("MSIE") ){ browser = "MSIE"; } else { browser = "Unknown"; } if( userAgent.match("Macintosh") ){ myPlatform = "Macintosh"; } else{ myPlatform = "Windows"; } var months = new Object(); months["JAN"] = 0; months["FEB"] = 1; months["MAR"] = 2; months["APR"] = 3; months["MAY"] = 4; months["JUN"] = 5; months["JUL"] = 6; months["AUG"] = 7; months["SEP"] = 8; months["OCT"] = 9; months["NOV"] = 10; months["DEC"] = 11; var thisYear = (new Date()).getFullYear(); var thisMonth = (new Date()).getMonth(); var lastYear = thisYear - 1; var startYear = thisYear; if(startMonth > thisMonth){ startYear = lastYear; } var baseStartTime = (new Date(startYear,startMonth)).getTime(); var currentTime = (new Date()).getTime(); var count = seqCountAtStart + Math.ceil(((currentTime - startTime)/1000) * seqPerSec); var freq = 1000/seqPerSec; var baseCount = baseCountAtStart + Math.ceil(((currentTime - baseStartTime)/1000) * basePerSec); var baseFreq = 1000/basePerSec; var numDivs = 9; var digit; var delay = 1; function addCommas(num){ var delimiter = ","; var strNum = new String(num); var arrayNum = []; while(strNum.length > 3) { var nn = strNum.substr(strNum.length - 3); arrayNum.unshift(nn); strNum = strNum.substr(0,strNum.length - 3); } if(strNum.length > 0) { arrayNum.unshift(strNum); } strNum = arrayNum.join(delimiter); return strNum; } function countSequences(){ count++; var numberToDisplay = count; for( var i=(numDivs - 1); i>=0; i-- ){ digit = numberToDisplay % 10; fillDiv(i,digit); numberToDisplay = Math.floor(numberToDisplay / 10); } } function fillDiv(index,num){ var id; id = "counter" + index; var counterDisplay = document.getElementById(id); if (counterDisplay.hasChildNodes()){ counterDisplay.removeChild(counterDisplay.childNodes[0]); } counterDisplay.appendChild(txtNode); } function countBases(){ baseCount++; var numberToDisplay = baseCount; numberToDisplay = addCommas(numberToDisplay); delay = 128; if( baseCount % delay == 0 ){ fillDivWithBases(numberToDisplay); } } function fillDivWithBases(num){ var id; id = "counter"; var txtNode = document.createTextNode(num); var counterDisplay = document.getElementById(id); if (counterDisplay != null){ if (counterDisplay.hasChildNodes()){ counterDisplay.removeChild(counterDisplay.childNodes[0]); } counterDisplay.appendChild(txtNode); } }