js.ontology-service-result.min.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of molgenis-ontology Show documentation
Show all versions of molgenis-ontology Show documentation
Plugin module containing SORTA (system for ontology-based re-coding and technical
annotation)
plugins.
(function(c,m){var i=new m.RestClient();var p=null;var o=null;var k="identifier";var d="N/A";var h=5;m.OntologyService=function f(s,t){if(s){o=s}if(t){p=t;p.entityPager={start:0,num:h,total:5}}};m.OntologyService.prototype.renderPage=function(){var s=[];s.push('');s.push('');s.push('The total number of matched items is ');s.push('');s.push("
");s.push('');s.push('The total number of unmatched items is ');s.push('');s.push("
");s.push('');s.push('');s.push("");s.push("");o.empty().append(s.join(""));t(function(x){var w={};var v=x.numberOfMatched;var u=x.numberOfUnmatched;w.total=p.matched?v:u;n(w);c("#matched-item-count").html(v);c("#unmatched-item-count").html(u)});c("#sorta-download-button").click(function(){c(this).parents("form:eq(0)").attr({action:m.getContextUrl()+"/match/download/"+p.sortaJobExecutionId,method:"GET"}).submit()});c("#matched-result-button").click(function(){p.matched=true;m.OntologyService.prototype.renderPage()});c("#unmatched-result-button").click(function(){p.matched=false;m.OntologyService.prototype.renderPage()});function t(u){c.ajax({type:"GET",url:m.getContextUrl()+"/count/"+p.sortaJobExecutionId,contentType:"application/json",success:function(v){if(u!==null&&typeof u==="function"){u(v)}}})}};function n(s){c.extend(p.entityPager,s);c.ajax({type:"POST",url:m.getContextUrl()+"/match/retrieve",async:false,data:JSON.stringify(p),contentType:"application/json",success:function(w){var v=c("").addClass("col-md-12");if(w.items.length>0){var y=c("").addClass("row").appendTo(v);var z=[];z.push('');z.push('Filter');z.push('');z.push('');z.push("");var t=c("").addClass("row").css({"margin-bottom":"10px"}).appendTo(v);t.append(z.join(""));t.append(''+(p.matched?"Matched result":"Unmatched result")+"
");var u=[];u.push('');u.push('Input term Best candidate Score Manual Match '+(p.matched?"Remove ":"")+" ");u.push("
");c("").addClass("row").append(u.join("")).appendTo(v);var C=c(v).find("table:eq(0)");c.each(w.items,function(E,D){C.append(g(D,p.matched,s))});var x=t.find("button:eq(0)");var A=t.find("input:eq(0)");c(x).click(function(){if(p.filterQuery!==c(A).val()){p.filterQuery=c(A).val();n(s)}return false});c(A).keyup(function(D){if(D.keyCode===13||c(this).val()===""){c(x).click()}});c(y).pager({page:Math.floor(w.start/w.num)+(w.start%w.num==0?0:1)+1,nrItems:w.total,nrItemsPerPage:w.num,onPageChange:n})}else{var B=[];B.push('There are no results!
');if(p.filterQuery){B.push("Clear the query : "+p.filterQuery+" ");B.push('')}B.push("
");v.append(B.join(""));c(v).find("span.glyphicon-remove:eq(0)").click(function(){p.filterQuery="";n(s)})}o.children("div.row:gt(0)").empty();c("").addClass("row").append(v).appendTo(o)}})}m.OntologyService.prototype.deleteMatchingTask=function(s,t){c.ajax({type:"POST",url:m.getContextUrl()+"/delete",async:false,data:JSON.stringify(s),contentType:"application/json",success:function(){if(t){t()}}})};function g(u,s,v){var w=c(" ");w.append(q(u.inputTerm));w.append(e(u.inputTerm,u.ontologyTerm));c(" ").append(u.matchedTerm.score?u.matchedTerm.score.toFixed(2)+"%":d).appendTo(w);if(s){c(" ").append('').appendTo(w);c(" ").append(u.matchedTerm.validated?'':"").appendTo(w);w.find("button:eq(0)").click(function(){a(u.inputTerm.Identifier,p.sortaJobExecutionId,function(z){var x={};c.map(u.matchedTerm,function(B,A){if(A!=="identifier"){x[A]=B}if(A==="validated"){x[A]=false}if(A==="inputTerm"){x[A]=B.Identifier}});if(z.ontologyTerms&&z.ontologyTerms.length>0){var y=z.ontologyTerms[0];x.score=y.Score;x.matchTerm=y.ontologyTermIRI}else{x.score=0;x.matchTerm=null}i.update("/api/v1/"+p.sortaJobExecutionId+"/"+u.matchedTerm.identifier,x,j(),true)})})}else{var t=c('').click(function(){a(u.inputTerm.Identifier,p.sortaJobExecutionId,function(x){b(u.inputTerm,x,w,v)})});c(" ").append(t).appendTo(w)}return w}function b(x,v,B,y){if(v.message){console.log("Error fetching candidate mappings",v.message);throw v.message}var s=c('').css({"margin-bottom":"20px"});B.parents("table:eq(0)").hide();B.parents("div:eq(0)").append(s);var C=c('').css({"margin-bottom":"10px","float":"right"}).click(function(){s.remove();B.parents("table:eq(0)").show()});var t=c('').css({"margin-bottom":"10px","margin-right":"10px","float":"right"}).click(function(){r(x.Identifier,p.sortaJobExecutionId,function(F){if(F.items.length>0){var G=F.items[0];var E="/api/v1/"+p.sortaJobExecutionId+"/"+G.identifier;var D={};c.map(G,function(I,H){D[H]=I;if(H==="validated"){D[H]=true}if(H==="inputTerm"){console.log("inputTerm",I);D[H]=I.Identifier}if(H==="score"){D[H]=0}if(H==="matchTerm"){D[H]=null}});i.update(E,D,j(),true)}})});var z=c("Adjusted score ?").css({cursor:"pointer"}).popover({title:"Explanation",content:'Adjusted scores are derived from the original scores (lexical similarity) combined with the weight of the words (inverse document frequency)
',placement:"auto",trigger:"hover",html:true});var A=c('
');var w=c(" ").appendTo(A);c(" ").append("Input term").css({width:"30%"}).appendTo(w);c(" ").append("Candidate mapping").css({width:"40%"}).appendTo(w);c(" ").append("Score").css({width:"12%"}).appendTo(w);c(" ").append(z).css({width:"12%"}).appendTo(w);c(" ").append("Select").appendTo(w);var u;if(v.ontologyTerms&&v.ontologyTerms.length>0){u=c('The candidate ontology terms are sorted based on similarity score, please select one of them by clicking button
');c.each(v.ontologyTerms,function(E,D){if(E>=20){return}var F=c(" ").appendTo(A);F.append(E==0?q(x):" ");F.append(e(x,D));F.append(""+D.Score.toFixed(2)+"% ");F.append(""+D.Combined_Score.toFixed(2)+"% ");F.append(' ');F.data("ontologyTerm",D);F.find("button:eq(0)").click(function(){r(x.Identifier,p.sortaJobExecutionId,function(I){if(I.items.length>0){var J=I.items[0];var H="/api/v1/"+p.sortaJobExecutionId+"/"+J.identifier;var G={};c.map(J,function(L,K){if(K==="validated"){G[K]=true}else{if(K==="inputTerm"){G[K]=L.Identifier}else{if(K==="matchTerm"){G.matchTerm=F.data("ontologyTerm").ontologyTermIRI}else{if(K==="score"){G.score=F.data("ontologyTerm").Score}else{G[K]=L}}}}});i.update(H,G,j(),true)}})})})}else{u=c('There are no candidate mappings for this input term!
');c(" ").append(q(x)).append(""+d+" "+d+" "+d+" "+d+" ").appendTo(A)}c('').append(u).append(C).append(t).append(A).appendTo(s)}function j(){return{success:function(){m.OntologyService.prototype.renderPage()},error:function(){m.OntologyService.prototype.renderPage()}}}function r(t,s,u){i.getAsync("/api/v1/"+s,{q:[{field:"inputTerm",operator:"EQUALS",value:t}],expand:["inputTerm"]},function(v){if(u){u(v)}})}function a(t,s,u){c.ajax({type:"POST",url:m.getContextUrl()+"/match/entity",async:false,data:JSON.stringify({identifier:t,sortaJobExecutionId:s}),contentType:"application/json",success:function(v){if(v.message){throw v.message}if(u){u(v)}}})}function q(s){var t=c(" ");if(s){c.map(s?s:{},function(v,u){if(u.toLowerCase()!==k.toLowerCase()){t.append(""+u+" : "+v+"")}})}return t}function e(v,u){var t=c(" ");if(v&&u){var x=c("Synonym : ");var s=l(u);if(s.length==0){x.append(d)}else{if(s.length==1){x.append(s.join())}else{x.addClass("show-popover").append(""+s.length+" synonyms, see more details").popover({content:s.join("
"),placement:"auto",trigger:"hover",html:true})}}if(u.ontologyTermIRI.startsWith("http")){t.append('Name : '+u.ontologyTermName+"").append(x)}else{t.append("Name : "+u.ontologyTermName+"").append(x)}var w={};c.each(u.ontologyTermDynamicAnnotation,function(z,y){if(!w[y.name]){w[y.name]=[]}w[y.name].push(y.value)});c.each(Object.keys(v),function(y,z){if(z.toLowerCase()!=="name"&&z.toLowerCase().search("synonym")===-1&&z.toLowerCase()!==k.toLowerCase()){t.append(""+z+" : "+(w[z]?w[z].join():"N/A")+"")}})}else{t.append(d)}return t}function l(t){var s=[];if(t.ontologyTermSynonym.length>0){c.each(t.ontologyTermSynonym,function(v,u){if(t.ontologyTermName!==u.ontologyTermSynonym&&c.inArray(u.ontologyTermSynonym,s)===-1){s.push(u.ontologyTermSynonym)}})}return s}}($,window.top.molgenis=window.top.molgenis||{}));