if(typeof flyui=="undefined"||!flyui){function flyui(){}}flyui.namespace=function(){var A=arguments,E=null,C,B,D;for(C=0;C<A.length;C=C+1){D=A[C].split(".");E=flyui;for(B=(D[0]=="flyui")?1:0;B<D.length;B=B+1){E[D[B]]=E[D[B]]||{};E=E[D[B]]}}return E};flyui.log=function(C,B,A){if(typeof B=="undefined"){B="info"}if(typeof A!="undefined"){C=A+" :: "+C}YAHOO.log(C,B)};flyui.info=function(C,A){var B="info";flyui.log(C,B,A)};flyui.debug=function(C,A){var B="debug";flyui.log(C,B,A)};flyui.err=function(C,A){var B="error";flyui.log(C,B,A)};flyui.chain=function(B,A){return function(D){var C=B(D);A(C)}};flyui.UnexpectedException=function(A,C){this.name="flyui.UnexpectedException";this.nested=C;this.message=A+" :: unexpected error";for(var B in C){if(B!="message"){this.message+="\n      "+B+": "+C[B]}}if(C.message){this.message+="\n..."+C.message}};flyui.namespace("flyui.util");flyui.util.ArrayUtils=function(){};flyui.util.isArrayMember=function(C,B){for(var A in C){if(C[A]==B){return true}}return false};flyui.util.appendIfNotMember=function(B,A){if(!flyui.util.isArrayMember(B,A)){B[B.length]=A}};flyui.util.arrayMembersAreEqual=function(C,E){for(var D in C){if(!flyui.util.isArrayMember(E,C[D])){return false}}for(var D in E){if(!flyui.util.isArrayMember(C,E[D])){return false}}return true};flyui.namespace("flyui.mvcutils");flyui.mvcutils.GenericModel2=function(){};flyui.mvcutils.GenericModel2.prototype._state=null;flyui.mvcutils.GenericModel2.prototype._events=null;flyui.mvcutils.GenericModel2.prototype._properties=null;flyui.mvcutils.GenericModel2.prototype._values=null;flyui.mvcutils.GenericModel2.prototype.setDefinition=function(A){this._init(A)};flyui.mvcutils.GenericModel2.prototype._init=function(B){if(typeof B=="object"){if(typeof B.properties=="object"&&B.properties.length){this._properties=B.properties;this._events={};for(var A=0;A<this._properties.length;A++){var C=this._properties[A];this._events[C]=new YAHOO.util.CustomEvent(C,this)}}else{throw new flyui.mvcutils.GenericModel2.BadDefinition("definition must have 'properties' field with array value")}if(typeof B.values=="object"){this._values=B.values}else{throw new flyui.mvcutils.GenericModel2.BadDefinition("definition must have 'values' field with object value")}this._state={};if(typeof B.initialize=="function"){B.initialize(this._state)}else{throw new flyui.mvcutils.GenericModel2.BadDefinition("definition must have 'initialize' field with function value")}}else{throw new flyui.mvcutils.GenericModel2.BadDefinition("definition must be an object")}};flyui.mvcutils.GenericModel2.prototype.subscribe=function(B,A,C){this._validateProperty(B);this._events[B].subscribe(A,C)};flyui.mvcutils.GenericModel2.prototype.subscribeAll=function(C,D){for(var A=0;A<this._properties.length;A++){var B=this._properties[A];this.subscribe(B,C,D)}};flyui.mvcutils.GenericModel2.prototype.get=function(A){this._validateProperty(A);return this._state[A]};flyui.mvcutils.GenericModel2.prototype.getter=function(){var A=this;return function(B){return A.get(B)}};flyui.mvcutils.GenericModel2.prototype.set=function(A,C){this._validatePropertyValue(A,C);var B=this._state[A];this._state[A]=C;this._notify(A,B,C)};flyui.mvcutils.GenericModel2.prototype._validateProperty=function(C){var B=false;for(var A=0;A<this._properties.length;A++){if(this._properties[A]==C){B=true}}if(!B){throw new flyui.mvcutils.GenericModel2.BadPropertyName("bad property name: "+C)}};flyui.mvcutils.GenericModel2.prototype._validatePropertyValue=function(E,D){var C=false;this._validateProperty(E);var A=this._values[E];if(A){for(var B in A){if(D==A[B]){C=true}}}else{C=true}if(!C){throw new flyui.mvcutils.GenericModel2.BadPropertyValue("bad property value, property: "+E+", value: "+D)}};flyui.mvcutils.GenericModel2.prototype._notify=function(A,C,B){this._events[A].fire(C,B,this.getter())};flyui.mvcutils.GenericModel2.BadDefinition=function(A){this.name="flyui.mvcutils.GenericModel2.BadDefinition";this.message=A};flyui.mvcutils.GenericModel2.BadPropertyName=function(A){this.name="flyui.mvcutils.GenericModel2.BadPropertyName";this.message=A};flyui.mvcutils.GenericModel2.BadPropertyValue=function(A){this.name="flyui.mvcutils.GenericModel2.BadPropertyValue";this.message=A};flyui.namespace("flyui.mvcutils");flyui.mvcutils.show=function(A){YAHOO.util.Dom.removeClass(A,"invisible")};flyui.mvcutils.hide=function(A){YAHOO.util.Dom.addClass(A,"invisible")};flyui.namespace("flyui.sparql");flyui.sparql.Service=function(){};flyui.sparql.Service.prototype.setEndpoint=function(A){this._endpoint=A};flyui.sparql.Service.prototype._endpoint=null;flyui.sparql.Service.prototype.query=function(E,F,D){var A="flyui.sparql.Service.prototype.query";try{flyui.info("query: "+E,A);var G={success:F,failure:D};var C=this._endpoint+"?query="+escape(E)+"&output=json";YAHOO.util.Connect.initHeader("Accept","application/sparql-results+json",true);YAHOO.util.Connect.asyncRequest("GET",C,G)}catch(B){throw new flyui.UnexpectedException(A,B)}};flyui.sparql.Service.prototype.postQuery=function(F,G,D){var A="flyui.sparql.Service.prototype.postQuery";try{flyui.info("query: "+F,A);var H={success:G,failure:D};var C=this._endpoint;var E="query="+escape(F)+"&output=json";YAHOO.util.Connect.initHeader("Accept","application/sparql-results+json",true);YAHOO.util.Connect.asyncRequest("POST",C,H,E)}catch(B){throw new flyui.UnexpectedException(A,B)}};flyui.namespace("flyui.flybase");flyui.flybase.provenance="FB2009_02";flyui.flybase.Service=function(A){this._endpoint=A};flyui.flybase.Service.prototype=new flyui.sparql.Service();flyui.flybase.Service.prototype.findGenesByAnyName=function(B,G,D){var A="flyui.flybase.Service.prototype.findGenesByAnyName";try{flyui.info("request: "+B,A);var E=flyui.chain(flyui.flybase.Service.responseToGenes,G);var F=flyui.flybase.Service._buildQueryForFindGenesByAnyName(B);this.postQuery(F,E,D)}catch(C){throw new flyui.UnexpectedException(A,C)}};flyui.flybase.Service.responseToGenes=function(B){var A="flyui.flybase.Service.responseToGenes";try{var E=YAHOO.lang.JSON.parse(B.responseText);var D=flyui.flybase.Gene.newInstancesFromSPARQLResults(E);return D}catch(C){throw new flyui.UnexpectedException(A,C)}};flyui.flybase.Service.responseToGenesByMultiNamesMap=function(B){var A="flyui.flybase.Service.responseToGenesByMultiNamesMap";return function(D){try{var J=YAHOO.lang.JSON.parse(D.responseText);var C=J.results.bindings;var G=new flyui.flybase.GenePool();for(var F=0;F<C.length;F++){var I=C[F].flybaseID.value;var E=G.get(I);if(C[F].symbol){E.addSymbol(C[F].symbol.value)}if(C[F].annotationSymbol){E.addAnnotationSymbol(C[F].annotationSymbol.value)}if(C[F].fullName){E.addFullName(C[F].fullName.value)}if(C[F].synonym){E.addSynonym(C[F].synonym.value)}var K=C[F]["label"].value;flyui.util.appendIfNotMember(B[K],E)}return B}catch(H){throw new flyui.UnexpectedException(A,H)}}};flyui.flybase.Service.prototype.findGenesByAnyNameBatch=function(G,I,D){var B="flyui.flybase.Service.prototype.findGenesByAnyNameBatch";try{flyui.info("request: "+G.join(", "),B);if(G.length==0){I({})}else{var C={};for(var E=0;E<G.length;E++){C[G[E]]=[]}var A=flyui.chain(flyui.flybase.Service.responseToGenesByMultiNamesMap(C),I);var H=flyui.flybase.Service._buildQueryForFindGenesByAnyNameBatch(G);flyui.info("initiate sparql query",B);this.postQuery(H,A,D)}}catch(F){throw new flyui.UnexpectedException(B,F)}};flyui.flybase.Service._buildQueryForFindGenesByAnyName=function(C){var B="flyui.flybase.Service._buildQueryForFindGenesByAnyName";try{var F="PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\nPREFIX chado: <http://purl.org/net/chado/schema/>\nPREFIX skos: <http://www.w3.org/2004/02/skos/core#>\nPREFIX so: <http://purl.org/obo/owl/SO#>\nPREFIX syntype: <http://purl.org/net/flybase/synonym-types/>\n";var A='SELECT DISTINCT ?flybaseID ?symbol ?annotationSymbol ?fullName WHERE {\n  ?feature skos:altLabel "'+C+'" ;\n    a so:SO_0000704 ;\n    chado:organism <http://openflydata.org/id/flybase/organism/Drosophila_melanogaster> ;\n    chado:uniquename ?flybaseID ;\n    chado:name ?symbol ;\n    chado:feature_dbxref [\n      chado:accession ?annotationSymbol ;\n      chado:db <http://openflydata.org/id/flybase/db/FlyBase_Annotation_IDs>\n    ] .\n  OPTIONAL {\n    ?fs\n      chado:feature ?feature ;\n      chado:is_current "true"^^xsd:boolean ;\n      chado:synonym [\n        a syntype:FullName ;\n        chado:name ?fullName ;\n      ] ;\n    a chado:Feature_Synonym .\n  }\n  FILTER (regex(str(?annotationSymbol), "^CG[0-9]*$"))\n}';var E=F+A;return E}catch(D){throw new flyui.UnexpectedException(B,D)}};flyui.flybase.Service._buildQueryForFindGenesByAnyNameBatch=function(H){var A="flyui.flybase.Service._buildQueryForFindGenesByAnyName";try{var D="PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\nPREFIX chado: <http://purl.org/net/chado/schema/>\nPREFIX skos: <http://www.w3.org/2004/02/skos/core#>\nPREFIX so: <http://purl.org/obo/owl/SO#>\nPREFIX syntype: <http://purl.org/net/flybase/synonym-types/>\n";var B="SELECT DISTINCT ?label ?flybaseID ?symbol ?annotationSymbol ?fullName WHERE {\n";var J='  {\n    {\n      LET (?label := "'+H[0]+'")\n      ?feature skos:altLabel ?label .\n    }\n';for(var E=1;E<H.length;E++){J+='    UNION\n    {\n      LET (?label := "'+H[E]+'")\n      ?feature skos:altLabel ?label .\n    }\n'}J+="  }\n";var I='  {\n    ?feature\n      a so:SO_0000704 ;\n      chado:organism <http://openflydata.org/id/flybase/organism/Drosophila_melanogaster> ;\n      chado:uniquename ?flybaseID ;\n      chado:name ?symbol ;\n      chado:feature_dbxref [\n        chado:accession ?annotationSymbol ;\n        chado:db <http://openflydata.org/id/flybase/db/FlyBase_Annotation_IDs>\n      ] .\n    OPTIONAL {\n      ?fs\n        chado:feature ?feature ;\n        chado:is_current "true"^^xsd:boolean ;\n        chado:synonym [\n          a syntype:FullName ;\n          chado:name ?fullName ;\n        ] ;\n      a chado:Feature_Synonym .\n    }\n    FILTER (regex(str(?annotationSymbol), "^CG[0-9]*$"))\n  }\n';var C="}";var G=D+B+J+I+C;return G}catch(F){throw new flyui.UnexpectedException(A,F)}};flyui.flybase.Gene=function(){var A=this;this.flybaseID=null;this.symbols=new Array();this.annotationSymbols=new Array();this.fullNames=new Array();this.addSymbol=function(B){flyui.util.appendIfNotMember(A.symbols,B)};this.addAnnotationSymbol=function(B){flyui.util.appendIfNotMember(A.annotationSymbols,B)};this.addFullName=function(B){flyui.util.appendIfNotMember(A.fullNames,B)}};flyui.flybase.Gene.newInstancesFromSPARQLResults=function(F){var A="flyui.flybase.Gene.newInstancesFromSPARQLResults";try{var E=new flyui.flybase.GenePool();var H=F.results.bindings;for(var D in H){var B=H[D].flybaseID.value;var G=E.get(B);if(H[D].symbol){G.addSymbol(H[D].symbol.value)}if(H[D].annotationSymbol){G.addAnnotationSymbol(H[D].annotationSymbol.value)}if(H[D].fullName){G.addFullName(H[D].fullName.value)}}return E.toArray()}catch(C){throw new flyui.UnexpectedException(A,C)}};flyui.flybase.GenePool=function(){this._pool=new Object()};flyui.flybase.GenePool.prototype.get=function(B){var A="flyui.flybase.GenePool.prototype.get";try{var D=this._pool[B];if(typeof D=="undefined"||!D){D=new flyui.flybase.Gene();D.flybaseID=B;this._pool[B]=D}return D}catch(C){throw new flyui.UnexpectedException(A,C)}};flyui.flybase.GenePool.prototype.toArray=function(){var B="flyui.flybase.GenePool.prototype.toArray";try{var E=new Array();for(var D in this._pool){E[E.length]=this._pool[D]}function A(F,G){if(F.symbols[0]>G.symbols[0]){return 1}else{return -1}}E.sort(A);return E}catch(C){throw new flyui.UnexpectedException(B,C)}};flyui.namespace("flyui.genefinder");flyui.genefinder.Widget=function(A,B){this._Widget(A,B)};flyui.genefinder.Widget.prototype._controller=null;flyui.genefinder.Widget.prototype._model=null;flyui.genefinder.Widget.prototype._renderer=null;flyui.genefinder.Widget.prototype._service=null;flyui.genefinder.Widget.prototype._geneSelectedEvent=null;flyui.genefinder.Widget.prototype._genesFoundEvent=null;flyui.genefinder.Widget.prototype._Widget=function(A,C){var B="flyui.genefinder.Widget.prototype._Widget";try{this._service=A;this._renderer=C;this._geneSelectedEvent=new YAHOO.util.CustomEvent("GENESELECTED",this);this._genesFoundEvent=new YAHOO.util.CustomEvent("GENESFOUND",this);this._model=new flyui.mvcutils.GenericModel2();this._model.setDefinition(flyui.genefinder.modelDefinition);this._controller=new flyui.genefinder.Controller(this._model,A,this);this._renderer.connect(this._model);this._renderer.setUserEventHandler(new flyui.genefinder.UserEventHandler(this._controller))}catch(D){throw new flyui.UnexpectedException(B,D)}};flyui.genefinder.Widget.prototype.subscribe=function(B,C,E){var A="flyui.genefinder.Widget.prototype.subscribe";try{if(B=="GENESELECTED"){this._geneSelectedEvent.subscribe(C,E)}else{if(B=="GENESFOUND"){this._genesFoundEvent.subscribe(C,E)}}}catch(D){throw new flyui.UnexpectedException(A,D)}};flyui.genefinder.Widget.prototype.findGenesByAnyName=function(B){var A="flyui.genefinder.Widget.prototype.findGenesByAnyName";try{this._controller.findGenesByAnyName(B)}catch(C){throw new flyui.UnexpectedException(A,C)}};flyui.genefinder.Widget.prototype.findGenesByAnyNameBatch=function(C){var A="flyui.genefinder.Widget.prototype.findGenesByAnyNameBatch";try{this._controller.findGenesByAnyNameBatch(C)}catch(B){throw new flyui.UnexpectedException(A,B)}};flyui.genefinder.Widget.prototype.setSelectionIndex=function(B){var A="flyui.genefinder.Widget.prototype.setSelectionIndex";try{this._controller.setSelectionIndex(B)}catch(C){throw new flyui.UnexpectedException(A,C)}};flyui.genefinder.UserEventHandler=function(A){this._onResultClicked=function(D,C){var B="flyui.genefinder.UserEventHandler this._onResultClicked";try{flyui.info("received click event, call the controller to set selection: "+C,B);A.setSelectionIndex(C)}catch(E){throw new flyui.UnexpectedException(B,E)}}};flyui.genefinder.Controller=function(B,A,D){var C=this;this._model=B;this._service=A;this._parent=D;this._findGenesByAnyNameSuccess=function(G){var F="flyui.genefinder.Controller this._findGenesByAnyNameSuccess";try{flyui.info("request success",F);C._model.set("RESULTS",G);C._model.set("STATE","READY");flyui.info("firing GENESFOUND event",F);var E=C._parent._genesFoundEvent;E.fire(G);if(G.length==1){C.setSelectionIndex(0)}}catch(H){throw new flyui.UnexpectedException(F,H)}};this._findGenesByAnyNameBatchSuccess=function(K){var F="flyui.genefinder.Controller this._findGenesByAnyNameBatchSuccess";try{flyui.info("request success",F);var G=[];for(key in K){var I=K[key];for(var H=0;H<I.length;H++){G[G.length]=I[H]}}function E(L,M){if(L.symbols[0]>M.symbols[0]){return 1}else{return -1}}G.sort(E);C._findGenesByAnyNameSuccess(G)}catch(J){throw new flyui.UnexpectedException(F,J)}};this._findGenesByAnyNameFailure=function(F){var E="flyui.genefinder.Controller this._findGenesByAnyNameFailure";try{flyui.err("request failed, status "+F.status+" "+F.statusText+" "+F.responseText,E);var H="There was an error retrieving data from FlyBase, see the logs for more info. The server may be busy or down, please try again later. If this message persists, please contact the Image Bioinformatics Research Group at bioimage@mail.ontonet.org.";C._model.set("ERRORMESSAGE",H);C._model.set("STATE","SERVERERROR")}catch(G){throw new flyui.UnexpectedException(E,G)}}};flyui.genefinder.Controller.prototype.findGenesByAnyName=function(B){var A="flyui.genefinder.Controller.prototype.findGenesByAnyName";try{flyui.info("findGenesByAnyName: "+B,A);this._findGenesByAnyName(B,this._findGenesByAnyNameSuccess,this._findGenesByAnyNameFailure)}catch(C){throw new flyui.UnexpectedException(A,C)}};flyui.genefinder.Controller.prototype.findGenesByAnyNameBatch=function(C){var A="flyui.genefinder.Controller.prototype.findGenesByAnyNameBatch";try{flyui.info("findGenesByAnyNameBatch: "+C,A);this._findGenesByAnyNameBatch(C,this._findGenesByAnyNameBatchSuccess,this._findGenesByAnyNameFailure)}catch(B){throw new flyui.UnexpectedException(A,B)}};flyui.genefinder.Controller.prototype._findGenesByAnyName=function(B,E,C){var A="flyui.genefinder.Controller.prototype._findGenesByAnyName";try{this._model.set("STATE","PENDING");this._model.set("QUERY",B);this._service.findGenesByAnyName(B,E,C)}catch(D){throw new flyui.UnexpectedException(A,D)}};flyui.genefinder.Controller.prototype._findGenesByAnyNameBatch=function(D,E,B){var A="flyui.genefinder.Controller.prototype._findGenesByAnyName";try{this._model.set("STATE","PENDING");this._model.set("QUERY",D);this._service.findGenesByAnyNameBatch(D,E,B)}catch(C){throw new flyui.UnexpectedException(A,C)}};flyui.genefinder.Controller.prototype.setSelectionIndex=function(B){var A="flyui.genefinder.Controller.prototype.setSelectionIndex";var D=false;try{var C=this._model.get("RESULTS");if(C!=null){if(B>=0&&B<C.length){this._model.set("SELECTIONINDEX",B);var E=this._parent._geneSelectedEvent;E.fire(C[B])}else{D=true}}}catch(F){throw new flyui.UnexpectedException(A,F)}if(D){throw new flyui.genefinder.SelectionOutOfBounds("index "+B+" cannot apply to results length "+C.length)}};flyui.genefinder.SelectionOutOfBounds=function(A){this.name="flyui.genefinder.SelectionOutOfBounds";this.message=A};flyui.genefinder.DefaultRenderer=function(){};flyui.genefinder.DefaultRenderer.prototype._canvas=null;flyui.genefinder.DefaultRenderer.prototype._pendingPane=null;flyui.genefinder.DefaultRenderer.prototype._resultsSummaryPane=null;flyui.genefinder.DefaultRenderer.prototype._resultsPane=null;flyui.genefinder.DefaultRenderer.prototype._messagePane=null;flyui.genefinder.DefaultRenderer.prototype._userEventHandler=null;flyui.genefinder.DefaultRenderer.prototype.setCanvas=function(A){this._canvas=A;this._initCanvas()};flyui.genefinder.DefaultRenderer.prototype.setUserEventHandler=function(A){this._userEventHandler=A};flyui.genefinder.DefaultRenderer.prototype._initCanvas=function(){var A="flyui.genefinder.DefaultRenderer.prototype._initCanvas";try{YAHOO.util.Dom.addClass(this._canvas,"genefinderWidget");this._pendingPane=document.createElement("p");this._pendingPane.innerHTML="pending...";this._canvas.appendChild(this._pendingPane);YAHOO.util.Dom.addClass(this._pendingPane,"pendingPane");flyui.mvcutils.hide(this._pendingPane);this._resultsSummaryPane=document.createElement("p");this._resultsSummaryPane.innerHTML="this should never be displayed";this._canvas.appendChild(this._resultsSummaryPane);YAHOO.util.Dom.addClass(this._resultsSummaryPane,"resultsSummaryPane");flyui.mvcutils.hide(this._resultsSummaryPane);this._resultsPane=document.createElement("div");this._canvas.appendChild(this._resultsPane);YAHOO.util.Dom.addClass(this._resultsPane,"resultsPane");flyui.mvcutils.hide(this._resultsPane);this._messagePane=document.createElement("p");this._messagePane.innerHTML="this should never be displayed";this._canvas.appendChild(this._messagePane);YAHOO.util.Dom.addClass(this._messagePane,"messagePane");flyui.mvcutils.hide(this._messagePane)}catch(B){throw new flyui.UnexpectedException(A,B)}};flyui.genefinder.DefaultRenderer.prototype._onStateChanged=function(D,C){var A="flyui.genefinder.DefaultRenderer.prototype._onStateChanged";try{if(C=="PENDING"){flyui.mvcutils.show(this._pendingPane);flyui.mvcutils.hide(this._messagePane);flyui.mvcutils.hide(this._resultsSummaryPane);flyui.mvcutils.hide(this._resultsPane)}else{if(C=="READY"){flyui.mvcutils.hide(this._pendingPane);flyui.mvcutils.show(this._messagePane);flyui.mvcutils.show(this._resultsSummaryPane);flyui.mvcutils.show(this._resultsPane)}else{if(C=="SERVERERROR"||C=="UNEXPECTEDERROR"){flyui.mvcutils.hide(this._pendingPane);flyui.mvcutils.show(this._messagePane);flyui.mvcutils.hide(this._resultsSummaryPane);flyui.mvcutils.hide(this._resultsPane)}else{throw {message:"unexpected state: "+C}}}}}catch(B){throw new flyui.UnexpectedException(A,B)}};flyui.genefinder.DefaultRenderer.prototype._onQueryChanged=function(B,A){this._query=A};flyui.genefinder.DefaultRenderer.prototype._onResultsChanged=function(E,D){var A="flyui.genefinder.DefaultRenderer.prototype._onResultsChanged";try{this._results=D;this._renderResultsSummary(this._query,D.length);if(D.length>0){this._resultsPane.innerHTML="";var B=this._renderResults(D);this._resultsPane.appendChild(B);this._renderGeneSelectionMessage(null)}else{this._resultsPane.innerHTML="";this._messagePane.innerHTML=""}}catch(C){throw new flyui.UnexpectedException(A,C)}};flyui.genefinder.DefaultRenderer.prototype._onSelectionIndexChanged=function(F,E){var A="flyui.genefinder.DefaultRenderer.prototype._onSelectionIndexChanged";try{var B=this._getResultNodes();if(F!=null){YAHOO.util.Dom.removeClass(B[F+1],"selected")}if(E!=null){flyui.info("adding selected class to node: "+B[E+1]+"debug",A);YAHOO.util.Dom.addClass(B[E+1],"selected");var D=this._results[E];this._renderGeneSelectionMessage(D)}}catch(C){throw new flyui.UnexpectedException(A,C)}};flyui.genefinder.DefaultRenderer.prototype._getResultNodes=function(){return this._resultsPane.getElementsByTagName("tr")};flyui.genefinder.DefaultRenderer.prototype._onErrorMessageChanged=function(B,A){this._messagePane.innerHTML=A};flyui.genefinder.DefaultRenderer.prototype._onModelChanged=function(F,D,C){var A="flyui.genefinder.DefaultRenderer.prototype._onModelChanged";try{var B={"STATE":"_onStateChanged","QUERY":"_onQueryChanged","RESULTS":"_onResultsChanged","ERRORMESSAGE":"_onErrorMessageChanged","SELECTIONINDEX":"_onSelectionIndexChanged"};var E=B[F];C[E](D[0],D[1])}catch(G){throw new flyui.UnexpectedException(A,G)}};flyui.genefinder.DefaultRenderer.prototype.connect=function(B){var A="flyui.genefinder.DefaultRenderer.prototype.connect";try{B.subscribeAll(this._onModelChanged,this)}catch(C){throw new flyui.UnexpectedException(A,C)}};flyui.genefinder.DefaultRenderer.renderDomElementFromList=function(G,E,F){var A="flyui.genefinder.DefaultRenderer.renderDomElementFromList";try{var B=document.createElement(G);for(var D=0;D<F.length;D++){var C=document.createElement(E);C.innerHTML=F[D];B.appendChild(C)}return B}catch(H){throw new flyui.UnexpectedException(A,H)}};flyui.genefinder.DefaultRenderer.prototype._renderResultsSummary=function(D,C){var A="flyui.genefinder.DefaultRenderer.prototype._renderResultsSummary";try{if(D instanceof Array){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+") for query '"+D+"' ...";this._resultsSummaryPane.innerHTML=B}catch(E){throw new flyui.UnexpectedException(A,E)}};flyui.genefinder.DefaultRenderer.prototype._renderResults=function(F){var A="flyui.genefinder.DefaultRenderer.prototype._renderResults";try{var J=document.createElement("table");var I=document.createElement("thead");var E=document.createElement("tbody");J.appendChild(I);J.appendChild(E);var B=["symbol","full name","annotation ID","flybase ID","user selection"];var G=flyui.genefinder.DefaultRenderer.renderDomElementFromList("tr","th",B);I.appendChild(G);for(var D=0;D<F.length;D++){var C=this._geneToTableCellContents(F[D]);var K=flyui.genefinder.DefaultRenderer.renderDomElementFromList("tr","td",C);E.appendChild(K);YAHOO.util.Event.addListener(K,"click",this._userEventHandler._onResultClicked,D)}return J}catch(H){throw new flyui.UnexpectedException(A,H)}};flyui.genefinder.DefaultRenderer.prototype._geneToTableCellContents=function(C){var A="flyui.genefinder.DefaultRenderer.prototype._geneToTableCellContents";try{return[C.symbols.join(" / "),C.fullNames.join(" / "),C.annotationSymbols.join(" / "),C.flybaseID,"<span class='selector'>[<a href='javascript:void(0)'>select this gene</a>]</span><span class='isselected'>selected</span>"]}catch(B){throw new flyui.UnexpectedException(A,B)}};flyui.genefinder.DefaultRenderer.prototype._renderGeneSelectionMessage=function(C){var A="flyui.genefinder.DefaultRenderer.prototype._renderGeneSelectionMessage";try{if(C==null){this._messagePane.innerHTML="selected gene: <strong>please select one of the genes from the list above, or try another query</strong>"}else{this._messagePane.innerHTML="selected gene: <strong>"+C.symbols.join(" / ")+"</strong> (FlyBase report: <a href='http://flybase.org/reports/"+C.flybaseID+".html'>"+C.flybaseID+"</a>)"}}catch(B){throw new flyui.UnexpectedException(A,B)}};flyui.genefinder.modelDefinition={properties:["STATE","RESULTS","ERRORMESSAGE","QUERY","SELECTIONINDEX"],values:{"STATE":["READY","PENDING","SERVERERROR","UNEXPECTEDERROR"]},initialize:function(A){A["STATE"]="READY";A["RESULTS"]=null;A["ERRORMESSAGE"]=null;A["QUERY"]=null;A["SELECTIONINDEX"]=null}};flyui.namespace("flyui.genefinder");flyui.genefinder.BatchWidget=function(A,D){var B="flyui.genefinder.BatchWidget";try{this.__init__(A,D)}catch(C){throw C}};flyui.genefinder.BatchWidget.prototype._controller=null;flyui.genefinder.BatchWidget.prototype._model=null;flyui.genefinder.BatchWidget.prototype._renderer=null;flyui.genefinder.BatchWidget.prototype._service=null;flyui.genefinder.BatchWidget.prototype._genesFoundEvent=null;flyui.genefinder.BatchWidget.prototype.__init__=function(A,D){var B="flyui.genefinder.BatchWidget.prototype.__init__";try{this._service=A;this._renderer=D;this._genesFoundEvent=new YAHOO.util.CustomEvent("GENESFOUND",this);this._model=new flyui.mvcutils.GenericModel2();this._model.setDefinition(flyui.genefinder.BatchWidget.modelDefinition);this._controller=new flyui.genefinder.BatchWidget.Controller(this._model,A,this);this._renderer.connect(this._model)}catch(C){throw C}};flyui.genefinder.BatchWidget.prototype.subscribe=function(C,D,E){var A="flyui.genefinder.BatchWidget.prototype.subscribe";try{if(C=="GENESFOUND"){this._genesFoundEvent.subscribe(D,E)}}catch(B){throw B}};flyui.genefinder.BatchWidget.prototype.findGenesByAnyNameBatch=function(C){var A="flyui.genefinder.BatchWidget.prototype.findGenesByAnyNameBatch";try{this._controller.findGenesByAnyNameBatch(C)}catch(B){throw B}};flyui.genefinder.BatchWidget.Controller=function(E,A,D){var B="flyui.genefinder.BatchWidget.Controller";try{this._model=null;this._service=null;this._controllee=null;this.__init__(E,A,D)}catch(C){throw C}};flyui.genefinder.BatchWidget.Controller.prototype.__init__=function(E,A,D){var B="flyui.genefinder.BatchWidget.Controller.prototype.__init__";try{this._model=E;this._service=A;this._controllee=D}catch(C){throw C}};flyui.genefinder.BatchWidget.Controller.prototype.findGenesByAnyNameBatch=function(C){var A="flyui.genefinder.BatchWidget.Controller.prototype.findGenesByAnyNameBatch";try{flyui.info("findGenesByAnyNameBatch: "+C,A);this._findGenesByAnyNameBatch(C,this._findGenesByAnyNameBatchSuccess(),this._findGenesByAnyNameBatchFailure())}catch(B){throw B}};flyui.genefinder.BatchWidget.Controller.prototype._findGenesByAnyNameBatch=function(D,E,C){var A="flyui.genefinder.BatchWidget.Controller.prototype._findGenesByAnyNameBatch";try{this._model.set("STATE","PENDING");this._model.set("QUERY",D);this._model.set("RESULTS",null);this._model.set("MESSAGE",null);this._service.findGenesByAnyNameBatch(D,E,C)}catch(B){throw B}};flyui.genefinder.BatchWidget.Controller.prototype._findGenesByAnyNameBatchSuccess=function(){var A="flyui.genefinder.BatchWidget.Controller.prototype._findGenesByAnyNameBatchSuccess";var B=this;return function(D){try{flyui.info("request success",A);B._model.set("RESULTS",D);B._model.set("STATE","READY");B._controllee._genesFoundEvent.fire(B._model.get("QUERY"),D)}catch(C){throw C}}};flyui.genefinder.BatchWidget.Controller.prototype._findGenesByAnyNameBatchFailure=function(){var A="flyui.genefinder.BatchWidget.Controller.prototype._findGenesByAnyNameBatchFailure";var B=this;return function(C){try{flyui.err("request failed: "+C.status+" "+C.statusText,A);B._model.set("MESSAGE","there was an error retrieving data from the server, see the logs for more info");B._model.set("STATE","SERVERERROR")}catch(D){throw D}}};flyui.genefinder.BatchWidget.modelDefinition={properties:["STATE","RESULTS","MESSAGE","QUERY"],values:{"STATE":["READY","PENDING","SERVERERROR","UNEXPECTEDERROR"]},initialize:function(A){A["STATE"]="READY";A["RESULTS"]=null;A["MESSAGE"]=null;A["QUERY"]=null}};flyui.genefinder.BatchWidget.DefaultRenderer=function(){};flyui.genefinder.BatchWidget.DefaultRenderer.prototype._canvas=null;flyui.genefinder.BatchWidget.DefaultRenderer.prototype._pendingPane=null;flyui.genefinder.BatchWidget.DefaultRenderer.prototype._resultsSummaryPane=null;flyui.genefinder.BatchWidget.DefaultRenderer.prototype._resultsPane=null;flyui.genefinder.BatchWidget.DefaultRenderer.prototype._messagePane=null;flyui.genefinder.BatchWidget.DefaultRenderer.prototype.setCanvas=function(C){var A="flyui.genefinder.BatchWidget.DefaultRenderer.prototype.setCanvas";try{this._canvas=$(C);this._initCanvas()}catch(B){throw B}};flyui.genefinder.BatchWidget.DefaultRenderer.prototype._initCanvas=function(){var B="flyui.genefinder.BatchWidget.DefaultRenderer.prototype._initCanvas";try{var E=this._canvas;E.addClass("batchGeneFinderWidget");var A=$("<p class='pendingPane'>pending...</p>").hide();E.append(A);this._pendingPane=A;var C=$("<p class='resultsSummaryPane'>this text should never be displayed</p>").hide();E.append(C);this._resultsSummaryPane=C;var F=$("<div class='resultsPane'></div>").hide();E.append(F);this._resultsPane=F;var G=$("<p class='messagePane'>this text should never be displayed</p>").hide();E.append(G);this._messagePane=G}catch(D){throw D}};flyui.genefinder.BatchWidget.DefaultRenderer.prototype.connect=function(C){var A="flyui.genefinder.BatchWidget.DefaultRenderer.prototype.connect";try{C.subscribeAll(this._onModelChanged,this)}catch(B){throw B}};flyui.genefinder.BatchWidget.DefaultRenderer.prototype._onModelChanged=function(G,E,C){var A="flyui.genefinder.BatchWidget.DefaultRenderer.prototype._onModelChanged";try{var B={"STATE":"_onStateChanged","QUERY":"_onQueryChanged","RESULTS":"_onResultsChanged","MESSAGE":"_onMessageChanged","MODE":"_onModeChanged"};var F=B[G];C[F](E[0],E[1],E[2])}catch(D){throw D}};flyui.genefinder.BatchWidget.DefaultRenderer.prototype._onQueryChanged=function(E,D,C){var A="flyui.genefinder.BatchWidget.DefaultRenderer.prototype._onQueryChanged";try{}catch(B){throw B}};flyui.genefinder.BatchWidget.DefaultRenderer.prototype._onStateChanged=function(E,D,C){var A="flyui.genefinder.BatchWidget.DefaultRenderer.prototype._onStateChanged";try{if(D=="PENDING"){this._pendingPane.show();this._messagePane.hide();this._resultsSummaryPane.hide();this._resultsPane.hide()}else{if(D=="READY"){this._pendingPane.hide();this._messagePane.hide();this._resultsSummaryPane.show();this._resultsPane.show()}else{if(D=="SERVERERROR"||D=="UNEXPECTEDERROR"){this._pendingPane.hide();this._messagePane.show();this._resultsSummaryPane.hide();this._resultsPane.hide()}else{throw {message:"invalid state: "+D}}}}}catch(B){throw B}};flyui.genefinder.BatchWidget.DefaultRenderer.prototype._onResultsChanged=function(E,D,C){var A="flyui.genefinder.BatchWidget.DefaultRenderer.prototype._onResultsChanged";try{if(D==null){this._resultsSummaryPane.empty();this._resultsPane.empty()}else{this._renderResultsSummary(D);this._renderResults(D)}}catch(B){throw B}};flyui.genefinder.BatchWidget.DefaultRenderer.prototype._onMessageChanged=function(E,D,C){var A="flyui.genefinder.BatchWidget.DefaultRenderer.prototype._onMessageChanged";try{if(D==null){this._messagePane.empty()}else{this._messagePane.html(D)}}catch(B){throw B}};flyui.genefinder.BatchWidget.DefaultRenderer.prototype._renderResultsSummary=function(C){var B="flyui.genefinder.BatchWidget.DefaultRenderer.prototype._renderResultsSummary";try{var G=0;var I=0;var F=0;for(var H in C){var D=C[H];if(D.length==0){I++}else{if(D.length==1){G++}else{F++}}}var E="found "+G+" OK, "+F+" ambiguous, "+I+" not found from <a href='http://flybase.org'>flybase.org</a> (FB2009_02) ...";this._resultsSummaryPane.html(E)}catch(A){throw A}};flyui.genefinder.BatchWidget.DefaultRenderer.prototype._renderResults=function(E){var B="flyui.genefinder.BatchWidget.DefaultRenderer.prototype._renderResults";try{var I=function(O){return"<a href='http://flybase.org/reports/"+O.flybaseID+".html'>"+O.flybaseID+"</a>"};var M="<strong>found:</strong> ";var N="<strong>not found:</strong> ";var H="<strong>ambiguous:</strong> ";var L=0;var C=0;var J=0;for(var K in E){var F=E[K];if(F.length==0){C++;N+=K+"; "}else{if(F.length==1){L++;M+=K+" ("+I(F[0])+"); "}else{J++;H+=K+" (";for(var D=0;D<F.length;D++){H+=I(F[D]);if(D<F.length-1){H+=", "}}H+="); "}}}var G="";if(L>0){G+="<p>"+M+"</p>"}if(J>0){G+="<p>"+H+"</p>"}if(C>0){G+="<p>"+N+"</p>"}this._resultsPane.html(G)}catch(A){throw A}};flyui.namespace("flyui.bdgp");flyui.bdgp.provenance="retrieved on 2008-10-30";flyui.bdgp.Service=function(A){this._endpoint=A};flyui.bdgp.Service.prototype=new flyui.sparql.Service();flyui.bdgp.Service.prototype.findImagesByAnyGeneLabel=function(D,G,C){var A="flyui.bdgp.Service.prototype.findImagesByAnyGeneLabel";try{flyui.info("geneLabel: "+D,A);var E=flyui.chain(flyui.bdgp.Service.responseToImages,G);var F=flyui.bdgp.Service._buildQueryForFindImagesByAnyGeneLabel(D);this.query(F,E,C)}catch(B){throw new flyui.UnexpectedException(A,B)}};flyui.bdgp.Service.responseToImages=function(C){var B="flyui.bdgp.Service.responseToImages";try{var D=YAHOO.lang.JSON.parse(C.responseText);var A=flyui.bdgp.Stage.newInstancesFromSPARQLResults(D);return A}catch(E){throw new flyui.UnexpectedException(B,E)}};flyui.bdgp.Service._buildQueryForFindImagesByAnyGeneLabel=function(C){try{var E="PREFIX bdgp: <http://purl.org/net/bdgp/schema/>  PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX : <http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX dc: <http://purl.org/dc/elements/1.1/> ";var A="select distinct ?imagepath ?stage ?developmentStage ?expression where {?gp skos:altLabel '"+C+"'; rdf:type bdgp:GeneProduct .?association bdgp:geneProduct ?gp ; bdgp:associate ?evidence ; bdgp:term ?term.?evidence bdgp:evidence ?img .?img rdf:type bdgp:Image ; bdgp:imagePath ?imagepath.?img bdgp:imageToTerm ?stage.?stage bdgp:name ?developmentStage.?term bdgp:name ?expression .}order by ?stage";var D=E+A;return D}catch(B){throw new flyui.UnexpectedException("flyui.bdgp.Service._buildQueryForFindImagesByAnyGeneLabel",B)}};flyui.bdgp.Stage=function(){try{var B=this;this.stageName=null;this.images=[];this.annotations=[];this.stageURI=null;this.addImage=function(C){flyui.util.appendIfNotMember(B.images,C)}}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.Stage",A)}};flyui.bdgp.Stage.newInstancesFromSPARQLResults=function(L){try{var B=new flyui.bdgp.StagePool();var C=new flyui.bdgp.ImagePool();var A=L.results.bindings;for(var E=0;E<A.length;E++){var K=A[E];var G=K.stage.value;var H=B.get(G);if(K.developmentStage&&!H.stageName){H.stageName=K.developmentStage.value}if(K.imagepath){var F=K.imagepath.value;var D=C.get(F);if(!D.expressions){D.expressions=new Array()}if(K.expression){var I=K.expression.value;if(I=="stage1-3"||I=="stage4-6"||I=="stage7-8"||I=="stage9-10"||I=="stage11-12"||I=="stage13-16"){}else{flyui.util.appendIfNotMember(D.expressions,I);flyui.util.appendIfNotMember(H.annotations,I)}}H.addImage(D)}}return B.toArray()}catch(J){throw new flyui.UnexpectedException("flyui.bdgp.Stage.newInstancesFromSPARQLResults",J)}};flyui.bdgp.ImagePool=function(){this._pool=new Object()};flyui.bdgp.StagePool=function(){this._pool=new Array()};flyui.bdgp.StagePool.prototype.get=function(A){try{var C=this._pool[A];if(typeof C=="undefined"||!C){C=new flyui.bdgp.Stage();C.stageURI=A;this._pool[A]=C}return C}catch(B){throw new flyui.UnexpectedException("flyui.bdgp.StagePool.prototype.get",B)}};flyui.bdgp.StagePool.prototype.toArray=function(){try{var C=new Array();for(var B in this._pool){C[C.length]=this._pool[B]}return C}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.StagePool.prototype.toArray",A)}};flyui.bdgp.ImagePool.prototype.get=function(B){try{var C=this._pool[B];if(!C){C=new Object();C.fullImageURL="http://www.fruitfly.org/insituimages/insitu_images/"+B;C.thumbnailURL="http://www.fruitfly.org/insituimages/insitu_images/thumbnails/"+B;this._pool[B]=C}return C}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.ImagePool.prototype.get",A)}};flyui.bdgp.ImagePool.prototype.toArray=function(){try{var C=new Array();for(var B in this._pool){C[C.length]=this._pool[B]}return C}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.ImagePool.prototype.toArray",A)}};flyui.bdgp.Service.prototype.findImagesByAnyGeneLabelBatch=function(G,F,C){var A="flyui.bdgp.Service.prototype.findImagesByAnyGeneLabelBatch";try{if(G.length==0){F({})}else{var D=flyui.chain(flyui.bdgp.Service.transformResponseForFindImagesByAnyGeneLabelBatch,F);var E=this._buildQueryForFindImagesByAnyGeneLabelBatch(G);this.postQuery(E,D,C)}}catch(B){throw B}};flyui.bdgp.Service.prototype._buildQueryForFindImagesByAnyGeneLabelBatch=function(E){var A="flyui.bdgp.Service.prototype._buildQueryForFindImagesByAnyGeneLabelBatch";try{var D="PREFIX bdgp: <http://purl.org/net/bdgp/schema/>\nPREFIX skos: <http://www.w3.org/2004/02/skos/core#>\n";D+='SELECT DISTINCT ?label ?imagepath ?expression ?stage WHERE \n{\n  {\n    { LET (?label := "'+E[0]+'" ) }\n';for(var C=0;C<E.length;C++){D+='    UNION\n    { LET (?label := "'+E[C]+'" ) }\n'}D+='  }\n  {\n    ?gp skos:altLabel ?label ;\n      a bdgp:GeneProduct .\n    ?association bdgp:geneProduct ?gp ;\n      bdgp:associate ?evidence ;\n      bdgp:term [ bdgp:name ?expression ] .\n    FILTER regex(?expression, "^(?!stage)", "i")\n    ?evidence bdgp:evidence ?img .\n    ?img bdgp:imagePath ?imagepath ;\n      bdgp:imageToTerm [ bdgp:name ?stage ] .\n  }\n}';return D}catch(B){throw B}};flyui.bdgp.Service.transformResponseForFindImagesByAnyGeneLabelBatch=function(H){var B="flyui.bdgp.Service.transformResponseForFindImagesByAnyGeneLabelBatch";try{var O=YAHOO.lang.JSON.parse(H.responseText);var C={};var E=new flyui.bdgp.ImagePool();var D=O.results.bindings;for(var J=0;J<D.length;J++){var N=D[J];var M=N["label"].value;var G=N["imagepath"].value;var F=E.get(G);var P=N["expression"].value;var K=N["stage"].value;if(typeof C[M]=="undefined"||!C[M]){C[M]={}}if(typeof C[M][K]=="undefined"||!C[M][K]){C[M][K]={"images":[],"terms":[]}}var L=C[M][K].images;var I=C[M][K].terms;flyui.util.appendIfNotMember(L,F);flyui.util.appendIfNotMember(I,P)}return C}catch(A){throw A}};flyui.namespace("flyui.bdgp");flyui.bdgp.ImageWidget=function(A,C){try{this._init(A,C)}catch(B){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget",B)}};flyui.bdgp.ImageWidget.prototype._controller=null;flyui.bdgp.ImageWidget.prototype._init=function(A,D){try{var C=new flyui.mvcutils.GenericModel2();C.setDefinition(flyui.bdgp.ImageWidget.modelDefinition);this._controller=new flyui.bdgp.ImageWidget.Controller(C,A,this);D.connect(C)}catch(B){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.prototype._init",B)}};flyui.bdgp.ImageWidget.prototype.findImagesByAnyGeneLabel=function(B){try{this._controller.findImagesByAnyGeneLabel(B)}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.prototype.findImagesByAnyGeneLabel",A)}};flyui.bdgp.ImageWidget.prototype.findImagesByGene=function(B){try{this._controller.findImagesByGene(B)}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.prototype.findImagesByGene",A)}};flyui.bdgp.ImageWidget.Controller=function(B,A,D){var C=this;this._model=B;this._service=A;this._parent=D;this._findImagesSuccess=function(E){flyui.info("request success");C._model.set("RESULTS",E);C._model.set("STATE","READY")};this._findImagesFailure=function(E){flyui.err("request failed, status "+E.status+" "+E.statusText);var F="There was an error retrieving data from BDGP, see the logs for more info. The server may be busy or down, please try again later. If this message persists, please contact the Image Bioinformatics Research Group at bioimage@mail.ontonet.org.";C._model.set("ERRORMESSAGE",F);C._model.set("STATE","SERVERERROR")}};flyui.bdgp.ImageWidget.Controller.prototype.findImagesByAnyGeneLabel=function(B){try{this._findImagesByAnyGeneLabel(B,this._findImagesSuccess,this._findImagesFailure)}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.Controller.prototype.findImagesByAnyGeneLabel",A)}};flyui.bdgp.ImageWidget.Controller.prototype._findImagesByAnyGeneLabel=function(C,D,B){try{flyui.info("flyui.bdgp.ImageWidget.Controller._findImagesByAnyGeneLabel :: request: "+C);this._model.set("STATE","PENDING");this._model.set("QUERY",C);this._model.set("RESULTS",null);this._service.findImagesByAnyGeneLabel(C,D,B)}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.Controller.prototype._findImagesByAnyGeneLabel",A)}};flyui.bdgp.ImageWidget.Controller.prototype.findImagesByGene=function(B){try{this._findImagesByGene(B,this._findImagesSuccess,this._findImagesFailure)}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.Controller.prototype.findImagesByGene",A)}};flyui.bdgp.ImageWidget.Controller.prototype._findImagesByGene=function(D,C,B){try{flyui.info("flyui.flyted.ImageWidget.Controller._findImagesByGene :: request: "+D.flybaseID);this._model.set("STATE","PENDING");this._model.set("QUERY",D);this._model.set("RESULTS",null);this._service.findImagesByAnyGeneLabel(D.flybaseID,C,B)}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.Controller.prototype._findImagesByGene",A)}};flyui.bdgp.ImageWidget.modelDefinition={properties:["STATE","RESULTS","QUERY","ERRORMESSAGE"],values:{"STATE":["PENDING","READY","SERVERERROR","UNEXPECTEDERROR"]},initialize:function(A){A["STATE"]="READY";A["RESULTS"]=null;A["QUERY"]=null;A["ERRORMESSAGE"]=null}};flyui.bdgp.ImageWidget.DefaultRenderer=function(){};flyui.bdgp.ImageWidget.DefaultRenderer.prototype._canvas=null;flyui.bdgp.ImageWidget.DefaultRenderer.prototype._pendingPane=null;flyui.bdgp.ImageWidget.DefaultRenderer.prototype._resultsPane=null;flyui.bdgp.ImageWidget.DefaultRenderer.prototype._resultsSummaryPane=null;flyui.bdgp.ImageWidget.DefaultRenderer.prototype._messagePane=null;flyui.bdgp.ImageWidget.DefaultRenderer.prototype.setCanvas=function(A){this._canvas=A;this._initCanvas()};flyui.bdgp.ImageWidget.DefaultRenderer.prototype._initCanvas=function(){try{YAHOO.util.Dom.addClass(this._canvas,"bdgpImageWidget");this._pendingPane=document.createElement("p");this._pendingPane.innerHTML="pending...";this._canvas.appendChild(this._pendingPane);YAHOO.util.Dom.addClass(this._pendingPane,"pendingPane");flyui.mvcutils.hide(this._pendingPane);this._messagePane=document.createElement("p");this._messagePane.innerHTML="this should never be displayed";this._canvas.appendChild(this._messagePane);YAHOO.util.Dom.addClass(this._messagePane,"messagePane");flyui.mvcutils.hide(this._messagePane);this._resultsSummaryPane=document.createElement("p");this._canvas.appendChild(this._resultsSummaryPane);YAHOO.util.Dom.addClass(this._resultsSummaryPane,"resultsSummaryPane");flyui.mvcutils.hide(this._resultsSummaryPane);this._resultsPane=document.createElement("div");this._canvas.appendChild(this._resultsPane);YAHOO.util.Dom.addClass(this._resultsPane,"resultsPane");flyui.mvcutils.hide(this._resultsPane)}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.DefaultRenderer.prototype._initCanvas",A)}};flyui.bdgp.ImageWidget.DefaultRenderer.prototype._onModelChanged=function(F,D,B){try{var A={"STATE":"_onStateChanged","QUERY":"_onQueryChanged","RESULTS":"_onResultsChanged","ERRORMESSAGE":"_onErrorMessageChanged"};var E=A[F];B[E](D[0],D[1])}catch(C){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.DefaultRenderer.prototype._onModelChanged",C)}};flyui.bdgp.ImageWidget.DefaultRenderer.prototype._onStateChanged=function(C,B){try{if(B=="PENDING"){flyui.mvcutils.show(this._pendingPane);flyui.mvcutils.hide(this._messagePane);flyui.mvcutils.hide(this._resultsSummaryPane);flyui.mvcutils.hide(this._resultsPane)}else{if(B=="READY"){flyui.mvcutils.hide(this._pendingPane);flyui.mvcutils.hide(this._messagePane);flyui.mvcutils.show(this._resultsSummaryPane);flyui.mvcutils.show(this._resultsPane)}else{if(B=="SERVERERROR"||B=="UNEXPECTEDERROR"){flyui.mvcutils.hide(this._pendingPane);flyui.mvcutils.show(this._messagePane);flyui.mvcutils.hide(this._resultsSummaryPane);flyui.mvcutils.hide(this._resultsPane)}else{throw {name:"flyui.bdgp.ImageWidget.UnexpectedStateError",message:"Invalid state: "+newState}}}}}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.DefaultRenderer.prototype._onStateChanged",A)}};flyui.bdgp.ImageWidget.DefaultRenderer.prototype._onErrorMessageChanged=function(C,B){try{this._messagePane.innerHTML=B}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.DefaultRenderer.prototype._onErrorMessageChanged",A)}};flyui.bdgp.ImageWidget.DefaultRenderer.prototype._onResultsChanged=function(E,D){try{if(D==null){this._resultsSummaryPane.innerHTML="";this._resultsPane.innerHTML=""}else{var A=0;for(var C=0;C<D.length;C++){A+=D[C].images.length}this._renderResultsSummary(this._query,A);this._renderResults(this._query,D)}}catch(B){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.DefaultRenderer.prototype._onResultsChanged",B)}};flyui.bdgp.ImageWidget.DefaultRenderer.prototype._onQueryChanged=function(C,B){try{this._query=B}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.DefaultRenderer.prototype._onQueryChanged",A)}};flyui.bdgp.ImageWidget.DefaultRenderer.prototype.connect=function(B){try{B.subscribeAll(this._onModelChanged,this)}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.DefaultRenderer.prototype.connect",A)}};flyui.bdgp.ImageWidget.DefaultRenderer.prototype._renderResultsSummary=function(D,C){try{var B="found ";B+=C;B+=" matching image";B+=(C==0||C>1)?"s ":" ";B+="from <a href='http://fruitfly.org'>fruitfly.org</a> ("+flyui.bdgp.provenance+") for ";if(D instanceof flyui.flybase.Gene){B+="gene <strong>"+D.symbols.join(" / ")+"</strong>";if(C>0){B+=" (BDGP report: <a href='http://www.fruitfly.org/cgi-bin/ex/bquery.pl?qtype=report&amp;find="+D.annotationSymbols[0]+"&amp;searchfield=CG'>"+D.annotationSymbols[0]+"</a>)"}}else{B+="query '"+D+"'"}if(C>0){B+=" ..."}this._resultsSummaryPane.innerHTML=B}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.DefaultRenderer.prototype._renderResultsSummary",A)}};flyui.bdgp.ImageWidget.DefaultRenderer.prototype._renderResults=function(C,B){if(B.length>0){var A=this._imagesToDivHTML(B);this._resultsPane.appendChild(A)}};flyui.bdgp.ImageWidget.DefaultRenderer.renderDomElementFromList=function(G,E,F){try{var B=document.createElement(G);for(var D=0;D<F.length;D++){var C=document.createElement(E);C.innerHTML=F[D];B.appendChild(C)}return B}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.DefaultRenderer.renderDomElementFromList",A)}};flyui.bdgp.ImageWidget.DefaultRenderer.prototype._imagesToDivHTML=function(A){try{var H=document.createElement("table");var F=document.createElement("thead");var D=document.createElement("tbody");H.appendChild(F);H.appendChild(D);var B=["stage and expressions","images"];var E=flyui.bdgp.ImageWidget.DefaultRenderer.renderDomElementFromList("tr","th",B);F.appendChild(E);for(var J=0;J<A.length;J++){var C=this._imageToTableCellContents(A[J]);var I=flyui.bdgp.ImageWidget.DefaultRenderer.renderDomElementFromList("tr","td",C);D.appendChild(I)}return H}catch(G){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.DefaultRenderer.prototype._imagesToDivHTML",G)}};flyui.bdgp.ImageWidget.DefaultRenderer.prototype._imageToTableCellContents=function(C){try{var F=C.images;var E=C.stageName+this._expressionTermsToDivHTML(F[0]);var B="";for(var D=0;D<F.length;D++){B+=this._imageToDivHTML(F[D])}return[E,B]}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.DefaultRenderer.prototype._imageToTableCellContents",A)}};flyui.bdgp.ImageWidget.DefaultRenderer.prototype._expressionTermsToDivHTML=function(E){try{var D='<div class="terms">';var A=E.expressions;D+="<ul>";for(var C=0;C<A.length;C++){D+="<li>"+A[C]+"</li>"}D+="</ul></div>";return D}catch(B){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.DefaultRenderer.prototype._expressionTermsToDivHTML",B)}};flyui.bdgp.ImageWidget.DefaultRenderer.prototype._imageToDivHTML=function(F,E,B){try{var C="thumbnail image of embryo in situ hybridisation";if(E instanceof flyui.flybase.Gene&&B){C="thumbnail image depicting expression of "+E.symbols[0]+" in "+B+" embryo"}var D='<div class="result">';D+='<a href="'+F.fullImageURL+'">';D+='<img src="'+F.thumbnailURL+'" alt="'+C+'">';D+="</img></a>";D+="</div>";return D}catch(A){throw new flyui.UnexpectedException("flyui.bdgp.ImageWidget.DefaultRenderer.prototype._imageToDivHTML",A)}};flyui.bdgp.ImageWidget.CompactRenderer=function(){};flyui.bdgp.ImageWidget.CompactRenderer.prototype=new flyui.bdgp.ImageWidget.DefaultRenderer();flyui.bdgp.ImageWidget.CompactRenderer.prototype._renderResults=function(G,E){if(E.length>0){var F="<table><tbody>";for(var D=0;D<E.length;D++){var C=E[D];var H=C.stageName.replace(/stage(.*)/,"stage $1");F+="<tr class='stagename'><td>"+H+"</td></tr>";F+="<tr class='stageimages'><td>";F+="<p class='terms'>";for(var B=0;B<C.annotations.length;B++){F+=C.annotations[B]+"; "}F+="</p>";for(var B=0;B<C.images.length;B++){F+=this._imageToDivHTML(C.images[B],G,H)}F+="</td></tr>"}F+="</tbody></table>";var A=document.createElement("div");A.innerHTML=F;this._resultsPane.appendChild(A)}};flyui.namespace("flyui.bdgp");flyui.bdgp.BatchWidget=function(A,D){var B="flyui.bdgp.BatchWidget";try{this.__init__(A,D)}catch(C){throw C}};flyui.bdgp.BatchWidget.prototype._controller=null;flyui.bdgp.BatchWidget.prototype._model=null;flyui.bdgp.BatchWidget.prototype._renderer=null;flyui.bdgp.BatchWidget.prototype._service=null;flyui.bdgp.BatchWidget.prototype.__init__=function(A,D){var B="flyui.bdgp.BatchWidget.prototype.__init__";try{this._service=A;this._renderer=D;this._model=new flyui.mvcutils.GenericModel2();this._model.setDefinition(flyui.bdgp.BatchWidget.modelDefinition);this._controller=new flyui.bdgp.BatchWidget.Controller(this._model,A,this);this._renderer.connect(this._model)}catch(C){throw C}};flyui.bdgp.BatchWidget.prototype.findImagesByGeneBatch=function(D,C){var A="flyui.bdgp.BatchWidget.prototype.findGenesByAnyNameBatch";try{this._controller.findImagesByGeneBatch(D,C)}catch(B){throw B}};flyui.bdgp.BatchWidget.prototype.clear=function(){var A="flyui.bdgp.BatchWidget.prototype.clear";try{this._controller.clear()}catch(B){throw B}};flyui.bdgp.BatchWidget.Controller=function(E,A,D){var B="flyui.bdgp.BatchWidget.Controller";try{this._model=null;this._service=null;this._controllee=null;this.__init__(E,A,D)}catch(C){throw C}};flyui.bdgp.BatchWidget.Controller.prototype.__init__=function(E,A,D){var B="flyui.bdgp.BatchWidget.Controller.prototype.__init__";try{this._model=E;this._service=A;this._controllee=D}catch(C){throw C}};flyui.bdgp.BatchWidget.Controller.prototype.findImagesByGeneBatch=function(D,C){var A="flyui.bdgp.BatchWidget.Controller.prototype.findGenesByAnyNameBatch";try{flyui.info("findImagesByGeneBatch: "+D+" || "+C,A);this._findImagesByGeneBatch(D,C,this._findImagesByGeneBatchSuccess(),this._findImagesByGeneBatchFailure())}catch(B){throw B}};flyui.bdgp.BatchWidget.Controller.prototype._findImagesByGeneBatch=function(H,E,G,C){var A="flyui.bdgp.BatchWidget.Controller.prototype._findImagesByGeneBatch";try{this._model.set("STATE","PENDING");this._model.set("QUERY",[H,E]);this._model.set("RESULTS",null);this._model.set("MESSAGE",null);var F=[];for(var D=0;D<E.length;D++){F[D]=E[D].flybaseID}this._service.findImagesByAnyGeneLabelBatch(F,G,C)}catch(B){throw B}};flyui.bdgp.BatchWidget.Controller.prototype._findImagesByGeneBatchSuccess=function(){var A="flyui.bdgp.BatchWidget.Controller.prototype._findImagesByGeneBatchSuccess";var B=this;return function(E){try{flyui.info("request success",A);B._model.set("RESULTS",E);B._model.set("STATE","READY");var C="Images depict patterns of gene expression during embryogenesis for Drosophila genes represented in non-redundant sets of Drosophila ESTs DGC1 and DGC2. Empty table cells indicate that no images are available from BDGP for that gene/stage. See also <a href='http://dx.doi.org/10.1186/gb-2002-3-12-research0088'>Tomancak et al. 2002</a> and <a href='http://dx.doi.org/10.1186/gb-2007-8-7-r145'>Tomancak et al. 2007</a>.";B._model.set("MESSAGE",C)}catch(D){throw D}}};flyui.bdgp.BatchWidget.Controller.prototype._findImagesByGeneBatchFailure=function(){var A="flyui.bdgp.BatchWidget.Controller.prototype._findImagesByGeneBatchFailure";var B=this;return function(C){try{flyui.err("request failed: "+C.status+" "+C.statusText,A);B._model.set("MESSAGE","there was an error retrieving data from the server, see the logs for more info");B._model.set("STATE","SERVERERROR")}catch(D){throw D}}};flyui.bdgp.BatchWidget.Controller.prototype.clear=function(){var A="flyui.bdgp.BatchWidget.Controller.prototype.clear";try{this._model.set("STATE","READY");this._model.set("QUERY",null);this._model.set("RESULTS",null);this._model.set("MESSAGE",null)}catch(B){throw B}};flyui.bdgp.BatchWidget.modelDefinition={properties:["STATE","RESULTS","MESSAGE","QUERY"],values:{"STATE":["READY","PENDING","SERVERERROR","UNEXPECTEDERROR"]},initialize:function(A){A["STATE"]="READY";A["RESULTS"]=null;A["MESSAGE"]=null;A["QUERY"]=null}};flyui.bdgp.BatchWidget.DefaultRenderer=function(){};flyui.bdgp.BatchWidget.DefaultRenderer.prototype._canvas=null;flyui.bdgp.BatchWidget.DefaultRenderer.prototype._pendingPane=null;flyui.bdgp.BatchWidget.DefaultRenderer.prototype._resultsSummaryPane=null;flyui.bdgp.BatchWidget.DefaultRenderer.prototype._resultsPane=null;flyui.bdgp.BatchWidget.DefaultRenderer.prototype._messagePane=null;flyui.bdgp.BatchWidget.DefaultRenderer.prototype.setCanvas=function(C){var A="flyui.bdgp.BatchWidget.DefaultRenderer.prototype.setCanvas";try{this._canvas=$(C);this._initCanvas()}catch(B){throw B}};flyui.bdgp.BatchWidget.DefaultRenderer.prototype._initCanvas=function(){var B="flyui.bdgp.BatchWidget.DefaultRenderer.prototype._initCanvas";try{var E=this._canvas;E.addClass("batchBdgpImageWidget");var A=$("<p class='pendingPane'>pending (please wait, this can take up to 10 seconds) ...</p>").hide();E.append(A);this._pendingPane=A;var C=$("<p class='resultsSummaryPane'>this text should never be displayed</p>").hide();E.append(C);this._resultsSummaryPane=C;var F=$("<div class='resultsPane'></div>").hide();E.append(F);this._resultsPane=F;var G=$("<p class='messagePane'>this text should never be displayed</p>").hide();E.append(G);this._messagePane=G}catch(D){throw D}};flyui.bdgp.BatchWidget.DefaultRenderer.prototype.connect=function(C){var A="flyui.bdgp.BatchWidget.DefaultRenderer.prototype.connect";try{C.subscribeAll(this._onModelChanged,this)}catch(B){throw B}};flyui.bdgp.BatchWidget.DefaultRenderer.prototype._onModelChanged=function(G,E,C){var A="flyui.bdgp.BatchWidget.DefaultRenderer.prototype._onModelChanged";try{var B={"STATE":"_onStateChanged","QUERY":"_onQueryChanged","RESULTS":"_onResultsChanged","MESSAGE":"_onMessageChanged"};var F=B[G];C[F](E[0],E[1],E[2])}catch(D){throw D}};flyui.bdgp.BatchWidget.DefaultRenderer.prototype._onQueryChanged=function(E,D,C){var A="flyui.bdgp.BatchWidget.DefaultRenderer.prototype._onQueryChanged";try{}catch(B){throw B}};flyui.bdgp.BatchWidget.DefaultRenderer.prototype._onStateChanged=function(E,D,C){var A="flyui.bdgp.BatchWidget.DefaultRenderer.prototype._onStateChanged";try{if(D=="PENDING"){this._pendingPane.show();this._messagePane.hide();this._resultsSummaryPane.hide();this._resultsPane.hide()}else{if(D=="READY"){this._pendingPane.hide();this._messagePane.show();this._resultsSummaryPane.show();this._resultsPane.show()}else{if(D=="SERVERERROR"||D=="UNEXPECTEDERROR"){this._pendingPane.hide();this._messagePane.show();this._resultsSummaryPane.hide();this._resultsPane.hide()}else{throw {message:"invalid state: "+D}}}}}catch(B){throw B}};flyui.bdgp.BatchWidget.DefaultRenderer.prototype._onResultsChanged=function(F,E,C){var A="flyui.bdgp.BatchWidget.DefaultRenderer.prototype._onResultsChanged";try{if(E==null){this._resultsSummaryPane.empty();this._resultsPane.empty()}else{var D=C("QUERY");this._renderResultsSummary(D,E);this._renderResults(D,E)}}catch(B){throw B}};flyui.bdgp.BatchWidget.DefaultRenderer.prototype._onMessageChanged=function(E,D,C){var A="flyui.bdgp.BatchWidget.DefaultRenderer.prototype._onMessageChanged";try{if(D==null){this._messagePane.empty()}else{this._messagePane.html(D)}}catch(B){throw B}};flyui.bdgp.BatchWidget.DefaultRenderer.prototype._renderResultsSummary=function(G,C){var A="flyui.bdgp.BatchWidget.DefaultRenderer.prototype._renderResultsSummary";try{var H=G[0];var D=G[1];var F=0;for(genename in C){for(stagename in C[genename]){F+=C[genename][stagename].images.length}}var E="found "+F+" images from <a href='http://fruitfly.org'>fruitfly.org</a> ("+flyui.bdgp.provenance+") ...";this._resultsSummaryPane.html(E)}catch(B){throw B}};flyui.bdgp.BatchWidget.DefaultRenderer.prototype._renderResults=function(D,N){var I="flyui.bdgp.BatchWidget.DefaultRenderer.prototype._renderResults";try{var A=D[0];var F=D[1];var G=["stage1-3","stage4-6","stage7-8","stage9-10","stage11-12","stage13-16"];var Q="<table>";Q+="<thead><tr><th>gene</th>";for(var T=0;T<G.length;T++){Q+="<th>"+G[T].replace(/stage(.*)/,"stage $1")+"</th>"}Q+="</tr></thead><tbody>";for(var T=0;T<A.length;T++){var O=A[T];var U=F[T].annotationSymbols[0];var L=F[T].flybaseID;Q+="<tr><td><a href='http://www.fruitfly.org/cgi-bin/ex/bquery.pl?qtype=report&amp;find="+U+"&amp;searchfield=CG'>"+O+"</a></td>";for(var S=0;S<G.length;S++){var H=G[S];var J=N[L];Q+="<td>";for(var R in J){if(R==H){var E=J[R];Q+="<p class='terms'>";for(var P=0;P<E.terms.length;P++){var M=E.terms[P];Q+=M+"; "}Q+="</p>";for(var P=0;P<E.images.length;P++){var B="thumbnail image depicting expression of "+O+" in "+H+" embryo";var K=E.images[P];Q+='<div class="result">';Q+='<a href="'+K.fullImageURL+'">';Q+='<img src="'+K.thumbnailURL+'" alt="'+B+'">';Q+="</img></a>";Q+="</div>"}}}Q+="</td>"}Q+="</tr>"}Q+="</tbody></table>";this._resultsPane.html(Q)}catch(C){throw C}};flyui.namespace("flyui.flyted");flyui.flyted.provenance="retrieved on 2008-12-03";flyui.flyted.Service=function(A){this._endpoint=A};flyui.flyted.Service.prototype=new flyui.sparql.Service();flyui.flyted.Service.prototype.findImagesByFlytedProbeName=function(A,G,D){var B="flyui.flyted.Service.prototype.findImagesByFlytedProbeName";try{flyui.info("probeName: "+A,B);var E=flyui.chain(flyui.flyted.Service.responseToImages,G);var F=flyui.flyted.Service._buildQueryForFindImagesByFlytedProbeName(A);this.query(F,E,D)}catch(C){throw new flyui.UnexpectedException(B,C)}};flyui.flyted.Service.prototype.findImagesByFlybaseGeneID=function(F,G,C){var A="flyui.flyted.Service.prototype.findImagesByFlybaseGeneID";try{flyui.info("flybaseGeneID: "+F,A);var D=flyui.chain(flyui.flyted.Service.responseToImages,G);var E=flyui.flyted.Service._buildQueryForFindImagesByFlybaseGeneID(F);this.query(E,D,C)}catch(B){throw new flyui.UnexpectedException(A,B)}};flyui.flyted.Service.prototype.findImagesByFlybaseGeneIDBatch=function(B,G,D){var A="flyui.flyted.Service.prototype.findImagesByFlybaseGeneIDBatch";try{flyui.info("flybaseGeneIDs: "+B,A);if(B.length==0){G({})}else{var E=flyui.chain(flyui.flyted.Service.transformResponseForFindImagesByFlybaseGeneIDBatch,G);var F=this._buildQueryForFindImagesByFlybaseGeneIDBatch(B);this.postQuery(F,E,D)}}catch(C){throw new flyui.UnexpectedException(A,C)}};flyui.flyted.Service.prototype._buildQueryForFindImagesByFlybaseGeneIDBatch=function(B){var A="flyui.flyted.Service.prototype._buildQueryForFindImagesByFlybaseGeneIDBatch";try{var E="PREFIX flyted: <http://purl.org/net/flyted/schema/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> ";E+="SELECT DISTINCT ?fbgn ?flytedURL ?fullImageURL ?thumbnailURL ?probe ?caption ?probeLabel  WHERE \n {\n  {\n    { LET (?fbgn := <http://openflydata.org/id/flybase/feature/"+B[0]+"> ) }\n";for(var D=0;D<B.length;D++){E+="    UNION\n    { LET (?fbgn := <http://openflydata.org/id/flybase/feature/"+B[D]+"> ) }\n"}E+="  }\n  {\n    ?probe flyted:hybridisesTranscriptOf ?fbgn ;\n			rdfs:label ?probeLabel .\n	?fullImageURL flyted:probe ?probe ; \n				  flyted:thumbnail ?thumbnailURL; \n				  rdfs:seeAlso ?flytedURL; \n				  rdfs:label ?caption .\n  }\n}";return E}catch(C){throw C}};flyui.flyted.Service.responseToImages=function(C){var B="flyui.flyted.Service.responseToImages";try{var D=YAHOO.lang.JSON.parse(C.responseText);var A=flyui.flyted.Image.newInstancesFromSPARQLResults(D);return A}catch(E){throw new flyui.UnexpectedException(B,E)}};flyui.flyted.Service._buildQueryForFindImagesByFlytedProbeName=function(B){try{var E="PREFIX flyted: <http://purl.org/net/flyted/schema/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> ";var A="SELECT DISTINCT *  WHERE { ?fullImageURL flyted:probe ?probe ; flyted:thumbnail ?thumbnailURL; rdfs:seeAlso ?flytedURL; rdfs:label ?caption .?probe rdfs:label '"+B+"' .}";var D=E+A;return D}catch(C){throw new flyui.UnexpectedException("flyui.flyted.Service._buildQueryForFindImagesByFlytedProbeName",C)}};flyui.flyted.Service._buildQueryForFindImagesByFlybaseGeneID=function(E){try{var D="PREFIX flyted: <http://purl.org/net/flyted/schema/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> ";"PREFIX so: <http://purl.org/obo/owl/SO#> ";var A="SELECT DISTINCT ?fullImageURL ?thumbnailURL ?flytedURL ?caption ?probe ?probeLabel WHERE { ?probe flyted:hybridisesTranscriptOf <http://openflydata.org/id/flybase/feature/"+E+"> ;rdfs:label ?probeLabel .?fullImageURL flyted:probe ?probe ; flyted:thumbnail ?thumbnailURL; rdfs:seeAlso ?flytedURL; rdfs:label ?caption .}";var C=D+A;return C}catch(B){throw new flyui.UnexpectedException("flyui.flyted.Service._buildQueryForFindImagesByFlybaseGeneID",B)}};flyui.flyted.Service.mapNameUsingTable=function(C,D){try{var A=D[C];if(typeof A=="undefined"||!A){A=[]}return A}catch(B){throw new flyui.UnexpectedException("flyui.flyted.Service.mapNameUsingTable",B)}};flyui.flyted.Image=function(){this.fullImageURL=null;this.thumbnailURL=null;this.flytedURL=null;this.caption=null;this.probe=null};flyui.flyted.Image.newInstancesFromSPARQLResults=function(L){try{var B=L.results.bindings;var D=new flyui.flyted.ImagePool();var G=new flyui.flyted.ProbePool();for(var F=0;F<B.length;F++){var K=B[F];var H=K.fullImageURL.value;var E=D.get(H);E.thumbnailURL=K.thumbnailURL.value;E.flytedURL=K.flytedURL.value;E.caption=K.caption.value;if(K.probe){var J=K.probe.value;var C=G.get(J);if(!C.probeLabels){C.probeLabels=new Array()}if(K.probeLabel){var A=K.probeLabel.value;flyui.util.appendIfNotMember(C.probeLabels,A)}E.probe=C}}return D.toArray()}catch(I){throw new flyui.UnexpectedException("flyui.flyted.Image.newInstancesFromSPARQLResults",I)}};flyui.flyted.ImagePool=function(){this._pool=new Object()};flyui.flyted.ImagePool.prototype.toArray=function(){try{var C=new Array();for(var B in this._pool){C[C.length]=this._pool[B]}return C}catch(A){throw new flyui.UnexpectedException("flyui.flyted.ImagePool.prototype.toArray",A)}};flyui.flyted.ImagePool.prototype.get=function(B){try{var C=this._pool[B];if(typeof C=="undefined"||!C){C=new flyui.flyted.Image();C.fullImageURL=B;this._pool[B]=C}return C}catch(A){throw new flyui.UnexpectedException("flyui.flyted.ImagePool.prototype.get",A)}};flyui.flyted.ProbePool=function(){this._pool=new Object()};flyui.flyted.ProbePool.prototype.get=function(C){try{var A=this._pool[C];if(!A){A=new Object();A.probeURI=C;this._pool[C]=A}return A}catch(B){throw new flyui.UnexpectedException("flyui.flyted.ProbePool.prototype.get",B)}};flyui.flyted.ProbePool.prototype.toArray=function(){try{var C=new Array();for(var B in this._pool){C[C.length]=this._pool[B]}return C}catch(A){throw new flyui.UnexpectedException("flyui.flyted.ProbePool.prototype.toArray",A)}};flyui.flyted.Service.transformResponseForFindImagesByFlybaseGeneIDBatch=function(I){var B="flyui.flyted.Service.transformResponseForFindImagesByFlybaseGeneIDBatch";try{var M=YAHOO.lang.JSON.parse(I.responseText);var D={};var F=new flyui.flyted.ImagePool();var E=M.results.bindings;for(var J=0;J<E.length;J++){var L=E[J];var C=L["fbgn"].value;var G=L["fullImageURL"].value;var H=F.get(G);H.thumbnailURL=L["thumbnailURL"].value;H.flytedURL=L["flytedURL"].value;H.caption=L["caption"].value;if(typeof D[C]=="undefined"||!D[C]){D[C]={"images":[]}}var K=D[C].images;flyui.util.appendIfNotMember(K,H)}return D}catch(A){throw A}};flyui.namespace("flyui.flyted");flyui.flyted.ImageWidget=function(A,D){try{var C=this;this._controller=null;this._renderer=D;this._model=null;this._renderer=null;this._service=null;this._init=function(){var E=new flyui.mvcutils.GenericModel2();E.setDefinition(flyui.flyted.ImageWidget.modelDefinition);this._controller=new flyui.flyted.ImageWidget.Controller(E,A,this);D.connect(E)};this._init(A,D)}catch(B){throw new flyui.UnexpectedException("flyui.flyted.ImageWidget",B)}};flyui.flyted.ImageWidget.prototype.findImagesByFlytedGeneName=function(A){try{this._controller.findImagesByFlytedGeneName(A)}catch(B){throw new flyui.UnexpectedException("flyui.flyted.ImageWidget.prototype.findImagesByFlytedGeneName",B)}};flyui.flyted.ImageWidget.prototype.findImagesByFlybaseGeneID=function(B){try{this._controller.findImagesByFlybaseGeneID(B)}catch(A){throw new flyui.UnexpectedException("flyui.flyted.ImageWidget.prototype.findImagesByFlybaseGeneID",A)}};flyui.flyted.ImageWidget.prototype.findImagesByGene=function(B){try{this._controller.findImagesByGene(B)}catch(A){throw new flyui.UnexpectedException("flyui.flyted.ImageWidget.prototype.findImagesByGene",A)}};flyui.flyted.ImageWidget.Controller=function(B,A,D){var C=this;this._model=B;this._service=A;this._parent=D;this._findImagesSuccess=function(E){try{flyui.info("request success");C._model.set("RESULTS",E);C._model.set("STATE","READY")}catch(F){throw new flyui.UnexpectedException("_findImagesSuccess",F)}};this._findImagesFailure=function(E){try{flyui.err("request failed, status "+E.status+" "+E.statusText);var G="There was an error retrieving data from FlyTED, see the logs for more info. The server may be busy or down, please try again later. If this message persists, please contact the Image Bioinformatics Research Group at bioimage@mail.ontonet.org.";C._model.set("ERRORMESSAGE",G);C._model.set("STATE","SERVERERROR")}catch(F){throw new flyui.UnexpectedException("_findImagesFailure",F)}}};flyui.flyted.ImageWidget.Controller.prototype.findImagesByFlytedGeneName=function(A){try{this._findImagesByFlytedGeneName(A,this._findImagesSuccess,this._findImagesFailure)}catch(B){throw new flyui.UnexpectedException("flyui.flyted.ImageWidget.Controller.prototype.findImagesByFlytedGeneName",B)}};flyui.flyted.ImageWidget.Controller.prototype._findImagesByFlytedGeneName=function(A,D,C){try{flyui.info("flyui.flyted.ImageWidget.Controller._findImagesByFlytedGeneName :: request: "+A);this._model.set("STATE","PENDING");this._model.set("QUERY",A);this._service.findImagesByFlytedProbeName(A,D,C)}catch(B){throw new flyui.UnexpectedException("flyui.flyted.ImageWidget.Controller.prototype._findImagesByFlytedGeneName",B)}};flyui.flyted.ImageWidget.Controller.prototype.findImagesByFlybaseGeneID=function(B){try{this._findImagesByFlybaseGeneID(B,this._findImagesSuccess,this._findImagesFailure)}catch(A){throw new flyui.UnexpectedException("flyui.flyted.ImageWidget.Controller.prototype.findImagesByFlybaseGeneID",A)}};flyui.flyted.ImageWidget.Controller.prototype._findImagesByFlybaseGeneID=function(C,D,B){try{flyui.info("flyui.flyted.ImageWidget.Controller._findImagesByFlybaseGeneID :: request: "+C);this._model.set("STATE","PENDING");this._model.set("QUERY",C);this._service.findImagesByFlybaseGeneID(C,D,B)}catch(A){throw new flyui.UnexpectedException("flyui.flyted.ImageWidget.Controller.prototype._findImagesByFlybaseGeneID",A)}};flyui.flyted.ImageWidget.Controller.prototype.findImagesByGene=function(B){try{this._findImagesByGene(B,this._findImagesSuccess,this._findImagesFailure)}catch(A){throw new flyui.UnexpectedException("flyui.flyted.ImageWidget.Controller.prototype.findImagesByGene",A)}};flyui.flyted.ImageWidget.Controller.prototype._findImagesByGene=function(D,C,B){try{flyui.info("flyui.flyted.ImageWidget.Controller._findImagesByGene :: request: "+D.flybaseID);this._model.set("STATE","PENDING");this._model.set("QUERY",D);this._service.findImagesByFlybaseGeneID(D.flybaseID,C,B)}catch(A){throw new flyui.UnexpectedException("flyui.flyted.ImageWidget.Controller.prototype._findImagesByGene",A)}};flyui.flyted.ImageWidget.modelDefinition={properties:["STATE","RESULTS","QUERY","ERRORMESSAGE"],values:{"STATE":["PENDING","READY","SERVERERROR","UNEXPECTEDERROR"]},initialize:function(A){A["STATE"]="READY";A["RESULTS"]=null;A["QUERY"]=null;A["ERRORMESSAGE"]=null}};flyui.flyted.ImageWidget.DefaultRenderer=function(){};flyui.flyted.ImageWidget.DefaultRenderer.prototype.setCanvas=function(B){try{this._canvas=B;this._initCanvas()}catch(A){throw new flyui.UnexpectedException("flyui.flyted.ImageWidget.DefaultRenderer.prototype.setCanvas",A)}};flyui.flyted.ImageWidget.DefaultRenderer.prototype._initCanvas=function(){try{YAHOO.util.Dom.addClass(this._canvas,"flytedImageWidget");this._pendingPane=document.createElement("p");this._pendingPane.innerHTML="pending...";this._canvas.appendChild(this._pendingPane);YAHOO.util.Dom.addClass(this._pendingPane,"pendingPane");flyui.mvcutils.hide(this._pendingPane);this._messagePane=document.createElement("div");this._messagePane.innerHTML="this should never be displayed";this._canvas.appendChild(this._messagePane);YAHOO.util.Dom.addClass(this._messagePane,"messagePane");flyui.mvcutils.hide(this._messagePane);this._resultsSummaryPane=document.createElement("p");this._canvas.appendChild(this._resultsSummaryPane);YAHOO.util.Dom.addClass(this._resultsSummaryPane,"resultsSummaryPane");flyui.mvcutils.hide(this._resultsSummaryPane);this._resultsPane=document.createElement("div");this._canvas.appendChild(this._resultsPane);YAHOO.util.Dom.addClass(this._resultsPane,"resultsPane");flyui.mvcutils.hide(this._resultsPane);this._explanationPane=document.createElement("p");this._explanationPane.innerHTML="this should never be displayed";this._canvas.appendChild(this._explanationPane);YAHOO.util.Dom.addClass(this._explanationPane,"explanationPane");flyui.mvcutils.hide(this._explanationPane)}catch(A){throw new flyui.UnexpectedException("flyui.flyted.ImageWidget.DefaultRenderer.prototype._initCanvas",A)}};flyui.flyted.ImageWidget.DefaultRenderer.prototype._canvas=null;flyui.flyted.ImageWidget.DefaultRenderer.prototype._pendingPane=null;flyui.flyted.ImageWidget.DefaultRenderer.prototype._resultsPane=null;flyui.flyted.ImageWidget.DefaultRenderer.prototype._resultsSummaryPane=null;flyui.flyted.ImageWidget.DefaultRenderer.prototype._messagePane=null;flyui.flyted.ImageWidget.DefaultRenderer.prototype._explanationPane=null;flyui.flyted.ImageWidget.DefaultRenderer.prototype._onModelChanged=function(F,D,B){try{var A={"STATE":"_onStateChanged","QUERY":"_onQueryChanged","RESULTS":"_onResultsChanged","ERRORMESSAGE":"_onErrorMessageChanged"};var E=A[F];B[E](D[0],D[1],D[2])}catch(C){throw new flyui.UnexpectedException("flyui.flyted.ImageWidget.DefaultRenderer.prototype._onModelChanged",C)}};flyui.flyted.ImageWidget.DefaultRenderer.prototype._onStateChanged=function(F,E,C){var A="flyui.flyted.ImageWidget.DefaultRenderer.prototype._onStateChanged";try{if(E=="PENDING"){flyui.mvcutils.show(this._pendingPane);flyui.mvcutils.hide(this._messagePane);flyui.mvcutils.hide(this._resultsSummaryPane);flyui.mvcutils.hide(this._resultsPane);flyui.mvcutils.hide(this._explanationPane)}else{if(E=="READY"){flyui.mvcutils.hide(this._pendingPane);flyui.mvcutils.hide(this._messagePane);flyui.mvcutils.show(this._resultsSummaryPane);var D=C("RESULTS");if(D.length>0){flyui.mvcutils.show(this._resultsPane);flyui.mvcutils.show(this._explanationPane)}}else{if(E=="SERVERERROR"||E=="UNEXPECTEDERROR"){flyui.mvcutils.hide(this._pendingPane);flyui.mvcutils.show(this._messagePane);flyui.mvcutils.hide(this._resultsSummaryPane);flyui.mvcutils.hide(this._resultsPane);flyui.mvcutils.hide(this._explanationPane)}else{throw {name:"flyui.flyted.ImageWidget.UnexpectedStateError",message:"Invalid state: "+newState}}}}}catch(B){throw new flyui.UnexpectedException(A,B)}};flyui.flyted.ImageWidget.DefaultRenderer.prototype._onQueryChanged=function(C,B){try{this._query=B}catch(A){throw new flyui.UnexpectedException("flyui.flyted.ImageWidget.DefaultRenderer.prototype._onQueryChanged",A)}};flyui.flyted.ImageWidget.DefaultRenderer.prototype._onResultsChanged=function(F,E){var B="flyui.flyted.ImageWidget.DefaultRenderer.prototype._onResultsChanged";try{this._resultsPane.innerHTML="";this._resultsSummaryPane.innerHTML="";this._explanationPane.innerHTML="";var A=[];for(var D=0;D<E.length;D++){flyui.util.appendIfNotMember(A,E[D].probe)}this._renderResultsSummary(this._query,E.length,A);if(E.length>0){this._resultsPane.innerHTML=this._imagesToDivHTML(E)}else{}}catch(C){throw new flyui.UnexpectedException(B,C)}};flyui.flyted.ImageWidget.DefaultRenderer.prototype._onErrorMessageChanged=function(C,B){try{this._messagePane.innerHTML=B}catch(A){throw new flyui.UnexpectedException("flyui.flyted.ImageWidget.DefaultRenderer.prototype._onErrorMessageChanged",A)}};flyui.flyted.ImageWidget.DefaultRenderer.prototype.connect=function(B){try{B.subscribeAll(this._onModelChanged,this)}catch(A){throw new flyui.UnexpectedException("flyui.flyted.ImageWidget.DefaultRenderer.prototype.connect",A)}};flyui.flyted.ImageWidget.DefaultRenderer.prototype._renderResultsSummary=function(M,I,K){var A="flyui.flyted.ImageWidget.DefaultRenderer.prototype._renderResultsSummary";try{function H(N){return N.replace("/","=2F").replace(" ","_")}var B="";var J="found <span>";J+=I;J+="</span> matching image";J+=(I==0||I>1)?"s ":" ";J+="from <a href='http://www.fly-ted.org'>www.fly-ted.org</a> ("+flyui.flyted.provenance+") for ";var G=[];for(var F=0;F<K.length;F++){var C=K[F];for(var E=0;E<C.probeLabels.length;E++){flyui.util.appendIfNotMember(G,C.probeLabels[E])}}if(M instanceof flyui.flybase.Gene){J+="gene <strong>"+M.symbols.join(" / ")+"</strong>"}else{J+="query <span>'"+M+"'</span>"}if(G.length>0){J+=" (Fly-TED report";J+=(G.length>1)?"s:":":";for(var F=0;F<G.length;F++){var D=G[F];J+=" <a href='http://www.fly-ted.org/view/geneid/"+H(D)+".html'>"+D+"</a>";if(F<G.length-1){J+=","}}J+=") ...";if(K.length==1&&K[0].probeLabels.length==1){}else{if(K.length==1&&K[0].probeLabels.length>1){B+="N.B. the reports at www.fly-ted.org (";for(var F=0;F<K[0].probeLabels.length;F++){var D=K[0].probeLabels[F];B+="<a href='http://www.fly-ted.org/view/geneid/"+H(D)+".html'>"+D+"</a>";if(F<K[0].probeLabels.length-1){B+=", "}}B+=") report data on <strong>the same probe</strong>; check probe PCR sequence to verify"}else{if(K.length>1){B+="N.B. the reports at www.fly-ted.org (";for(var F=0;F<K.length;F++){var D=K[F].probeLabels[0];B+="<a href='http://www.fly-ted.org/view/geneid/"+H(D)+".html'>"+D+"</a>";if(F<K.length-1){B+=", "}}B+=") report data on <strong>different probes</strong> which both amplify transcripts of gene "+M.flybaseID+"; check probe PCR sequence to verify"}else{flyui.err("encountered unexpected probe / labels combination",A)}}}}this._resultsSummaryPane.innerHTML=J;this._explanationPane.innerHTML=B}catch(L){throw new flyui.UnexpectedException(A,L)}};flyui.flyted.ImageWidget.DefaultRenderer.prototype._imagesToDivHTML=function(A){try{var D="";for(var C in A){D+=this._imageToDivHTML(A[C])}return D}catch(B){throw new flyui.UnexpectedException("flyui.flyted.ImageWidget.DefaultRenderer.prototype._imagesToDivHTML",B)}};flyui.flyted.ImageWidget.DefaultRenderer.prototype._imageToDivHTML=function(D){try{var B="thumbnail image depicting expression of "+D.caption;var C='<div class="result">';C+='<a href="'+D.flytedURL+'">';C+='<img src="'+D.thumbnailURL+'" alt="'+B+'">';C+="</img></a>";C+='<p class="caption">'+D.caption+"</p>";C+="</div>";return C}catch(A){throw new flyui.UnexpectedException("flyui.flyted.ImageWidget.DefaultRenderer.prototype._imageToDivHTML",A)}};flyui.namespace("flyui.flyted");flyui.flyted.BatchWidget=function(A,D){var B="flyui.flyted.BatchWidget";try{this.__init__(A,D)}catch(C){throw C}};flyui.flyted.BatchWidget.prototype._controller=null;flyui.flyted.BatchWidget.prototype._model=null;flyui.flyted.BatchWidget.prototype._renderer=null;flyui.flyted.BatchWidget.prototype._service=null;flyui.flyted.BatchWidget.prototype.__init__=function(A,D){var B="flyui.flyted.BatchWidget.prototype.__init__";try{this._service=A;this._renderer=D;this._model=new flyui.mvcutils.GenericModel2();this._model.setDefinition(flyui.flyted.BatchWidget.modelDefinition);this._controller=new flyui.flyted.BatchWidget.Controller(this._model,A,this);this._renderer.connect(this._model)}catch(C){throw C}};flyui.flyted.BatchWidget.prototype.findImagesByGeneBatch=function(D,C){var A="flyui.flyted.BatchWidget.prototype.findGenesByAnyNameBatch";try{this._controller.findImagesByGeneBatch(D,C)}catch(B){throw B}};flyui.flyted.BatchWidget.prototype.clear=function(){var A="flyui.flyted.BatchWidget.prototype.clear";try{this._controller.clear()}catch(B){throw B}};flyui.flyted.BatchWidget.Controller=function(E,A,D){var B="flyui.flyted.BatchWidget.Controller";try{this._model=null;this._service=null;this._controllee=null;this.__init__(E,A,D)}catch(C){throw C}};flyui.flyted.BatchWidget.Controller.prototype.__init__=function(E,A,D){var B="flyui.flyted.BatchWidget.Controller.prototype.__init__";try{this._model=E;this._service=A;this._controllee=D}catch(C){throw C}};flyui.flyted.BatchWidget.Controller.prototype.findImagesByGeneBatch=function(D,C){var A="flyui.flyted.BatchWidget.Controller.prototype.findGenesByAnyNameBatch";try{flyui.info("findImagesByGeneBatch: "+D+" || "+C,A);this._findImagesByGeneBatch(D,C,this._findImagesByGeneBatchSuccess(),this._findImagesByGeneBatchFailure())}catch(B){throw B}};flyui.flyted.BatchWidget.Controller.prototype._findImagesByGeneBatch=function(H,E,G,C){var A="flyui.flyted.BatchWidget.Controller.prototype._findImagesByGeneBatch";try{this._model.set("STATE","PENDING");this._model.set("QUERY",[H,E]);this._model.set("RESULTS",null);this._model.set("MESSAGE",null);var F=[];for(var D=0;D<E.length;D++){F[D]=E[D].flybaseID}this._service.findImagesByFlybaseGeneIDBatch(F,G,C)}catch(B){throw B}};flyui.flyted.BatchWidget.Controller.prototype._findImagesByGeneBatchSuccess=function(){var A="flyui.flyted.BatchWidget.Controller.prototype._findImagesByGeneBatchSuccess";var B=this;return function(E){try{flyui.info("request success",A);B._model.set("RESULTS",E);B._model.set("STATE","READY");var C="Images depict expression patterns of genes involved in spermatogenesis in the testes of Drosophila melanogaster. Empty table cells indicate that no images are available from FlyTED for that gene. See also Carine Barreau, Elizabeth Benson, Elin Gudmannsdottir and Helen White-Cooper, <a href='http://dev.biologists.org/cgi/content/full/135/11/1897'>Post-meiotic transcription in Drosophila testes</a>, Development. 2008 Jun;135(11):1897-902.";B._model.set("MESSAGE",C)}catch(D){throw D}}};flyui.flyted.BatchWidget.Controller.prototype._findImagesByGeneBatchFailure=function(){var A="flyui.flyted.BatchWidget.Controller.prototype._findImagesByGeneBatchFailure";var B=this;return function(C){try{flyui.err("request failed: "+C.status+" "+C.statusText,A);B._model.set("MESSAGE","there was an error retrieving data from the server, see the logs for more info");B._model.set("STATE","SERVERERROR")}catch(D){throw D}}};flyui.flyted.BatchWidget.Controller.prototype.clear=function(){var A="flyui.flyted.BatchWidget.Controller.prototype.clear";try{this._model.set("STATE","READY");this._model.set("QUERY",null);this._model.set("RESULTS",null);this._model.set("MESSAGE",null)}catch(B){throw B}};flyui.flyted.BatchWidget.modelDefinition={properties:["STATE","RESULTS","MESSAGE","QUERY"],values:{"STATE":["READY","PENDING","SERVERERROR","UNEXPECTEDERROR"]},initialize:function(A){A["STATE"]="READY";A["RESULTS"]=null;A["MESSAGE"]=null;A["QUERY"]=null}};flyui.flyted.BatchWidget.DefaultRenderer=function(){};flyui.flyted.BatchWidget.DefaultRenderer.prototype._canvas=null;flyui.flyted.BatchWidget.DefaultRenderer.prototype._pendingPane=null;flyui.flyted.BatchWidget.DefaultRenderer.prototype._resultsSummaryPane=null;flyui.flyted.BatchWidget.DefaultRenderer.prototype._resultsPane=null;flyui.flyted.BatchWidget.DefaultRenderer.prototype._messagePane=null;flyui.flyted.BatchWidget.DefaultRenderer.prototype.setCanvas=function(C){var A="flyui.flyted.BatchWidget.DefaultRenderer.prototype.setCanvas";try{this._canvas=$(C);this._initCanvas()}catch(B){throw B}};flyui.flyted.BatchWidget.DefaultRenderer.prototype._initCanvas=function(){var B="flyui.flyted.BatchWidget.DefaultRenderer.prototype._initCanvas";try{var E=this._canvas;E.addClass("batchFlytedImageWidget");var A=$("<p class='pendingPane'>pending (please wait, this can take up to 10 seconds) ...</p>").hide();E.append(A);this._pendingPane=A;var C=$("<p class='resultsSummaryPane'>this text should never be displayed</p>").hide();E.append(C);this._resultsSummaryPane=C;var F=$("<div class='resultsPane'></div>").hide();E.append(F);this._resultsPane=F;var G=$("<p class='messagePane'>this text should never be displayed</p>").hide();E.append(G);this._messagePane=G}catch(D){throw D}};flyui.flyted.BatchWidget.DefaultRenderer.prototype.connect=function(C){var A="flyui.flyted.BatchWidget.DefaultRenderer.prototype.connect";try{C.subscribeAll(this._onModelChanged,this)}catch(B){throw B}};flyui.flyted.BatchWidget.DefaultRenderer.prototype._onModelChanged=function(G,E,C){var A="flyui.flyted.BatchWidget.DefaultRenderer.prototype._onModelChanged";try{var B={"STATE":"_onStateChanged","QUERY":"_onQueryChanged","RESULTS":"_onResultsChanged","MESSAGE":"_onMessageChanged"};var F=B[G];C[F](E[0],E[1],E[2])}catch(D){throw D}};flyui.flyted.BatchWidget.DefaultRenderer.prototype._onQueryChanged=function(E,D,C){var A="flyui.flyted.BatchWidget.DefaultRenderer.prototype._onQueryChanged";try{}catch(B){throw B}};flyui.flyted.BatchWidget.DefaultRenderer.prototype._onStateChanged=function(E,D,C){var A="flyui.flyted.BatchWidget.DefaultRenderer.prototype._onStateChanged";try{if(D=="PENDING"){this._pendingPane.show();this._messagePane.hide();this._resultsSummaryPane.hide();this._resultsPane.hide()}else{if(D=="READY"){this._pendingPane.hide();this._messagePane.show();this._resultsSummaryPane.show();this._resultsPane.show()}else{if(D=="SERVERERROR"||D=="UNEXPECTEDERROR"){this._pendingPane.hide();this._messagePane.show();this._resultsSummaryPane.hide();this._resultsPane.hide()}else{throw {message:"invalid state: "+D}}}}}catch(B){throw B}};flyui.flyted.BatchWidget.DefaultRenderer.prototype._onResultsChanged=function(F,E,C){var A="flyui.flyted.BatchWidget.DefaultRenderer.prototype._onResultsChanged";try{if(E==null){this._resultsSummaryPane.empty();this._resultsPane.empty()}else{var D=C("QUERY");this._renderResultsSummary(D,E);this._renderResults(D,E)}}catch(B){throw B}};flyui.flyted.BatchWidget.DefaultRenderer.prototype._onMessageChanged=function(E,D,C){var A="flyui.flyted.BatchWidget.DefaultRenderer.prototype._onMessageChanged";try{if(D==null){this._messagePane.empty()}else{this._messagePane.html(D)}}catch(B){throw B}};flyui.flyted.BatchWidget.DefaultRenderer.prototype._renderResultsSummary=function(G,C){var A="flyui.flyted.BatchWidget.DefaultRenderer.prototype._renderResultsSummary";try{var H=G[0];var D=G[1];var F=0;for(genename in C){F+=C[genename].images.length}var E="found "+F+" images from <a href='http://www.fly-ted.org'>www.fly-ted.org</a> ("+flyui.flyted.provenance+") ...";this._resultsSummaryPane.html(E)}catch(B){throw B}};flyui.flyted.BatchWidget.DefaultRenderer.prototype._renderResults=function(O,G){var B="flyui.flyted.BatchWidget.DefaultRenderer.prototype._renderResults";try{var J=O[0];var K=O[1];var M="<table>";M+="<thead><tr><th>gene</th><th>images</th></tr></thead><tbody>";for(var H=0;H<J.length;H++){var E=J[H];var N=K[H].annotationSymbols[0];var D=K[H].flybaseID;M+="<tr><td>"+E+"</td><td>";var C="http://openflydata.org/id/flybase/feature/"+D;if(typeof G[C]!="undefined"||G[C]){var I=G[C].images;for(var F in I){var L="thumbnail image depicting expression of "+I[F].caption;M+='<div class="result">';M+='<a href="'+I[F].flytedURL+'">';M+='<img src="'+I[F].thumbnailURL+'" alt="'+L+'">';M+="</img></a>";M+='<p class="caption">'+I[F].caption+"</p>";M+="</div>"}}M+="</td></tr>"}M+="</tbody></table>";this._resultsPane.html(M)}catch(A){throw A}};flyui.namespace("flyui.flyatlas");flyui.flyatlas.provenance="retrieved on 2008-09-16";flyui.flyatlas.Service=function(){};flyui.flyatlas.Service.prototype=new flyui.sparql.Service();flyui.flyatlas.Service.prototype.getAssaysByAffyProbeId=function(D,G,C){var A="flyui.flyatlas.Service.prototype.getAssaysByAffyProbeId";try{flyui.info("request: "+D,A);var E=flyui.chain(flyui.flyatlas.Service.responseToAssayGroups,G);var F=this._buildQueryForGetAssaysByProbeId(D);this.postQuery(F,E,C)}catch(B){throw new flyui.UnexpectedException(A,B)}};flyui.flyatlas.Service.prototype.getAssaysByFlybaseGeneId=function(D,G,C){var A="flyui.flyatlas.Service.prototype.getAssaysByFlybaseGeneId";try{flyui.info("request: "+D,A);var E=flyui.chain(flyui.flyatlas.Service.responseToAssayGroups,G);var F=this._buildQueryForGetAssaysByFlybaseGeneId(D);this.postQuery(F,E,C)}catch(B){throw new flyui.UnexpectedException(A,B)}};flyui.flyatlas.Service.responseToAssayGroups=function(C){var B="flyui.flyatlas.Service.responseToAssayGroups";try{var E=YAHOO.lang.JSON.parse(C.responseText);var A=flyui.flyatlas.AssayGroup.newInstancesFromResultSet(E);return A}catch(D){throw new flyui.UnexpectedException(B,D)}};flyui.flyatlas.Service.prototype._buildQueryForGetAssaysByProbeId=function(J){var A="flyui.flyatlas.Service.prototype._buildQueryForGetAssaysByProbeId";try{var H="PREFIX xs: <http://www.w3.org/2001/XMLSchema#> \nPREFIX : <http://purl.org/NET/flyatlas/schema#> ";var D='SELECT * WHERE { \n?probedata :affy_id "'+J+'"^^xs:string , ?affy_id ; a :ProbeData ; \n  :fly_present ?whole_present ; \n  :fly_mean ?whole_mean ; \n  :fly_SEM ?whole_sem ; ';function I(K){return"  :"+K+" [ \n    a :TissueVals ; \n    :t_change ?"+K+"_change ; \n    :mean ?"+K+"_mean ; \n    :sem ?"+K+"_sem ; \n    :present ?"+K+"_present ; \n    :ratio ?"+K+"_ratio ; \n  ] ; "}var B=" . }";var G=H;G+=D;for(var E=0;E<flyui.flyatlas.tissues.length;E++){var C=flyui.flyatlas.tissues[E];if(C!="whole"){G+=I(flyui.flyatlas.tissues[E])}}G+=B;return G}catch(F){throw new flyui.UnexpectedException(A,F)}};flyui.flyatlas.Service.prototype._buildQueryForGetAssaysByFlybaseGeneId=function(C){var A="flyui.flyatlas.Service.prototype._buildQueryForGetAssaysByFlybaseGeneId";try{var I="PREFIX xs: <http://www.w3.org/2001/XMLSchema#> \nPREFIX : <http://purl.org/NET/flyatlas/schema#> \nPREFIX fb: <http://openflydata.org/id/flybase/feature/> \n";var E="SELECT * WHERE { \n?probedata :gene fb:"+C+"; \n  a :ProbeData ; \n  :affy_id ?affy_id ; \n  :fly_present ?whole_present ; \n  :fly_mean ?whole_mean ; \n  :fly_SEM ?whole_sem ; \n";function J(K){return"  :"+K+" [ \n    a :TissueVals ; \n    :t_change ?"+K+"_change ; \n    :mean ?"+K+"_mean ; \n    :sem ?"+K+"_sem ; \n    :present ?"+K+"_present ; \n    :ratio ?"+K+"_ratio ; \n  ] ; \n"}var B=" . }";var H=I;H+=E;for(var F=0;F<flyui.flyatlas.tissues.length;F++){var D=flyui.flyatlas.tissues[F];if(D!="whole"){H+=J(flyui.flyatlas.tissues[F])}}H+=B;return H}catch(G){throw new flyui.UnexpectedException(A,G)}};flyui.flyatlas.Service.prototype.getAssaysByFlybaseGeneIdBatch=function(G,I,E){var C="flyui.flyatlas.Service.prototype.getAssaysByFlybaseGeneIdBatch";try{flyui.info("request: "+G,C);if(G.length==0){I({})}else{var D={};for(var F=0;F<G.length;F++){D[G[F]]=[]}var B=flyui.chain(flyui.flyatlas.Service.transformResponseForGetAssaysByFlybaseGeneIdBatch(D),I);var H=this._buildQueryForGetAssaysByFlybaseGeneIdBatch(G);this.postQuery(H,B,E)}}catch(A){throw A}};flyui.flyatlas.Service.prototype._buildQueryForGetAssaysByFlybaseGeneIdBatch=function(G){var B="flyui.flyatlas.Service.prototype._buildQueryForGetAssaysByFlybaseGeneIdBatch";try{var I="PREFIX xs: <http://www.w3.org/2001/XMLSchema#> \nPREFIX : <http://purl.org/NET/flyatlas/schema#> \nPREFIX fb: <http://openflydata.org/id/flybase/feature/> \n";var E="SELECT * WHERE { \n";E+="  {\n    {\n      LET (?gene := fb:"+G[0]+')\n      LET (?flybaseID := "'+G[0]+'")\n    }\n';for(var F=1;F<G.length;F++){E+="    UNION\n    {\n      LET (?gene := fb:"+G[F]+")\n    }\n"}E+="  }\n";E+="  {\n    ?probedata :gene ?gene; \n      a :ProbeData ; \n      :affy_id ?affy_id ; \n      :fly_present ?whole_present ; \n      :fly_mean ?whole_mean ; \n      :fly_SEM ?whole_sem ; \n";function J(K){return"      :"+K+" [ \n        a :TissueVals ; \n        :t_change ?"+K+"_change ; \n        :mean ?"+K+"_mean ; \n        :sem ?"+K+"_sem ; \n        :present ?"+K+"_present ; \n        :ratio ?"+K+"_ratio ; \n      ] ; \n"}var C="    .\n  }\n}";var H=I;H+=E;for(var F=0;F<flyui.flyatlas.tissues.length;F++){var D=flyui.flyatlas.tissues[F];if(D!="whole"){H+=J(flyui.flyatlas.tissues[F])}}H+=C;return H}catch(A){throw A}};flyui.flyatlas.Service.transformResponseForGetAssaysByFlybaseGeneIdBatch=function(B){var A="flyui.flyatlas.Service.transformResponseForGetAssaysByFlybaseGeneIdBatch";return function(G){try{var J=YAHOO.lang.JSON.parse(G.responseText);var E=J.results.bindings;for(var H=0;H<E.length;H++){var D=E[H].gene.value;var I=D.split("/")[D.split("/").length-1];var K=flyui.flyatlas.AssayGroup.newInstanceFromBinding(E[H]);var F=B[I];F[F.length]=K}return B}catch(C){throw C}}};flyui.flyatlas.AssayGroup=function(){this.affy_id=null;this.whole=null;this.brain=null;this.head=null;this.crop=null;this.midgut=null;this.hindgut=null;this.tubule=null;this.ovary=null;this.testis=null;this.acc=null;this.l_tubule=null;this.l_fatbody=null;this.ta_ganglion=null;this.carcass=null;this.sgland=null};flyui.flyatlas.AssayGroup.newInstancesFromResultSet=function(E){var B="flyui.flyatlas.AssayGroup.newInstancesFromResultSet";try{var A=[];for(var D=0;D<E.results.bindings.length;D++){var F=E.results.bindings[D];A[A.length]=flyui.flyatlas.AssayGroup.newInstanceFromBinding(F)}return A}catch(C){throw new flyui.UnexpectedException(B,C)}};flyui.flyatlas.AssayGroup.newInstanceFromBinding=function(F){var A="flyui.flyatlas.AssayGroup.newInstanceFromBinding";try{var E=new flyui.flyatlas.AssayGroup();E.affy_id=F["affy_id"].value;for(var C=0;C<flyui.flyatlas.tissues.length;C++){var D=flyui.flyatlas.tissues[C];E[D]=flyui.flyatlas.Assay.newInstanceFromBinding(F,D)}return E}catch(B){throw new flyui.UnexpectedException(A,B)}};flyui.flyatlas.Assay=function(){this.mean=null;this.present=null;this.sem=null;this.change=null;this.ratio=null};flyui.flyatlas.Assay.newInstanceFromBinding=function(J,E){var A="flyui.flyatlas.Assay.newInstanceFromBinding";try{var H=new flyui.flyatlas.Assay();var C=["mean","sem","present"];for(var F=0;F<C.length;F++){var B=C[F];H[B]=J[E+"_"+B].value}var D=["ratio","change"];if(E=="whole"){H.ratio=1;H.change="None"}else{for(var F=0;F<D.length;F++){var G=D[F];if(J[E+"_"+G]){H[G]=J[E+"_"+G].value}}}return H}catch(I){throw new flyui.UnexpectedException(A,I)}};flyui.flyatlas.tissues=["whole","brain","head","crop","midgut","hindgut","tubule","ovary","testis","acc","l_tubule","l_fatbody","ta_ganglion","carcass","sgland"];flyui.flyatlas.Service.prototype.getProbesAndGenesByExpressionProfile=function(F,H,D,B){var A="flyui.flyatlas.Service.prototype.getProbesAndGenesByExpressionProfile";try{flyui.info("request: "+F,A);var E=flyui.chain(flyui.flyatlas.Service.transformResponseForGetProbesAndGenesByExpressionProfile,H);var G=this._buildQueryForGetProbesAndGenesByExpressionProfile(F,B);this.postQuery(G,E,D)}catch(C){throw new flyui.UnexpectedException(A,C)}};flyui.flyatlas.Service.prototype._buildQueryForGetProbesAndGenesByExpressionProfile=function(E,B){var A="flyui.flyatlas.Service.prototype._buildQueryForGetProbesAndGenesByExpressionProfile";try{var F="PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\nPREFIX : <http://purl.org/NET/flyatlas/schema#>\nSELECT DISTINCT ?probe ?gene WHERE {\n  ?probedata\n";for(var D=1;D<flyui.flyatlas.tissues.length;D++){var G=flyui.flyatlas.tissues[D];var H=E[G];if(H=="Up"||H=="Down"||H=="None"){F+="    :"+G+' [\n      :t_change "'+H+'"^^xsd:string ;\n      a :TissueVals ;\n    ] ;\n'}}F+="    :affy_id ?probe ;\n    :gene ?gene ;\n    a :ProbeData .\n} LIMIT "+B;return F}catch(C){throw new flyui.UnexpectedException(A,C)}};flyui.flyatlas.Service.transformResponseForGetProbesAndGenesByExpressionProfile=function(F){var B="flyui.flyatlas.Service.transformResponseForGetProbesAndGenesByExpressionProfile";try{var L=YAHOO.lang.JSON.parse(F.responseText);var J=[];var H=[];var D=[];var C=L.results.bindings;for(var G=0;G<C.length;G++){var I=C[G].probe.value;var A=C[G].gene.value;var E=A.split("/")[A.split("/").length-1];flyui.util.appendIfNotMember(J,I);flyui.util.appendIfNotMember(H,E);D[D.length]=[I,E]}return{"probes":J,"genes":H,"pairs":D}}catch(K){throw new flyui.UnexpectedException(B,K)}};flyui.namespace("flyui.flyatlas");flyui.flyatlas.Widget=function(A,B){this._controller=null;this._model=null;this._renderer=null;this._service=null;this._init(A,B)};flyui.flyatlas.Widget.prototype._init=function(A,C){try{this._service=A;this._renderer=C;this._model=new flyui.mvcutils.GenericModel2();this._model.setDefinition(flyui.flyatlas.Widget.modelDefinition);this._controller=new flyui.flyatlas.Widget.Controller(this._model,A,this);this._renderer.connect(this._model)}catch(B){throw new flyui.UnexpectedException("flyui.flyatlas.Widget.prototype._init",B)}};flyui.flyatlas.Widget.prototype.getAssaysByAffyProbeId=function(B){try{this._controller.getAssaysByAffyProbeId(B)}catch(A){throw new flyui.UnexpectedException("flyui.flyatlas.Widget.prototype.getAssaysByAffyProbeId",A)}};flyui.flyatlas.Widget.prototype.getAssaysByGene=function(B){try{this._controller.getAssaysByGene(B)}catch(A){throw new flyui.UnexpectedException("flyui.flyatlas.Widget.prototype.getAssaysByGene",A)}};flyui.flyatlas.Widget.Controller=function(C,A,B){this._model=null;this._service=null;this._controllee=null;this._init(C,A,B)};flyui.flyatlas.Widget.Controller.prototype._init=function(C,A,B){this._model=C;this._service=A;this._controllee=B};flyui.flyatlas.Widget.Controller.prototype.getAssaysByAffyProbeId=function(B){try{this._getAssaysByAffyProbeId(B,this._getAssaysSuccess(),this._getAssaysFailure())}catch(A){throw new flyui.UnexpectedException("flyui.flyatlas.Widget.Controller.prototype.getAssaysByAffyProbeId",A)}};flyui.flyatlas.Widget.Controller.prototype.getAssaysByGene=function(B){try{this._getAssaysByGene(B,this._getAssaysSuccess(),this._getAssaysFailure())}catch(A){throw new flyui.UnexpectedException("flyui.flyatlas.Widget.Controller.prototype.getAssaysByGene",A)}};flyui.flyatlas.Widget.Controller.prototype._getAssaysByAffyProbeId=function(C,D,B){try{this._model.set("RESULTS",null);this._model.set("QUERY",C);this._model.set("MODE","PROBE");this._model.set("STATE","PENDING");this._service.getAssaysByAffyProbeId(C,D,B)}catch(A){throw new flyui.UnexpectedException("flyui.flyatlas.Widget.Controller.prototype._getAssaysByAffyProbeId",A)}};flyui.flyatlas.Widget.Controller.prototype._getAssaysByGene=function(D,C,B){try{this._model.set("RESULTS",null);this._model.set("QUERY",D);this._model.set("MODE","GENE");this._model.set("STATE","PENDING");this._service.getAssaysByFlybaseGeneId(D.flybaseID,C,B)}catch(A){throw new flyui.UnexpectedException("flyui.flyatlas.Widget.Controller.prototype._getAssaysByGene",A)}};flyui.flyatlas.Widget.Controller.prototype._getAssaysSuccess=function(){var A=this;return function(B){try{A._model.set("RESULTS",B);A._model.set("STATE","READY")}catch(C){throw new flyui.UnexpectedException("anonymous callback (from flyui.flyatlas.Widget.Controller.prototype._getAssaysSuccess)",C)}}};flyui.flyatlas.Widget.Controller.prototype._getAssaysFailure=function(){var A=this;return function(B){try{flyui.err("request failed: "+B.status+" "+B.statusText);A._model.set("MESSAGE","there was an error retrieving data from the server, see the logs for more info");A._model.set("STATE","SERVERERROR")}catch(C){throw new flyui.UnexpectedException("anonymous callback (from flyui.flyatlas.Widget.Controller.prototype._getAssaysFailure)",C)}}};flyui.flyatlas.Widget.modelDefinition={properties:["STATE","RESULTS","MESSAGE","QUERY","MODE"],values:{"STATE":["READY","PENDING","SERVERERROR","UNEXPECTEDERROR"],"MODE":["PROBE","GENE"]},initialize:function(A){A["STATE"]="READY";A["RESULTS"]=null;A["MESSAGE"]=null;A["QUERY"]=null;A["MODE"]=null}};flyui.flyatlas.Widget.DefaultRenderer=function(){this._canvas=null;this._pendingPane=null;this._resultsPane=null;this._resultsSummaryPane=null;this._messagePane=null};flyui.flyatlas.Widget.DefaultRenderer.prototype.setCanvas=function(B){try{this._canvas=$(B);this._initCanvas()}catch(A){throw new flyui.UnexpectedException("flyui.flyatlas.Widget.DefaultRenderer.prototype.setCanvas",A)}};flyui.flyatlas.Widget.DefaultRenderer.prototype._initCanvas=function(){try{var D=this._canvas;D.addClass("flyatlasWidget");var A=$("<p class='pendingPane'>pending...</p>").hide();D.append(A);this._pendingPane=A;var B=$("<p class='resultsSummaryPane'>this text should never be displayed</p>").hide();D.append(B);this._resultsSummaryPane=B;var E=$("<div class='resultsPane'></div>").hide();D.append(E);this._resultsPane=E;var F=$("<p class='messagePane'>this text should never be displayed</p>").hide();D.append(F);this._messagePane=F}catch(C){throw new flyui.UnexpectedException("flyui.flyatlas.Widget.DefaultRenderer.prototype._initCanvas",C)}};flyui.flyatlas.Widget.DefaultRenderer.prototype.connect=function(B){try{B.subscribeAll(this._onModelChanged,this)}catch(A){throw new flyui.UnexpectedException("flyui.flyatlas.Widget.DefaultRenderer.prototype.connect",A)}};flyui.flyatlas.Widget.DefaultRenderer.prototype._onModelChanged=function(F,D,B){try{var A={"STATE":"_onStateChanged","QUERY":"_onQueryChanged","RESULTS":"_onResultsChanged","MESSAGE":"_onMessageChanged","MODE":"_onModeChanged"};var E=A[F];B[E](D[0],D[1],D[2])}catch(C){throw new flyui.UnexpectedException("flyui.flyatlas.Widget.DefaultRenderer.prototype._onModelChanged",C)}};flyui.flyatlas.Widget.DefaultRenderer.prototype._onQueryChanged=function(C,B,A){};flyui.flyatlas.Widget.DefaultRenderer.prototype._onModeChanged=function(C,B,A){};flyui.flyatlas.Widget.DefaultRenderer.prototype._onStateChanged=function(D,C,B){try{if(C=="PENDING"){this._pendingPane.show();this._messagePane.empty().hide();this._resultsSummaryPane.hide();this._resultsPane.hide()}else{if(C=="READY"){this._pendingPane.hide();this._messagePane.hide();this._resultsSummaryPane.show();this._resultsPane.show()}else{if(C=="SERVERERROR"||C=="UNEXPECTEDERROR"){this._pendingPane.hide();this._messagePane.show();this._resultsSummaryPane.hide();this._resultsPane.hide()}else{throw {message:"invalid state: "+C}}}}}catch(A){throw new flyui.UnexpectedException("flyui.flyatlas.Widget.DefaultRenderer.prototype._onStateChanged",A)}};flyui.flyatlas.Widget.DefaultRenderer.prototype._onResultsChanged=function(F,E,B){try{if(E==null){this._resultsSummaryPane.empty();this._resultsPane.empty()}else{this._resultsSummaryPane.empty();this._resultsPane.empty();var C=B("QUERY");var D=B("MODE");this._renderResultsSummary(D,C,E.length);if(E.length>0){this._renderResults(E)}}}catch(A){throw new flyui.UnexpectedException("flyui.flyatlas.Widget.DefaultRenderer.prototype._onResultsChanged",A)}};flyui.flyatlas.Widget.DefaultRenderer.prototype._onMessageChanged=function(D,C,B){try{this._messagePane.html(C)}catch(A){throw new flyui.UnexpectedException("flyui.flyatlas.Widget.DefaultRenderer.prototype._onMessageChanged",A)}};flyui.flyatlas.Widget.DefaultRenderer.prototype._renderResultsSummary=function(E,D,C){try{var B="found ";B+=C;B+=" matching probe";B+=(C==0||C>1)?"s ":" ";B+="from <a href='http://www.flyatlas.org'>flyatlas.org</a> ("+flyui.flyatlas.provenance+") for ";if(E=="PROBE"){B+="probe "+D}else{if(E=="GENE"){B+="gene <strong>"+D.symbols[0]+"</strong>"}else{throw {message:"unexpected mode: "+E}}}if(C>0){B+=" ..."}this._resultsSummaryPane.html(B)}catch(A){throw new flyui.UnexpectedException("flyui.flyatlas.Widget.DefaultRenderer.prototype._renderResultsSummary",A)}};flyui.flyatlas.Widget.DefaultRenderer.prototype._renderResults=function(E){try{var A=this._resultsPane;var H="<table class='resultsTable'>";H+="<thead><tr><th>probe</th><th>tissue</th><th>mRNA signal</th><th>present call</th><th>enrichment</th><th>affy call</th></thead>";for(var D=0;D<E.length;D++){var J=E[D];H+="<tbody>";for(var F=0;F<flyui.flyatlas.tissues.length;F++){var C=flyui.flyatlas.tissues[F];var G=J[C];var B="";if(C=="whole"){B="top"}else{if(G.change=="Up"){if(G.ratio>2){B="callUp xx"}else{B="callUp x"}}else{if(G.change=="Down"){if(G.ratio<0.5){B="callDown xx"}else{B="callDown x"}}else{B="callNone"}}}H+="<tr class='"+B+"'>";H+=(C=="whole")?"<td rowspan='15'><strong><a href='http://flyatlas.org/probeset.cgi?name="+J.affy_id+"'>"+J.affy_id+"</a></strong></td>":"";H+="<td>"+C+"</td>";H+="<td>"+G.mean+" ± "+G.sem+"</td>";H+="<td>"+G.present+" of 4</td>";H+=(C!="whole")?"<td>"+G.ratio+"</td>":"<td> - </td>";H+=(C!="whole")?"<td>"+G.change+"</td>":"<td> - </td>";H+="</tr>"}H+="</tbody>"}H+="</table>";A.append($(H))}catch(I){throw new flyui.UnexpectedException("flyui.flyatlas.Widget.DefaultRenderer.prototype._renderResults",I)}};flyui.namespace("flyui.flyatlas");flyui.flyatlas.BatchWidget=function(A,D){var B="flyui.flyatlas.BatchWidget";try{this.__init__(A,D)}catch(C){throw C}};flyui.flyatlas.BatchWidget.prototype._controller=null;flyui.flyatlas.BatchWidget.prototype._model=null;flyui.flyatlas.BatchWidget.prototype._renderer=null;flyui.flyatlas.BatchWidget.prototype._service=null;flyui.flyatlas.BatchWidget.prototype.__init__=function(A,D){var B="flyui.flyatlas.BatchWidget.prototype.__init__";try{this._service=A;this._renderer=D;this._model=new flyui.mvcutils.GenericModel2();this._model.setDefinition(flyui.flyatlas.BatchWidget.modelDefinition);this._controller=new flyui.flyatlas.BatchWidget.Controller(this._model,A,this);this._renderer.connect(this._model)}catch(C){throw C}};flyui.flyatlas.BatchWidget.prototype.getAssaysByGeneBatch=function(D,C){var A="flyui.flyatlas.BatchWidget.prototype.getAssaysByGeneBatch";try{this._controller.getAssaysByGeneBatch(D,C)}catch(B){throw B}};flyui.flyatlas.BatchWidget.prototype.clear=function(){var A="flyui.flyatlas.BatchWidget.prototype.clear";try{this._controller.clear()}catch(B){throw B}};flyui.flyatlas.BatchWidget.Controller=function(E,A,D){var B="flyui.flyatlas.BatchWidget.Controller";try{this._model=null;this._service=null;this._controllee=null;this.__init__(E,A,D)}catch(C){throw C}};flyui.flyatlas.BatchWidget.Controller.prototype.__init__=function(E,A,D){var B="flyui.flyatlas.BatchWidget.Controller.prototype.__init__";try{this._model=E;this._service=A;this._controllee=D}catch(C){throw C}};flyui.flyatlas.BatchWidget.Controller.prototype.getAssaysByGeneBatch=function(D,C){var A="flyui.flyatlas.BatchWidget.Controller.prototype.findGenesByAnyNameBatch";try{flyui.info("getAssaysByGeneBatch: "+D+" || "+C,A);this._getAssaysByGeneBatch(D,C,this._getAssaysByGeneBatchSuccess(),this._getAssaysByGeneBatchFailure())}catch(B){throw B}};flyui.flyatlas.BatchWidget.Controller.prototype._getAssaysByGeneBatch=function(F,E,D,C){var A="flyui.flyatlas.BatchWidget.Controller.prototype._getAssaysByGeneBatch";try{this._model.set("STATE","PENDING");this._model.set("QUERY",[F,E]);this._model.set("RESULTS",null);this._model.set("MESSAGE",null);this._service.getAssaysByFlybaseGeneIdBatch(E,D,C)}catch(B){throw B}};flyui.flyatlas.BatchWidget.Controller.prototype._getAssaysByGeneBatchSuccess=function(){var A="flyui.flyatlas.BatchWidget.Controller.prototype._getAssaysByGeneBatchSuccess";var B=this;return function(E){try{flyui.info("request success",A);B._model.set("RESULTS",E);B._model.set("STATE","READY");var C="Values shown are mean mRNA signal plus or minus standard error on the mean; cell background colour indicates results of T-test comparison with whole fly, green is up, red is down, white is no change. Empty cells indicate no data are available for that gene. See also: Chintapalli, V. R., Wang, J. and Dow, J. A. T. (2007) Using FlyAtlas to identify better Drosophila models of human disease, <a href='http://www.nature.com/ng/journal/v39/n6/abs/ng2049.html'>Nature Genetics 39: 715-720</a>.";B._model.set("MESSAGE",C)}catch(D){throw D}}};flyui.flyatlas.BatchWidget.Controller.prototype._getAssaysByGeneBatchFailure=function(){var A="flyui.flyatlas.BatchWidget.Controller.prototype._getAssaysByGeneBatchFailure";var B=this;return function(C){try{flyui.err("request failed: "+C.status+" "+C.statusText,A);B._model.set("MESSAGE","there was an error retrieving data from the server, see the logs for more info");B._model.set("STATE","SERVERERROR")}catch(D){throw D}}};flyui.flyatlas.BatchWidget.Controller.prototype.clear=function(){var A="flyui.flyatlas.BatchWidget.Controller.prototype.clear";try{this._model.set("STATE","READY");this._model.set("QUERY",null);this._model.set("RESULTS",null);this._model.set("MESSAGE",null)}catch(B){throw B}};flyui.flyatlas.BatchWidget.modelDefinition={properties:["STATE","RESULTS","MESSAGE","QUERY"],values:{"STATE":["READY","PENDING","SERVERERROR","UNEXPECTEDERROR"]},initialize:function(A){A["STATE"]="READY";A["RESULTS"]=null;A["MESSAGE"]=null;A["QUERY"]=null}};flyui.flyatlas.BatchWidget.DefaultRenderer=function(){};flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._canvas=null;flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._pendingPane=null;flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._resultsSummaryPane=null;flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._resultsPane=null;flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._messagePane=null;flyui.flyatlas.BatchWidget.DefaultRenderer.prototype.setCanvas=function(C){var A="flyui.flyatlas.BatchWidget.DefaultRenderer.prototype.setCanvas";try{this._canvas=$(C);this._initCanvas()}catch(B){throw B}};flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._initCanvas=function(){var B="flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._initCanvas";try{var E=this._canvas;E.addClass("batchFlyatlasWidget");var A=$("<p class='pendingPane'>pending (please wait, this can take up to 10 seconds) ...</p>").hide();E.append(A);this._pendingPane=A;var C=$("<p class='resultsSummaryPane'>this text should never be displayed</p>").hide();E.append(C);this._resultsSummaryPane=C;var F=$("<div class='resultsPane'></div>").hide();E.append(F);this._resultsPane=F;var G=$("<p class='messagePane'>this text should never be displayed</p>").hide();E.append(G);this._messagePane=G}catch(D){throw D}};flyui.flyatlas.BatchWidget.DefaultRenderer.prototype.connect=function(C){var A="flyui.flyatlas.BatchWidget.DefaultRenderer.prototype.connect";try{C.subscribeAll(this._onModelChanged,this)}catch(B){throw B}};flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._onModelChanged=function(G,E,C){var A="flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._onModelChanged";try{var B={"STATE":"_onStateChanged","QUERY":"_onQueryChanged","RESULTS":"_onResultsChanged","MESSAGE":"_onMessageChanged"};var F=B[G];C[F](E[0],E[1],E[2])}catch(D){throw D}};flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._onQueryChanged=function(E,D,C){var A="flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._onQueryChanged";try{}catch(B){throw B}};flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._onStateChanged=function(E,D,C){var A="flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._onStateChanged";try{if(D=="PENDING"){this._pendingPane.show();this._messagePane.hide();this._resultsSummaryPane.hide();this._resultsPane.hide()}else{if(D=="READY"){this._pendingPane.hide();this._messagePane.show();this._resultsSummaryPane.show();this._resultsPane.show()}else{if(D=="SERVERERROR"||D=="UNEXPECTEDERROR"){this._pendingPane.hide();this._messagePane.show();this._resultsSummaryPane.hide();this._resultsPane.hide()}else{throw {message:"invalid state: "+D}}}}}catch(B){throw B}};flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._onResultsChanged=function(F,E,C){var A="flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._onResultsChanged";try{if(E==null){this._resultsSummaryPane.empty();this._resultsPane.empty()}else{var D=C("QUERY");this._renderResultsSummary(D,E);this._renderResults(D,E)}}catch(B){throw B}};flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._onMessageChanged=function(E,D,C){var A="flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._onMessageChanged";try{if(D==null){this._messagePane.empty()}else{this._messagePane.html(D)}}catch(B){throw B}};flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._renderResultsSummary=function(J,E){var B="flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._renderResultsSummary";try{var G=J[0];var D=J[1];var I="";var H=0;for(var F=0;F<G.length;F++){var C=E[D[F]];H+=C.length}var I="found ";I+=H;I+=" matching probe";I+=(H==0||H>1)?"s ":" ";I+="from <a href='http://flyatlas.org'>flyatlas.org</a> ("+flyui.flyatlas.provenance+") ...";this._resultsSummaryPane.html(I)}catch(A){throw A}};flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._renderResults=function(C,J){var H="flyui.flyatlas.BatchWidget.DefaultRenderer.prototype._renderResults";try{var A=C[0];var R=C[1];var M="<table><thead><tr><th>gene</th><th>probe</th>";for(var P=0;P<flyui.flyatlas.tissues.length;P++){var G=flyui.flyatlas.tissues[P];M+="<th>"+G+"</th>"}M+="</tr></thead>";for(var P=0;P<A.length;P++){var K=A[P];var I=R[P];var S=J[I];M+="<tbody>";if(S.length>0){for(var O=0;O<S.length;O++){M+="<tr>";M+="<td>"+K+"</td>";var E=S[O];M+="<td><a href='http://flyatlas.org/probeset.cgi?name="+E.affy_id+"'>"+E.affy_id+"</a></td>";for(var N=0;N<flyui.flyatlas.tissues.length;N++){var G=flyui.flyatlas.tissues[N];var F=E[G].change;var Q=E[G].mean;var L=E[G].sem;var D="flyatlasChangeNone";if(F=="Up"){D="flyatlasChangeUp"}else{if(F=="Down"){D="flyatlasChangeDown"}}M+="<td class='"+D+"'>"+Q+"±"+L+"</td>"}M+="</tr>"}}else{M+="<tr><td>"+K+"</td></tr>"}M+="</tbody>"}M+="</table>";this._resultsPane.html(M)}catch(B){throw B}};flyui.namespace("flyui.flyatlas");flyui.flyatlas.ProfileWidget=function(A,D){var B="flyui.flyatlas.ProfileWidget";try{this.__init__(A,D)}catch(C){throw C}};flyui.flyatlas.ProfileWidget.prototype._controller=null;flyui.flyatlas.ProfileWidget.prototype._model=null;flyui.flyatlas.ProfileWidget.prototype._renderer=null;flyui.flyatlas.ProfileWidget.prototype._service=null;flyui.flyatlas.ProfileWidget.prototype.__init__=function(A,D){var B="flyui.flyatlas.ProfileWidget.prototype.__init__";try{this._service=A;this._renderer=D;this._resultsReceivedEvent=new YAHOO.util.CustomEvent("RESULTSRECEIVED",this);this._model=new flyui.mvcutils.GenericModel2();this._model.setDefinition(flyui.flyatlas.ProfileWidget.modelDefinition);this._controller=new flyui.flyatlas.ProfileWidget.Controller(this._model,A,this);this._renderer.connect(this._model)}catch(C){throw C}};flyui.flyatlas.ProfileWidget.prototype.getProbesAndGenesByExpressionProfile=function(D,B){var A="flyui.flyatlas.ProfileWidget.prototype.getProbesAndGenesByExpressionProfile";try{this._controller.getProbesAndGenesByExpressionProfile(D,B)}catch(C){throw C}};flyui.flyatlas.ProfileWidget.prototype.subscribe=function(C,D,E){var A="flyui.flyatlas.ProfileWidget.prototype.subscribe";try{if(C=="RESULTSRECEIVED"){this._resultsReceivedEvent.subscribe(D,E)}}catch(B){throw B}};flyui.flyatlas.ProfileWidget.Controller=function(E,A,D){var B="flyui.flyatlas.ProfileWidget.Controller";try{this._model=null;this._service=null;this._controllee=null;this.__init__(E,A,D)}catch(C){throw C}};flyui.flyatlas.ProfileWidget.Controller.prototype.__init__=function(E,A,D){var B="flyui.flyatlas.ProfileWidget.Controller.prototype.__init__";try{this._model=E;this._service=A;this._controllee=D}catch(C){throw C}};flyui.flyatlas.ProfileWidget.Controller.prototype.getProbesAndGenesByExpressionProfile=function(D,B){var A="flyui.flyatlas.ProfileWidget.Controller.prototype.findGenesByAnyNameBatch";try{flyui.info("getProbesAndGenesByExpressionProfile: "+D,A);this._getProbesAndGenesByExpressionProfile(D,this._getProbesAndGenesByExpressionProfileSuccess(),this._getProbesAndGenesByExpressionProfileFailure(),B)}catch(C){throw C}};flyui.flyatlas.ProfileWidget.Controller.prototype._getProbesAndGenesByExpressionProfile=function(E,F,D,B){var A="flyui.flyatlas.ProfileWidget.Controller.prototype._getProbesAndGenesByExpressionProfile";try{this._model.set("STATE","PENDING");this._model.set("QUERY",E);this._model.set("RESULTS",null);this._model.set("MESSAGE",null);this._model.set("LIMIT",B);this._service.getProbesAndGenesByExpressionProfile(E,F,D,B)}catch(C){throw C}};flyui.flyatlas.ProfileWidget.Controller.prototype._getProbesAndGenesByExpressionProfileSuccess=function(){var A="flyui.flyatlas.ProfileWidget.Controller.prototype._getProbesAndGenesByExpressionProfileSuccess";var B=this;return function(F){try{flyui.info("request success",A);B._model.set("RESULTS",F);B._model.set("STATE","READY");var D=B._model.get("LIMIT");if(F.length==D){var C="At most "+D+" results are shown.";B._model.set("MESSAGE",C)}B._controllee._resultsReceivedEvent.fire(F)}catch(E){throw E}}};flyui.flyatlas.ProfileWidget.Controller.prototype._getProbesAndGenesByExpressionProfileFailure=function(){var A="flyui.flyatlas.ProfileWidget.Controller.prototype._getProbesAndGenesByExpressionProfileFailure";var B=this;return function(C){try{flyui.err("request failed: "+C.status+" "+C.statusText,A);B._model.set("MESSAGE","there was an error retrieving data from the server, see the logs for more info");B._model.set("STATE","SERVERERROR")}catch(D){throw D}}};flyui.flyatlas.ProfileWidget.modelDefinition={properties:["STATE","RESULTS","MESSAGE","QUERY","LIMIT"],values:{"STATE":["READY","PENDING","SERVERERROR","UNEXPECTEDERROR"]},initialize:function(A){A["STATE"]="READY";A["RESULTS"]=null;A["MESSAGE"]=null;A["QUERY"]=null;A["LIMIT"]=200}};flyui.flyatlas.ProfileWidget.DefaultRenderer=function(){};flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._canvas=null;flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._pendingPane=null;flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._resultsSummaryPane=null;flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._resultsPane=null;flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._messagePane=null;flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype.setCanvas=function(C){var A="flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype.setCanvas";try{this._canvas=$(C);this._initCanvas()}catch(B){throw B}};flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._initCanvas=function(){var B="flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._initCanvas";try{var E=this._canvas;E.addClass("flyatlasProfileWidget");var A=$("<p class='pendingPane'>pending (please wait, this can take a while) ...</p>").hide();E.append(A);this._pendingPane=A;var C=$("<p class='resultsSummaryPane'>this text should never be displayed</p>").hide();E.append(C);this._resultsSummaryPane=C;var F=$("<div class='resultsPane'></div>").hide();E.append(F);this._resultsPane=F;var G=$("<p class='messagePane'>this text should never be displayed</p>").hide();E.append(G);this._messagePane=G}catch(D){throw D}};flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype.connect=function(C){var A="flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype.connect";try{C.subscribeAll(this._onModelChanged,this)}catch(B){throw B}};flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._onModelChanged=function(G,E,C){var A="flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._onModelChanged";try{var B={"STATE":"_onStateChanged","QUERY":"_onQueryChanged","RESULTS":"_onResultsChanged","MESSAGE":"_onMessageChanged"};var F=B[G];C[F](E[0],E[1],E[2])}catch(D){throw D}};flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._onQueryChanged=function(E,D,C){var A="flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._onQueryChanged";try{}catch(B){throw B}};flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._onStateChanged=function(E,D,C){var A="flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._onStateChanged";try{if(D=="PENDING"){this._pendingPane.show();this._messagePane.hide();this._resultsSummaryPane.hide();this._resultsPane.hide()}else{if(D=="READY"){this._pendingPane.hide();this._messagePane.show();this._resultsSummaryPane.show();this._resultsPane.show()}else{if(D=="SERVERERROR"||D=="UNEXPECTEDERROR"){this._pendingPane.hide();this._messagePane.show();this._resultsSummaryPane.hide();this._resultsPane.hide()}else{throw {message:"invalid state: "+D}}}}}catch(B){throw B}};flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._onResultsChanged=function(E,D,C){var A="flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._onResultsChanged";try{if(D==null){this._resultsSummaryPane.empty();this._resultsPane.empty()}else{this._renderResultsSummary(D);this._renderResults(D)}}catch(B){throw B}};flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._onMessageChanged=function(E,D,C){var A="flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._onMessageChanged";try{if(D==null){this._messagePane.empty()}else{this._messagePane.html(D)}}catch(B){throw B}};flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._renderResultsSummary=function(C){var A="flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._renderResultsSummary";try{var D="found "+C.pairs.length+" results ("+C.probes.length+" distinct probe IDs, "+C.genes.length+" distinct gene IDs) from <a href='http://flyatlas.org'>flyatlas.org</a> ("+flyui.flyatlas.provenance+") ...";this._resultsSummaryPane.html(D)}catch(B){throw B}};flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._renderResults=function(F){var B="flyui.flyatlas.ProfileWidget.DefaultRenderer.prototype._renderResults";try{var H="<strong>matching probes: </strong>";for(var G=0;G<F.probes.length;G++){var C=F.probes[G];H+="<strong><a href='http://flyatlas.org/probeset.cgi?name="+C+"'>"+C+"</a></strong> (";var I=0;for(var E=0;E<F.pairs.length;E++){var D=F.pairs[E];if(D[0]==C){if(I>0){H+=", "}H+="<a href='http://flybase.org/reports/"+D[1]+".html'>"+D[1]+"</a>";I++}}H+="); "}this._resultsPane.html(H)}catch(A){throw A}};flyui.namespace("flyui.flybasepub");flyui.flybasepub.Service=function(A){this._endpoint=A};flyui.flybasepub.Service.prototype=new flyui.sparql.Service();flyui.flybasepub.Service.prototype.findPubsByUniqueGeneName=function(C,H,E,B){var A="flyui.flybasepub.Service.prototype.findPubsByUniqueGeneName";try{flyui.info("request: "+C,A);var F=flyui.chain(flyui.flybasepub.Service.responseToGene,H);var G=flyui.flybasepub.Service._buildQueryForFindPubsByUniqueGeneName(C,B);this.postQuery(G,F,E)}catch(D){throw new flyui.UnexpectedException(A,D)}};flyui.flybasepub.Service.responseToGene=function(B){var A="flyui.flybasepub.Service.responseToGene";try{var D=YAHOO.lang.JSON.parse(B.responseText);var E=flyui.flybasepub.Publication.newInstancesFromSPARQLResults(D);return E}catch(C){throw new flyui.UnexpectedException(A,C)}};flyui.flybasepub.Service._buildQueryForFindPubsByUniqueGeneName=function(D,C){var B="flyui.flybasepub.Service._buildQueryForFindPubsByUniqueGeneName";try{var G="PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\nPREFIX chado: <http://purl.org/net/chado/schema/>\nPREFIX so: <http://purl.org/obo/owl/SO#>\n";var A='SELECT DISTINCT ?flybaseID ?pub ?title ?miniref ?uniquename WHERE {\n  ?flybaseID \n	 chado:uniquename	"'+D+'"^^xsd:string ;\n    a so:SO_0000704 ;\n    chado:organism <http://openflydata.org/id/flybase/organism/Drosophila_melanogaster> ;\n    chado:feature_pub ?pub .\n	 ?pub a chado:Pub ;\n	 	chado:uniquename ?uniquename .\n  OPTIONAL { ?pub chado:title ?title }\n  OPTIONAL { ?pub chado:pyear ?pyear }\n  OPTIONAL { ?pub chado:miniref ?miniref }\n} orderby desc(?pyear) limit '+C+"\n";var F=G+A;return F}catch(E){throw new flyui.UnexpectedException(B,E)}};flyui.flybasepub.Publication=function(){var A=this;this.flybaseID=null;this.pubID=null;this.title="";this.pyear="";this.miniref=""};flyui.flybasepub.Publication.newInstancesFromSPARQLResults=function(F){var A="flyui.flybasepub.Publication.newInstancesFromSPARQLResults";try{var E=new flyui.flybasepub.PublicationPool();var H=F.results.bindings;for(var D in H){var B=H[D].flybaseID.value;var G=H[D].pub.value;if(G.search(/unattributed/)==-1){publication=E.get(G);publication.flybaseID=B;publication.uniquename=H[D].uniquename.value;if(H[D].title){publication.title=H[D].title.value}if(H[D].pyear){publication.pyear=H[D].pyear.value}if(H[D].miniref){publication.miniref=H[D].miniref.value}}}return E.toArray()}catch(C){throw new flyui.UnexpectedException(A,C)}};flyui.flybasepub.PublicationPool=function(){this._pool=new Object()};flyui.flybasepub.PublicationPool.prototype.get=function(D){var B="flyui.flybasepub.PublicationPool.prototype.get";try{var A=this._pool[D];if(typeof A=="undefined"||!A){A=new flyui.flybasepub.Publication();A.pubID=D;this._pool[D]=A}return A}catch(C){throw new flyui.UnexpectedException(B,C)}};flyui.flybasepub.PublicationPool.prototype.toArray=function(){var A="flyui.flybasepub.PublicationPool.prototype.toArray";try{var D=new Array();for(var C in this._pool){D[D.length]=this._pool[C]}return D}catch(B){throw new flyui.UnexpectedException(A,B)}};flyui.namespace("flyui.flybasepub");flyui.flybasepub.PublicationWidget=function(A,D){try{var C=this;this._controller=null;this._renderer=D;this._model=null;this._renderer=null;this._service=null;this._init=function(){var E=new flyui.mvcutils.GenericModel2();E.setDefinition(flyui.flybasepub.PublicationWidget.modelDefinition);this._controller=new flyui.flybasepub.PublicationWidget.Controller(E,A,this);D.connect(E)};this._init(A,D)}catch(B){throw new flyui.UnexpectedException("flyui.flybasepub.PublicationWidget",B)}};flyui.flybasepub.PublicationWidget.prototype.findPublicationsByFlybaseGeneID=function(A){try{this._controller.findPublicationsByFlybaseGeneID(A)}catch(B){throw new flyui.UnexpectedException("flyui.flybasepub.PublicationWidget.prototype.findPublicationsByFlybaseGeneID",B)}};flyui.flybasepub.PublicationWidget.prototype.findPublicationsByGene=function(B){try{this._controller.findPublicationsByGene(B)}catch(A){throw new flyui.UnexpectedException("flyui.flybasepub.PublicationWidget.prototype.findPublicationsByGene",A)}};flyui.flybasepub.PublicationWidget.Controller=function(B,A,D){var C=this;this._model=B;this._service=A;this._parent=D;this._findPublicationsSuccess=function(F){try{flyui.info("request success");C._model.set("RESULTS",F);C._model.set("STATE","READY")}catch(E){throw new flyui.UnexpectedException("_findPublicationsSuccess",E)}};this._findPublicationsFailure=function(E){try{flyui.err("request failed, status "+E.status+" "+E.statusText);var G="There was an error retrieving data from FlyBase, see the logs for more info. The server may be busy or down, please try again later. If this message persists, please contact the Image Bioinformatics Research Group at bioimage@mail.ontonet.org.";C._model.set("ERRORMESSAGE",G);C._model.set("STATE","SERVERERROR")}catch(F){throw new flyui.UnexpectedException("_findPublicationsFailure",F)}}};flyui.flybasepub.PublicationWidget.Controller.prototype._limit=100;flyui.flybasepub.PublicationWidget.Controller.prototype.findPublicationsByFlybaseGeneID=function(B){try{this._findPublicationsByFlybaseGeneID(B,this._findPublicationsSuccess,this._findPublicationsFailure)}catch(A){throw new flyui.UnexpectedException("flyui.flybasepub.PublicationWidget.Controller.prototype.findPublicationsByFlybaseGeneID",A)}};flyui.flybasepub.PublicationWidget.Controller.prototype._findPublicationsByFlybaseGeneID=function(C,D,B){try{flyui.info("flyui.flybasepub.PublicationWidget.Controller._findPublicationsByFlybaseGeneID :: request: "+C);this._model.set("RESULTS",null);this._model.set("STATE","PENDING");this._model.set("QUERY",C);this._service.findPubsByUniqueGeneName(C,D,B,this._limit)}catch(A){throw new flyui.UnexpectedException("flyui.flybasepub.PublicationWidget.Controller._findPublicationsByFlybaseGeneID",A)}};flyui.flybasepub.PublicationWidget.Controller.prototype.findPublicationsByGene=function(B){try{this._findPublicationsByGene(B,this._findPublicationsSuccess,this._findPublicationsFailure)}catch(A){throw new flyui.UnexpectedException("flyui.flybasepub.PublicationWidget.Controller.prototype.findPublicationsByFlybaseGeneID",A)}};flyui.flybasepub.PublicationWidget.Controller.prototype._findPublicationsByGene=function(D,C,B){try{flyui.info("flyui.flybasepub.PublicationWidget.Controller._findPublicationsByGene :: request: "+D.flybaseID);this._model.set("RESULTS",null);this._model.set("STATE","PENDING");this._model.set("QUERY",D);this._service.findPubsByUniqueGeneName(D.flybaseID,C,B,this._limit)}catch(A){throw new flyui.UnexpectedException("flyui.flybasepub.PublicationWidget.Controller._findPublicationsByGene",A)}};flyui.flybasepub.PublicationWidget.modelDefinition={properties:["STATE","RESULTS","QUERY","ERRORMESSAGE"],values:{"STATE":["PENDING","READY","SERVERERROR","UNEXPECTEDERROR"]},initialize:function(A){A["STATE"]="READY";A["RESULTS"]=null;A["QUERY"]=null;A["ERRORMESSAGE"]=null}};flyui.flybasepub.PublicationWidget.DefaultRenderer=function(){this._canvas=null;this._pendingPane=null;this._resultsPane=null;this._resultsSummaryPane=null;this._messagePane=null;this._explanationPane=null};flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype.setCanvas=function(B){try{this._canvas=$(B);this._initCanvas()}catch(A){throw new flyui.UnexpectedException("flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype.setCanvas",A)}};flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._initCanvas=function(){var D="flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._initCanvas";try{var G=this._canvas;G.addClass("flybasePublicationWidget");var C=$("<p class='pendingPane'>pending...</p>").hide();G.append(C);this._pendingPane=C;var A=$("<p class='messagePane'>this text should never be displayed</p>").hide();G.append(A);this._messagePane=A;var E=$("<p class='resultsSummaryPane'>this text should never be displayed</p>").hide();G.append(E);this._resultsSummaryPane=E;var H=$("<div class='resultsPane'></div>").hide();G.append(H);this._resultsPane=H;var B=$("<p class='explanationPane'>this text should never be displayed</p>").hide();G.append(B);this._explanationPane=B}catch(F){throw new flyui.UnexpectedException("flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._initCanvas",F)}};flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._onModelChanged=function(G,E,C){var A="flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._onModelChanged";try{var B={"STATE":"_onStateChanged","QUERY":"_onQueryChanged","RESULTS":"_onResultsChanged","ERRORMESSAGE":"_onErrorMessageChanged"};var F=B[G];C[F](E[0],E[1],E[2])}catch(D){throw new flyui.UnexpectedException("flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._onModelChanged",D)}};flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._onStateChanged=function(E,D,C){var A="flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._onStateChanged";try{if(D=="PENDING"){this._pendingPane.show();this._messagePane.empty().hide();this._resultsSummaryPane.hide();this._resultsPane.hide();this._explanationPane.hide()}else{if(D=="READY"){this._pendingPane.hide();this._messagePane.hide();this._resultsSummaryPane.show();this._resultsPane.show()}else{if(D=="SERVERERROR"||D=="UNEXPECTEDERROR"){this._pendingPane.hide();this._messagePane.show();this._resultsSummaryPane.hide();this._resultsPane.hide();this._explanationPane.hide()}else{throw {name:"flyui.flybasepub.PublicationWidget.UnexpectedStateError",message:"Invalid state: "+newState}}}}}catch(B){throw new flyui.UnexpectedException(A,B)}};flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._onQueryChanged=function(C,B){try{this._query=B}catch(A){throw new flyui.UnexpectedException("flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._onQueryChanged",A)}};flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._onResultsChanged=function(D,C){var A="flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._onResultsChanged";try{if(C==null){this._resultsPane.empty();this._resultsSummaryPane.empty();this._explanationPane.empty()}else{this._resultsSummaryPane.empty();this._resultsPane.empty();this._renderResultsSummary(this._query,C.length);if(C.length>0){this._renderResults(C)}else{}}}catch(B){throw new flyui.UnexpectedException(A,B)}};flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._onErrorMessageChanged=function(C,B){try{this._messagePane.innerHTML=B}catch(A){throw new flyui.UnexpectedException("flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._onErrorMessageChanged",A)}};flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype.connect=function(B){try{B.subscribeAll(this._onModelChanged,this)}catch(A){throw new flyui.UnexpectedException("flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype.connect",A)}};flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._renderResultsSummary=function(E,D){var A="flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._renderResultsSummary";try{if(E instanceof flyui.flybase.Gene){E=E.flybaseID}var C="";if(D<30){C+="found <span>";C+=D;C+="</span> publication";C+=(D==0||D>1)?"s ":" "}else{C+="found more than 30 publications";C+=" (only the most recent 30 records displayed) "}C+="from <a href='http://www.flybase.org'>www.flybase.org</a> for ";C+="<a href='http://flybase.org/reports/"+E+".html'>"+E+"</a>";C+=" (data retrieved on 2009-02). ";C+="A full list of publicaiton can be found from ";C+="<a href='http://flybase.org/reports/"+E+".html'>www.flybase.org</a>";C+=" ...";this._resultsSummaryPane.html(C)}catch(B){throw new flyui.UnexpectedException(A,B)}};flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._renderResults=function(G){var A="flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._renderResults";try{var H=this._resultsPane;var F="<table class='resultsTable'>";F+="<thead><tr><th>Number</th><th>Mini Reference</th><th>Title</th><th>Year</th></tr></thead>";var E=0;for(var C in G){if(G[C]){if(E<30){var D=parseInt(C)+1;F+=this._publicationToDivHTML(G[C],D);E++}}}F+="</table>";H.append($(F))}catch(B){throw new flyui.UnexpectedException("flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._imagesToDivHTML",B)}};flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._publicationToDivHTML=function(B,E){var A="flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._publicationToDivHTML";try{var D="<tr>";D+="<td>"+E+"</td>";D+="<td>"+B.miniref+"</td>";D+="<td>"+B.title+"</td>";D+="<td>"+B.pyear+"</td>";D+="</tr>";return D}catch(C){throw new flyui.UnexpectedException("flyui.flybasepub.PublicationWidget.DefaultRenderer.prototype._imageToDivHTML",C)}};flyui.flybasepub.PublicationWidget.SimpleRenderer=function(){};flyui.flybasepub.PublicationWidget.SimpleRenderer.prototype=new flyui.flybasepub.PublicationWidget.DefaultRenderer();flyui.flybasepub.PublicationWidget.SimpleRenderer.prototype._renderResultsSummary=function(F,E){var A="flyui.flybasepub.PublicationWidget.SimpleRenderer.prototype._renderResultsSummary";try{var D="";D+="found "+E+" reference";D+=(E==0||E>1)?"s ":" ";D+="from <a href='http://flybase.org'>flybase.org</a> ("+flyui.flybase.provenance+") for gene ";var G=F;var B=F;if(F instanceof flyui.flybase.Gene){G=F.symbols[0];B=F.flybaseID}D+="<strong>"+G+"</strong> ";if(E==100){D+="(only "+flyui.flybasepub.PublicationWidget.Controller.prototype._limit+" most recent results are shown, see FlyBase gene report <a href='http://flybase.org/reports/"+B+".html'>"+B+"</a> for a complete list)"}else{D+="(FlyBase report: <a href='http://flybase.org/reports/"+B+".html'>"+B+"</a>) "}D+=" ...";this._resultsSummaryPane.html(D)}catch(C){throw C}};flyui.flybasepub.PublicationWidget.SimpleRenderer.prototype._renderResults=function(G){var A="flyui.flybasepub.PublicationWidget.SimpleRenderer.prototype._renderResults";try{var H=this._resultsPane;var F="<table class='resultsTable'>";F+="<tbody>";var E=0;for(var C=0;C<G.length;C++){var D=G[C];F+="<tr><td>"+D.miniref+"<br/>"+D.title+" [<a href='http://flybase.org/reports/"+D.uniquename+".html'>"+D.uniquename+"</a>]</td></tr>"}F+="</tbody></table>";H.append($(F))}catch(B){throw B}}