flyui.namespace("flyui.apps.byexpressionprofile");flyui.apps.byexpressionprofile.CustomGeneFinderRenderer=function(){};flyui.apps.byexpressionprofile.CustomGeneFinderRenderer.prototype=new flyui.genefinder.DefaultRenderer();flyui.apps.byexpressionprofile.CustomGeneFinderRenderer.prototype._renderResultsSummary=function(D,C){var A="flyui.genefinder.DefaultRenderer.prototype._renderResultsSummary";try{if(D instanceof Array){flyui.debug("found array query",A);D=D.join(", ")}var B="found ";B+=C;B+=" matching <em>D. melanogaster</em> gene";B+=(C==0||C>1)?"s ":" ";B+="from <a href='http://flybase.org'>flybase.org</a> ("+flyui.flybase.provenance+") ...";this._resultsSummaryPane.innerHTML=B}catch(E){flyui.debug("caught "+E.name,", "+E.message,A);throw new flyui.UnexpectedException(A,E)}};flyui.apps.byexpressionprofile.Application=function(){var D=this;var A=null;var B=null;var E=null;var F=null;var C=null;var G=null;this.initQueryTable=function(){var I="<table><thead><tr>";for(var H=1;H<flyui.flyatlas.tissues.length;H++){var J=flyui.flyatlas.tissues[H];I+="<th>"+J+"</th>"}I+="</tr></thead><tbody><tr>";for(var H=1;H<flyui.flyatlas.tissues.length;H++){var J=flyui.flyatlas.tissues[H];I+='<td><select id="select_'+J+'_change"><option value="any">any</option><option value="Up">up</option><option selected="selected" value="Down">down</option><option value="None">none</option></select></td>'}I+="</tr></tbody></table>";$("#queryTableContainer").html(I)};this.initFlyatlasProfile=function(){var J="flyui.apps.byexpressionprofile.Application.initFlyatlasProfile";try{flyui.debug("instantiate a service for the flyatlas profile widget",J);var H=new flyui.flyatlas.Service();H.setEndpoint("../../../data/flyatlas");flyui.debug("instantiate a renderer for the batchgenefinder widget",J);var L=$("#flyatlasProfileWidget");var K=new flyui.flyatlas.ProfileWidget.DefaultRenderer();K.setCanvas(L);flyui.debug("instantiate a flyatlas profile widget",J);A=new flyui.flyatlas.ProfileWidget(H,K)}catch(I){flyui.apps.byexpressionprofile.handleError(I)}};this.initGeneFinder=function(){try{flyui.info("instantiate a service for the genefinder widget");var H=new flyui.flybase.Service("../../../data/flybase");flyui.info("instantiate a renderer for the genefinder widget");var K=document.getElementById("geneFinderWidget");var J=new flyui.apps.byexpressionprofile.CustomGeneFinderRenderer();J.setCanvas(K);flyui.info("instantiate a genefinder widget");B=new flyui.genefinder.Widget(H,J)}catch(I){flyui.apps.byexpressionprofile.handleError(I)}};this.initFlybasepub=function(){try{flyui.info("instantiate a service for the flybase publication widget");var H=new flyui.flybasepub.Service();H.setEndpoint("../../../data/flybase");flyui.info("instantiate a renderer for the flybase publication widget");var J=new flyui.flybasepub.PublicationWidget.SimpleRenderer();J.setCanvas($("#flybasepubPublicationWidget"));flyui.info("instantiate a flybase publication widget");G=new flyui.flybasepub.PublicationWidget(H,J)}catch(I){flyui.apps.publicationmashup.handleError(I)}};this.initFlyatlas=function(){try{flyui.info("instantiate a service for the flyatlas widget");var H=new flyui.flyatlas.Service();H.setEndpoint("../../../data/flyatlas");flyui.info("instantiate a renderer for the flyatlas widget");var J=new flyui.flyatlas.Widget.DefaultRenderer();J.setCanvas($("#flyatlasWidget"));flyui.info("instantiate a flyatlas widget");E=new flyui.flyatlas.Widget(H,J)}catch(I){flyui.apps.expressionmashup.handleError(I)}};this.initFlyted=function(){try{flyui.info("instantiate a service for the flyted image widget");var H=new flyui.flyted.Service("../../../data/flyted");flyui.info("instantiate a renderer for the flyted image widget");var K=document.getElementById("flytedImageWidget");var J=new flyui.flyted.ImageWidget.DefaultRenderer();J.setCanvas(K);flyui.info("instantiate a flyted image widget");F=new flyui.flyted.ImageWidget(H,J)}catch(I){flyui.apps.expressionmashup.handleError(I)}};this.initBdgp=function(){try{flyui.info("instantiate a service for the bdgp image widget");var H=new flyui.bdgp.Service("../../../data/bdgp");flyui.info("instantiate a renderer for the bdgp image widget");var K=document.getElementById("bdgpImageWidget");var J=new flyui.bdgp.ImageWidget.CompactRenderer();J.setCanvas(K);flyui.info("instantiate a bdgp image widget");C=new flyui.bdgp.ImageWidget(H,J)}catch(I){flyui.apps.expressionmashup.handleError(I)}};this.init=function(){var I="flyui.apps.byexpressionprofile.Application.init";try{var J=new YAHOO.widget.LogReader("logger");this.initQueryTable();this.initFlyatlasProfile();this.initGeneFinder();this.initFlyatlas();this.initFlyted();this.initBdgp();this.initFlybasepub();flyui.debug("hook form submission to widget call",I);YAHOO.util.Event.addListener("queryForm","submit",this.onFormSubmitted);flyui.debug("add listener for results received event",I);A.subscribe("RESULTSRECEIVED",this.onResultsReceived,null);B.subscribe("GENESELECTED",this.onGeneSelected,null);flyui.debug("application loaded, showing main pane",I);$("#loadingPane").hide();$("#applicationPane").show();D.initState()}catch(H){flyui.apps.byexpressionprofile.handleError(H)}};this.onFormSubmitted=function(H){var I="flyui.apps.byexpressionprofile.Application.onFormSubmitted";try{flyui.debug("form submitted",I);var J={};flyui.debug("build profile object",I);for(var M=1;M<flyui.flyatlas.tissues.length;M++){var L=flyui.flyatlas.tissues[M];var Q="select_"+L+"_change";var O=document.getElementById(Q);var P=O.value;flyui.debug("found value "+P+" for select "+Q,I);J[L]=P}D.setQueryState(J);var K=document.getElementById("queryLimit").value;D.doQuery(J,K)}catch(N){flyui.apps.byexpressionprofile.handleError(N)}};this.doQuery=function(K,H){var J="flyui.apps.byexpressionprofile.Application.doQuery";try{$("#errorMessage").hide().html("this should never be visible");$("#geneFinderWidget").hide();$("#flyatlasWidget").hide();$("#flytedImageWidget").hide();$("#bdgpImageWidget").hide();flyui.debug("initiate request for probes and genes by profile",J);flyui.debug("limit: "+H,J);A.getProbesAndGenesByExpressionProfile(K,H)}catch(I){flyui.apps.byexpressionprofile.handleError(I)}};this.setQueryState=function(L){var K="flyui.apps.byexpressionprofile.Application.setQueryState";try{var M="";for(var N in L){M+=N+":"+L[N]+"|"}var I=new String(window.location.href);var J=I.indexOf("#");if(J>0){I=I.substring(0,J)}window.location.href=I+"#query="+escape(M)}catch(H){flyui.apps.byexpressionprofile.handleError(H)}};this.initState=function(){var J="flyui.apps.byexpressionprofile.Application.initState";try{var H=new String(window.location.href);var I=H.indexOf("#query=");if(I>0){var O=H.length;var S=unescape(H.substring(I+7,O));flyui.info("found query: "+S);var L={};var N=S.split("|");for(var P=0;P<N.length;P++){var K=N[P];var R=K.split(":");if(R[0].length>0){L[R[0]]=R[1];var T="select_"+R[0]+"_change";flyui.debug(T,J);document.getElementById(T).value=R[1]}}var M=document.getElementById("queryLimit").value;D.doQuery(L,M)}}catch(Q){flyui.apps.byexpressionprofile.handleError(Q)}};this.onResultsReceived=function(K,I){try{flyui.debug("application: results received");var J=I[0];var L=J.genes;B.findGenesByAnyNameBatch(L);$("#geneFinderWidget").show()}catch(H){flyui.apps.byexpressionprofile.handleError(H)}};this.onGeneSelected=function(J,I){try{var K=I[0];flyui.info("gene selected: "+K+" "+K.flybaseID);E.getAssaysByGene(K);F.findImagesByGene(K);C.findImagesByGene(K);G.findPublicationsByGene(K);$("#flyatlasWidget").show();$("#flytedImageWidget").show();$("#bdgpImageWidget").show()}catch(H){flyui.apps.expressionmashup.handleError(H)}};this.init()};flyui.apps.byexpressionprofile.handleError=function(A){flyui.err(A.name+" :: "+A.message);$("#errorMessage").html("an error has occurred, please see the log for more details").show()};YAHOO.util.Event.onDOMReady(function(){new flyui.apps.byexpressionprofile.Application()})