UNPKG

homology

Version:
3 lines 25.2 kB
/*! Homology.js, version 0.6.0. Developed by Eric Weitz. https://github.com/eweitz/homology. Public domain (CC0 1.0). */ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(window,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="/dist",r(r.s=2)}([function(t,e,r){t.exports=r(1)},function(t,e,r){var n=function(t){"use strict";var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,a=Object.create(o.prototype),i=new j(n||[]);return a._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return E()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var u=x(i,r);if(u){if(u===l)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),a}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function p(){}function h(){}var d={};d[o]=function(){return this};var v=Object.getPrototypeOf,m=v&&v(v(k([])));m&&m!==e&&r.call(m,o)&&(d=m);var g=h.prototype=f.prototype=Object.create(d);function y(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){var n;this._invoke=function(o,a){function i(){return new e((function(n,i){!function n(o,a,i,u){var c=s(t[o],t,a);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,i,u)}),(function(t){n("throw",t,i,u)})):e.resolve(f).then((function(t){l.value=t,i(l)}),(function(t){return n("throw",t,i,u)}))}u(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function k(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:E}}function E(){return{value:void 0,done:!0}}return p.prototype=g.constructor=h,h.constructor=p,p.displayName=u(h,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,u(t,i,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},y(b.prototype),b.prototype[a]=function(){return this},t.AsyncIterator=b,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new b(c(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},y(g),u(g,i,"Generator"),g[o]=function(){return this},g.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,l):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},function(t,e,r){"use strict";r.r(e);var n=r(0),o=r.n(n);function a(t){var e;return(e=t.split(" "))[0][0].toUpperCase()+e[0].slice(1)+" "+e.slice(1).join(" ")}function i(t){var e,r,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,c=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;throw null!==u&&(u=a(u)),null!==c&&(c=a(c[0])),e={geneNotFound:'Gene "'.concat(i,'" not found in source organism "').concat(u,'"'),orthologsNotFound:'Orthologs not found for gene "'.concat(i,'"'),orthologsNotFoundInTarget:'Orthologs not found for gene "'.concat(i,'" in target organism "').concat(c,'"')},n=o?"<br/><small>".concat(o.message,"</small>"):"",r=e[t]+n,new Error(r)}function u(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==r)return;var n,o,a=[],i=!0,u=!1;try{for(r=r.call(t);!(i=(n=r.next()).done)&&(a.push(n.value),!e||a.length!==e);i=!0);}catch(t){u=!0,o=t}finally{try{i||null==r.return||r.return()}finally{if(u)throw o}}return a}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return c(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function s(t,e,r,n,o,a,i){try{var u=t[a](i),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function l(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){s(a,n,o,i,u,"next",t)}function u(t){s(a,n,o,i,u,"throw",t)}i(void 0)}))}}var f="https://omabrowser.org/api";function p(t,e){return h.apply(this,arguments)}function h(){return(h=l(o.a.mark((function t(e,r){var n,a,i,u,c,s,l,f,p;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n="https://www.uniprot.org/uniprot/?format=tab&"+(a="columns=id,entry name,genes")+"&sort=score",i="&query=gene:"+e+"+AND+organism:"+r,t.next=5,fetch(n+i);case 5:return u=t.sent,t.next=8,u.text();case 8:c=t.sent,s=c.split("\n").slice(1,-1),l=0;case 11:if(!(l<s.length)){t.next=20;break}if(a=s[l].split("\t"),f=a[2].split(" ").map((function(t){return t.toLowerCase()})),p=a[0],!f.includes(e.toLowerCase())){t.next=17;break}return t.abrupt("return",p);case 17:l++,t.next=11;break;case 20:throw Error('No Uniprot entry found for gene name "'+e+'" in organism "'+r+'"');case 21:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function d(t){return v.apply(this,arguments)}function v(){return(v=l(o.a.mark((function t(e){var r,n,a;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=f+"/protein/"+e+"/orthologs/",t.next=3,fetch(r);case 3:return n=t.sent,t.next=6,n.json();case 6:if(a=t.sent,404!==n.status){t.next=9;break}throw Error('OMA orthologs not found for Uniprot protein "'+e+'".');case 9:return t.abrupt("return",a);case 10:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function m(t){return g.apply(this,arguments)}function g(){return(g=l(o.a.mark((function t(e){var r,n,a;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=f+"/protein/"+e+"/",t.next=3,fetch(r);case 3:return n=t.sent,t.next=6,n.json();case 6:if(a=t.sent,404!==n.status){t.next=9;break}throw Error('OMA protein not found for Uniprot protein "'+e+'".');case 9:return t.abrupt("return",a);case 10:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function y(t){var e,r;if("homo sapiens"===t)return"HUMAN";if("mus musculus"===t)return"MOUSE";var n=u(t.split(" "),2);return e=n[0],r=n[1],(e.slice(0,3)+r.slice(0,2)).toUpperCase()}function b(){return(b=l(o.a.mark((function t(e,r,n){var a,u,c,s,l,f,h,v,g,b;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:b=[],v=0;case 2:if(!(v<e.length)){t.next=34;break}return g=e[v],t.prev=4,t.next=7,p(g,r);case 7:return a=t.sent,t.next=10,m(a);case 10:u=t.sent,t.next=16;break;case 13:t.prev=13,t.t0=t.catch(4),i("geneNotFound",t.t0,g,r,n);case 16:return t.prev=16,t.next=19,d(a);case 19:c=t.sent,t.next=25;break;case 22:t.prev=22,t.t1=t.catch(16),i("orthologsNotFound",t.t1,g,r,n);case 25:h=n.map((function(t){return y(t)})),0===(f=c.filter((function(t){return s=t.omaid,l=s.slice(0,5),h.includes(l)}))).length&&i("orthologsNotFoundInTarget",void 0,g,r,n),f.unshift(u),f=f.map((function(t){return{gene:t.canonicalid,location:t.chromosome+":"+t.locus.start+"-"+t.locus.end}})),b.push(f);case 31:v++,t.next=2;break;case 34:return t.abrupt("return",b);case 35:case"end":return t.stop()}}),t,null,[[4,13],[16,22]])})))).apply(this,arguments)}var x=function(t,e,r){return b.apply(this,arguments)},w={"aedes aegypti":"7159","anopheles gambiae":"7165","arabidopsis thaliana":"3702","aspergillis fumigatus":"746128","aspergillus niger":"5061","aspergillus oryzae":"5062","bos taurus":"9913","brachypodium distachyon":"15368","caenorhabditis elegans":"6239","callithrix jacchus":"9483","canis lupus familiaris":"9615","chlorocebus sabaeus":"60711","ciona intestinalis":"7719","capsicum annuum":"4072","culex quinquefasciatus":"7176","danio rerio":"7955","drosophila melanogaster":"7227","equus caballus":"9796","felis catus":"9685","gallus gallus":"9031","glycine max":"3847","gorilla gorilla":"9593","homo sapiens":"9606","hordeum vulgare":"4513","macaca fascicularis":"9541","macaca mulatta":"9544","mus musculus":"10090","musa acuminata":"4641","oryza sativa":"4530","ornithorhynchus anatinus":"9258","pan paniscus":"9597","pan troglodytes":"9598","plasmodium falciparum":"5833","rattus norvegicus":"10116","saccharomyces cerevisiae":"4932","solanum lycopersicum":"4081","sus scrofa":"9823","vitis vinifera":"29760","zea mays":"4577"};var _,j;_=w,j={},Object.keys(_).forEach((function(t){j[_[t]]=t}));function k(t,e,r,n,o,a,i){try{var u=t[a](i),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function E(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){k(a,n,o,i,u,"next",t)}function u(t){k(a,n,o,i,u,"throw",t)}i(void 0)}))}}function O(t){return L.apply(this,arguments)}function L(){return(L=E(o.a.mark((function t(e){var r,n,a,i;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[],"&api_key=e7ce8adecd69d0457df7ec2ccbb704c4e709","https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=gene&retmode=json&api_key=e7ce8adecd69d0457df7ec2ccbb704c4e709",t.next=5,fetch("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=gene&retmode=json&api_key=e7ce8adecd69d0457df7ec2ccbb704c4e709&id="+e.join(","));case 5:return n=t.sent,t.next=8,n.json();case 8:return a=t.sent,(i=a.result).uids.forEach((function(t){var e=i[t],n=e.genomicinfo[0],o={name:e.name,id:e.uid};n&&(o.chr=n.chrloc,o.start=n.chrstart,o.stop=n.chrstop,o.location=o.chr+":"+o.start+"-"+o.stop),r.push(o)})),t.abrupt("return",r);case 12:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function S(t){return N.apply(this,arguments)}function N(){return(N=E(o.a.mark((function t(e){var r,n;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return"https://mygene.info/v3/query",t.next=3,fetch("https://mygene.info/v3/query"+e+"&size=20");case 3:return r=t.sent,t.next=6,r.json();case 6:return n=t.sent,t.abrupt("return",n);case 8:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function I(t){var e=null;e=Array.isArray(t.genomic_pos)?t.genomic_pos.filter((function(t){return!t.chr.includes("_")}))[0]:t.genomic_pos;var r={name:t.symbol,chr:e.chr,start:e.start,stop:e.end,id:e.ensemblgene};return r.location=r.chr+":"+r.start+"-"+r.stop,r}function P(t,e){var r=t.map((function(t){if(t.ensemblId)return"ensemblgene:".concat(t.ensemblId);t.name&&(t=t.name);var e=t.replace(/\(/g,"\\(").replace(/\)/g,"\\)");return"symbol:".concat(e)})).join(" OR ");return"?q=".concat(r,"&species=").concat(e,"&fields=symbol,genomic_pos,name,exons")}function A(t,e){return M.apply(this,arguments)}function M(){return(M=E(o.a.mark((function t(e,r){var n,a,i,u,c;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=[],a=P(e,r),t.next=4,S(a);case 4:if(i=t.sent,u=!1,i.hits.length<e.length&&(u=!0),i.hits.forEach((function(t){if("genomic_pos"in t==!1||"name"in t==!1&&"_id"in t==!1)u=!0;else{var e=I(t);n.push(e)}})),!u){t.next=15;break}if("string"!=typeof e[0]&&"ncbiGeneId"in e[0]!=!1){t.next=11;break}throw Error("Enrichment needed");case 11:return c=e.map((function(t){return t.ncbiGeneId})),t.next=14,O(c);case 14:n=t.sent;case 15:return t.abrupt("return",n);case 16:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function C(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==r)return;var n,o,a=[],i=!0,u=!1;try{for(r=r.call(t);!(i=(n=r.next()).done)&&(a.push(n.value),!e||a.length!==e);i=!0);}catch(t){u=!0,o=t}finally{try{i||null==r.return||r.return()}finally{if(u)throw o}}return a}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return F(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return F(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function G(t,e,r,n,o,a,i){try{var u=t[a](i),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function T(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){G(a,n,o,i,u,"next",t)}function u(t){G(a,n,o,i,u,"throw",t)}i(void 0)}))}}var U="https://homology-api.firebaseapp.com/orthodb/";function q(t){return z.apply(this,arguments)}function z(){return(z=T(o.a.mark((function t(e){var r,n,a,i=arguments;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=!(i.length>1&&void 0!==i[1])||i[1],t.next=3,fetch(U+e);case 3:return n=t.sent,t.next=6,n.json();case 6:if(a=t.sent,!r){t.next=11;break}return t.abrupt("return",a.data);case 11:return t.abrupt("return",a);case 12:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function R(t){var e;return"entrez"in t?e=t.entrez[0].id:t.xrefs.forEach((function(t){"NCBIgene"===t.type&&(e=t.name)})),e}function Y(t){var e=t.split("/").slice(-1)[0].split("_");return e[0]+"_"+e[1]+":"+e[2]}function $(t){return!isNaN(parseFloat(t))&&isFinite(t)}function B(t,e){var r={},n={};t.forEach((function(t){n[t]=[],r[t]=[]}));var o={};return e.results.bindings.forEach((function(e){var a=e.gene_s_name.value,i=a;if(a.includes(";")){var u=a.split(";");if(void 0===(i=t.find((function(t){return u.includes(t)}))))return}var c=Y(e.gene_s.value);t.forEach((function(t){t in r&&t!==i&&t.toLowerCase()===i.toLowerCase()&&(r[i]=r[t].slice(),n[i]=n[t].slice(),delete r[t],delete n[t])})),o[i]={id:c};var s=e.gene_t_name.value;if(s.includes(";")){var l=s.split(";");if(l.find((function(t){return $(t)}))){var f=l.find((function(t){return!$(t)}));s=f||l[0]}else s=l.sort((function(t,e){return t.length<e.length}))[0]}var p=Y(e.gene_t.value);i in n&&!n[i].includes(s)&&(n[i].push(s),r[i].push({name:s,id:p}))})),{orthologMap:r,sources:o}}function D(t,e,r){var n=r[e];return e=e.toLowerCase(),t.sort((function(t,r){var o,a,i=t.name.toLowerCase(),u=r.name.toLowerCase();if(i===e)return-1;if(u===e)return 1;if(t.exons!==r.exons){if(t.exons==n.exons)return-1;if(r.exons==n.exons)return 1}if((null===(o=t.domains)||void 0===o?void 0:o.length)>1&&(null===(a=r.domains)||void 0===a?void 0:a.length)>1&&i!==e&&u!==e){var c=t.domains.length,s=r.domains.length,l=n.domains.length;if(c===l)return-1;if(s===l)return 1;var f=Math.abs(c-l),p=Math.abs(s-l);if(f<p)return-1;if(f>p)return 1}}))}function H(t){return J.apply(this,arguments)}function J(){return(J=T(o.a.mark((function t(e){var r;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,q("ogdetails?id="+e.id);case 2:return(r=t.sent).ensembl&&(e.ensemblId=r.ensembl[0].id),e.ncbiGeneId=R(r),e.aas=r.aas,e.exons=r.exons,e.domains=r.interpro,t.abrupt("return",e);case 9:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function K(t,e){return Q.apply(this,arguments)}function Q(){return(Q=T(o.a.mark((function t(e,r){var n,a,i,u=arguments;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=u.length>2&&void 0!==u[2]&&u[2],a={},i={},t.next=5,Promise.all(Object.entries(e).map(function(){var t=T(o.a.mark((function t(e){var u,c,s,l,f,p,h;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u=C(e,2),c=u[0],s=u[1],void 0!==(l=r[c])){t.next=4;break}throw Error("".concat(c," not found in target"));case 4:if(!1!==(n||s.every((function(t){return t.name.toLowerCase()!==c.toLowerCase()})))){t.next=8;break}return a[c]=s,t.abrupt("return");case 8:return t.next=10,H(l);case 10:return f=t.sent,i[c]=f,p=s.map(function(){var t=T(o.a.mark((function t(e){return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,H(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),t.next=15,Promise.all(p);case 15:h=t.sent,a[c]=h;case 17:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 5:return e=a,r=i,t.abrupt("return",{orthologMap:e,sources:r});case 8:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function V(t,e){return void 0!==t.name&&void 0!==t.location&&((r=t.name)===(n=e)||r.replace(/-/g,"")===n.replace(/-/g,""));var r,n}function W(t,e,r){return X.apply(this,arguments)}function X(){return(X=T(o.a.mark((function t(e,r,n){var a,u,c,s,l,f,p,h,d,v,m,g,y,b,x;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.join("%7C"),u=n[0],c=w[r],s=w[u],l=encodeURIComponent(["prefix : <http://purl.orthodb.org/>","select *","where {","?og a :OrthoGroup .","?gene_s a :Gene .","?gene_t a :Gene .","?gene_s up:organism/a taxon:".concat(c," ."),"?gene_t up:organism/a taxon:".concat(s," ."),"?gene_s :memberOf ?og .","?gene_t :memberOf ?og .","?gene_s :name ?gene_s_name .","?gene_t :name ?gene_t_name .",'filter (regex(?gene_s_name, "(^;?'.concat(a,';?)", "i"))'),"}"].join("\n")),t.next=7,q("sparql/?query="+l,!1);case 7:return 0===(f=t.sent).results.bindings.length&&i("orthologsNotFound",null,e),p=B(e,f),t.prev=10,t.next=13,K(p.orthologMap,p.sources);case 13:h=t.sent,t.next=20;break;case 16:t.prev=16,t.t0=t.catch(10),i("orthologsNotFoundInTarget",null,t.t0.message.split(" ")[0],r,n);case 20:return d=h.orthologMap,v=h.sources,t.prev=22,t.next=25,A(e,c);case 25:m=t.sent,t.next=39;break;case 28:return t.prev=28,t.t1=t.catch(22),t.next=32,K(p.orthologMap,p.sources,!0);case 32:return h=t.sent,d=h.orthologMap,v=h.sources,g=Object.values(v).map((function(t){return t.ncbiGeneId})),t.next=38,O(g);case 38:m=t.sent;case 39:return t.prev=39,y=[],Object.entries(d).forEach((function(t){var e=C(t,2),r=(e[0],e[1]);y=y.concat(r)})),t.next=44,A(y,s);case 44:b=t.sent,t.next=59;break;case 47:return t.prev=47,t.t2=t.catch(39),t.next=51,K(p.orthologMap,p.sources,!0);case 51:return h=t.sent,d=h.orthologMap,y=[],Object.entries(d).forEach((function(t){var e=C(t,2),r=(e[0],e[1]);y=y.concat(r)})),v=h.sources,t.next=58,A(y,s);case 58:b=t.sent;case 59:return x=[],Object.entries(d).forEach((function(t,e){var r=C(t,2),n=r[0],o=r[1],a=[];o=D(o,n,v);var i=m.find((function(t){return V(t,n)})).location,u={name:n,location:i};a.push(u),o.forEach((function(t){var r=t.name,n=b.find((function(t){return V(t,r)}));n||(n=b[e]);var o={name:r,location:n.location};a.push(o)})),x.push(a)})),t.abrupt("return",x);case 62:case"end":return t.stop()}}),t,null,[[10,16],[22,28],[39,47]])})))).apply(this,arguments)}function Z(t,e,r,n,o,a,i){try{var u=t[a](i),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function tt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){Z(a,n,o,i,u,"next",t)}function u(t){Z(a,n,o,i,u,"throw",t)}i(void 0)}))}}function et(){return(et=tt(o.a.mark((function t(e,r,n){var a,i=arguments;return o.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("orthodb"!==(a=i.length>3&&void 0!==i[3]?i[3]:"orthodb")){t.next=7;break}return t.next=4,W(e,r,n);case 4:return t.abrupt("return",t.sent);case 7:if("oma"!==a){t.next=11;break}return t.next=10,x(e,r,n);case 10:return t.abrupt("return",t.sent);case 11:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var rt=function(t,e,r){return et.apply(this,arguments)};window.fetchOrthologs=rt;e.default=rt}])})); //# sourceMappingURL=homology.min.js.map