(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i').appendTo(pluginContainer); globals.container.append("\n
\n
Selected Element
\n
\n
\n
\n "); globals.container.append('
'); globals.container.append("\n
\n \n \n
"); globals.container.append(''); globals.container.find('.btn-uniprot').on('click', function () { return Initialize(); }); globals.container.find('.checkbox-input').on('click', function () { return checkboxchecked(); }); } function checkboxchecked() { globals.checkbox_checked = document.getElementById("checkbox_submap").checked; } function Initialize() { if (globals.allBioEntities.length > 0) { Start(); } else { minervaProxy.project.data.getAllBioEntities().then(function (bioEntities) { globals.allBioEntities = bioEntities; Start(); }); } } function Start() { checkformodelID().then(function (newCalculation) { if (newCalculation === true || globals.calculated === false) { globals.allBioEntities.forEach(function (e) { if (globals.checkbox_checked === true && e.getModelId() !== globals.modelid) {} else { if (e.constructor.name === 'Alias') { if (globals.allSpeciesNamesLoweCase.includes(e.getName().toLowerCase()) === false) { globals.allSpeciesNamesLoweCase.push(e.getName().toLowerCase()); globals.allSpeciesNames.push(e.getName()); globals.allSpecies.push(e); globals.InDegree.push(0); globals.OutDegree.push(0); globals.Betweenness.push(0); globals.Closeness.push(0); } } else globals.allReactions.push(e); } }); for (var n = 0; n < globals.allSpeciesNamesLoweCase.length; n++) { globals.countSPs.push(new Array(globals.allSpeciesNamesLoweCase.length)); globals.ShortestPath.push(new Array(globals.allSpeciesNamesLoweCase.length)); globals.SPTypes.push(new Array(globals.allSpeciesNamesLoweCase.length)); } for (var i = 0; i < globals.allSpeciesNamesLoweCase.length; i++) { for (var j = 0; j < globals.allSpeciesNamesLoweCase.length; j++) { globals.SPTypes[i][j] = 1; globals.countSPs[i][j] = 0; if (i === j) globals.ShortestPath[i][j] = 0;else globals.ShortestPath[i][j] = Number.MAX_SAFE_INTEGER; } } var negative = 'negative influence'; var unegative = 'unknown negative influence'; var checkReactions = []; for (var _i = 0; _i < globals.allReactions.length; _i++) { var reaction = globals.allReactions[_i]; var sbioEntities = reaction.getReactants(); var tbioEntities = reaction.getProducts(); var mbioEntities = reaction.getModifiers(); for (var s = 0; s < tbioEntities.length; s++) { var tid = globals.allSpeciesNamesLoweCase.indexOf(tbioEntities[s].getAlias().getName().toLowerCase()); for (var s = 0; s < sbioEntities.length; s++) { var sid = globals.allSpeciesNamesLoweCase.indexOf(sbioEntities[s].getAlias().getName().toLowerCase()); var stid = sid + '-' + tid; if (!(sid === tid || sid < 0 || tid < 0)) { if (checkReactions.includes(stid) === false) { globals.OutDegree[sid] += 1; globals.InDegree[tid] += 1; } checkReactions.push(stid); globals.ShortestPath[sid][tid] = 1; globals.countSPs[sid][tid] = 1; var type = "".concat(reaction._type.toString().toLowerCase()); if (negative === type || unegative === type) { globals.SPTypes[sid][tid] = -1; } } } for (var m = 0; m < mbioEntities.length; m++) { var mid = globals.allSpeciesNamesLoweCase.indexOf(mbioEntities[m].getAlias().getName().toLowerCase()); var mtid = mid + '-' + tid; if (!(mid === tid || mid < 0 || tid < 0)) { globals.ShortestPath[mid][tid] = 1; globals.countSPs[mid][tid] = 1; if (checkReactions.includes(mtid) === false) { globals.OutDegree[mid] += 1; globals.InDegree[tid] += 1; } checkReactions.push(mtid); } } } } var length = globals.allSpeciesNamesLoweCase.length; for (var k = 0; k < length; k++) { for (var _s = 0; _s < length; _s++) { if (_s === k) { continue; } for (var t = 0; t < length; t++) { if (_s === t) { continue; } var ikCount = globals.ShortestPath[_s][k]; var kjcount = globals.ShortestPath[k][t]; var stCount = globals.ShortestPath[_s][t]; if (ikCount != Number.MAX_SAFE_INTEGER && kjcount != Number.MAX_SAFE_INTEGER) { if (stCount > ikCount + kjcount) { globals.ShortestPath[_s][t] = ikCount + kjcount; globals.SPTypes[_s][t] = globals.SPTypes[_s][k] * globals.SPTypes[k][t]; globals.countSPs[_s][t] = globals.countSPs[_s][k] * globals.countSPs[k][t]; } if (stCount === ikCount + kjcount) { if (globals.SPTypes[_s][k] * globals.SPTypes[k][t] === -1) { globals.SPTypes[_s][t] = -1; } globals.countSPs[_s][t] += globals.countSPs[_s][k] * globals.countSPs[k][t]; } } } } } var tbl = undefined; if (document.getElementById('resultstable')) { $('#resultstable').DataTable().destroy(); tbl = document.getElementById('resultstable'); tbl.parentElement.removeChild(tbl); } tbl = document.createElement("table"); tbl.setAttribute('class', 'table table-striped table-bordered table-sm'); tbl.setAttribute('style', 'width:100%'); tbl.setAttribute('id', 'resultstable'); tbl.setAttribute('cellspacing', '0'); globals.downloadtext = 'Element\tInDegree\tOutDegree\tBetweenness\tCloseness'; for (var _k = 0; _k < length; _k++) { var result_row = tbl.insertRow(tbl.rows.length); globals.downloadtext += "\n".concat(globals.allSpeciesNames[_k], "\t").concat(globals.InDegree[_k], "\t").concat(globals.OutDegree[_k]); createButtonCell(result_row, 'td', globals.allSpeciesNames[_k], globals.allSpeciesNames[_k], 'center'); createCell(result_row, 'td', globals.InDegree[_k], 'col-3', '', 'center'); createCell(result_row, 'td', globals.OutDegree[_k], 'col-3', '', 'center'); for (var _s2 = 0; _s2 < length; _s2++) { if (_s2 === _k) { continue; } var ksCount = globals.ShortestPath[_k][_s2]; for (var _t = 0; _t < length; _t++) { if (_s2 === _t) { continue; } if (globals.countSPs[_s2][_t] == 0) continue; var skCount = globals.ShortestPath[_s2][_k]; var ktcount = globals.ShortestPath[_k][_t]; var _stCount = globals.ShortestPath[_s2][_t]; if (skCount === Number.MAX_SAFE_INTEGER || ktcount === Number.MAX_SAFE_INTEGER || _stCount === Number.MAX_SAFE_INTEGER) continue; if (skCount === 0 || ktcount === 0 || _stCount === 0) continue; if (_stCount === skCount + ktcount) { globals.Betweenness[_k] += globals.countSPs[_s2][_k] * globals.countSPs[_k][_t] / globals.countSPs[_s2][_t]; } } if (ksCount != Number.MAX_SAFE_INTEGER && ksCount != 0) { globals.Closeness[_k] += 1 / ksCount; } } globals.downloadtext += "\t".concat(Math.round((globals.Betweenness[_k] + Number.EPSILON) * 100) / 100, "\t").concat(Math.round((globals.Closeness[_k] + Number.EPSILON) * 100) / 100); createCell(result_row, 'td', Math.round((globals.Betweenness[_k] + Number.EPSILON) * 100) / 100, 'col-3', '', 'center'); createCell(result_row, 'td', Math.round((globals.Closeness[_k] + Number.EPSILON) * 100) / 100, 'col-3', '', 'center'); } var header = tbl.createTHead(); var headerrow = header.insertRow(0); createCell(headerrow, 'th', 'Element', 'col-3', 'col', 'center'); for (var h = 0; h < globals.Overlays.length; h++) { createCell(headerrow, 'th', globals.Overlays[h], 'col-3', 'col', 'center'); } globals.centralities.push(globals.InDegree); globals.centralities.push(globals.OutDegree); globals.centralities.push(globals.Betweenness); globals.centralities.push(globals.Closeness); globals.alreadycalculated = true; if (!(globals.container.find('.btn-download').length > 0)) { globals.container.append('
'); globals.container.append("\n
\n
First Element
\n
\n
\n
\n "); globals.container.append(''); globals.container.append("\n
\n
Second Element
\n
\n
\n
\n "); globals.container.append(''); globals.container.append("\n
\n
Shortest Path between both elements
\n
\n
\n
\n "); globals.container.append(''); globals.container.append('
'); globals.container.append(""); globals.container.find('.btn-download').on('click', function () { return download('CentralityValues.txt'); }); globals.container.find('.btn-spbutton').on('click', function () { return ShortestPath(); }); globals.container.find('.btn-selectsecond').on('click', function () { return setSecondElement(); }); globals.container.find('.btn-selectfirst').on('click', function () { return SetFirstElement(); }); } globals.container.append(tbl); $('#resultstable').DataTable(); globals.calculated = true; minerva.ServerConnector.getLoggedUser().then(function (user) { minerva.ServerConnector.getOverlays({ creator: user._login }).then(function (overlays) { hideOverlays().then(function (rs) { setTimeout(getDataOverlays(overlays).then(function (ols) { ajaxDeleteQuery(ols).then(function (dr) { $("[name='refreshOverlays']").click(); ajaxPostQuery(0).then(function (pr) { resolve(''); }).catch(function (error) {}); }); }), 200); }); }); }); } }); } function download(filename) { var element = document.createElement('a'); element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(globals.downloadtext)); element.setAttribute('download', filename); element.style.display = 'none'; document.body.appendChild(element); element.click(); document.body.removeChild(element); } function highlightSelected() { var pickedRandomly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; minervaProxy.project.map.getHighlightedBioEntities().then(function (highlighted) { minervaProxy.project.map.hideBioEntity(highlighted).then(function (r) { var highlightDefs = []; if (pickedRandomly) { if (globals.pickedRandomly) { highlightDefs.push({ element: { id: globals.pickedRandomly.id, modelId: globals.pickedRandomly.getModelId(), type: globals.pickedRandomly.constructor.name.toUpperCase() }, type: "SURFACE", options: { color: '#00FF00', opacity: 0.2 } }); } } else { globals.selected.forEach(function (e) { if (e.constructor.name === 'Alias') { highlightDefs.push({ element: { id: e.id, modelId: e.getModelId(), type: "ALIAS" }, type: "ICON" }); } }); } minervaProxy.project.map.showBioEntity(highlightDefs); }); }); } function focusOnSelected() { function focus(entity) { if (entity.constructor.name === 'Alias') { minervaProxy.project.map.fitBounds({ modelId: entity.getModelId(), x1: entity.getX(), y1: entity.getY(), x2: entity.getX() + entity.getWidth(), y2: entity.getY() + entity.getHeight() }); } else { minervaProxy.project.map.fitBounds({ modelId: entity.getModelId(), x1: entity.getCenter().x, y1: entity.getCenter().y, x2: entity.getCenter().x, y2: entity.getCenter().y }); } } if (globals.selected.length > 0) { minervaProxy.project.map.openMap({ id: globals.selected[0].getModelId() }); focus(globals.selected[0]); } } $(document).on('click', '.clickElementinTable', function () { var name = $(this).attr('data'); globals.selected = []; globals.allBioEntities.forEach(function (e) { if (e.constructor.name === 'Alias') { if (name === e.getName()) { if (globals.modelid === -1 || e.getModelId() === globals.modelid) { globals.selected.push(e); } } } }); focusOnSelected(); }); function createCell(row, type, text, style, scope, align) { var cell = document.createElement(type); // create text node cell.innerHTML = text; // append text node to the DIV cell.setAttribute('class', style); if (scope != '') cell.setAttribute('scope', scope); // set DIV class attribute // set DIV class attribute for IE (?!) cell.setAttribute('style', 'text-align: ' + align + '; vertical-align: middle;'); // append DIV to the table cell row.appendChild(cell); return cell; } function createButtonCell(row, type, text, data, align) { var button = document.createElement('button'); // create text node button.innerHTML = text; button.setAttribute('type', 'button'); button.setAttribute('data', data); // set DIV class attribute // set DIV class attribute for IE (?!) button.setAttribute('class', 'clickElementinTable'); var cell = document.createElement(type); // create text node cell.appendChild(button); cell.setAttribute('style', 'text-align: ' + align + '; vertical-align: middle;'); // append DIV to the table cell row.appendChild(cell); return cell; return button; // append DIV to the table cell } function ajaxDeleteQuery(count) { return new Promise(function (resolve, reject) { if (count.length > 0) { $.ajax({ method: 'DELETE', url: minerva.ServerConnector._serverBaseUrl + 'api/projects/' + minervaProxy.project.data.getProjectId() + '/overlays/' + count[0].id, cookie: 'MINERVA_AUTH_TOKEN=xxxxxxxx', success: function success(response) { count.splice(0, 1); ajaxDeleteQuery(count).then(function (r) { return resolve(response); }); } }); } else { resolve(''); } }); } function ajaxPostQuery(count) { return new Promise(function (resolve, reject) { if (count < globals.Overlays.length) { var array = globals.centralities[count]; $.ajax({ method: 'POST', url: minerva.ServerConnector._serverBaseUrl + 'api/projects/' + minervaProxy.project.data.getProjectId() + '/overlays/', data: "content=name%09color".concat(contentstring(array), "&description=PhenotypeActivity&filename=").concat(globals.Overlays[count], ".txt&name=").concat(globals.Overlays[count], "&googleLicenseConsent=true"), cookie: 'MINERVA_AUTH_TOKEN=xxxxxxxx', success: function success(response) { $("[name='refreshOverlays']").click(); ajaxPostQuery(count + 1).then(function (r) { return resolve(response); }); }, error: function error(response) { reject(); } }); } else { resolve(''); } }); } function contentstring(array) { var normalizedarray = []; var max = 0; array.forEach(function (a) { if (a > max) max = a; }); array.forEach(function (a) { normalizedarray.push(a / max); }); var rgbToHex = function rgbToHex(rgb) { var hex = Number(Math.round(rgb)).toString(16); if (hex.length < 2) { hex = "0" + hex; } return hex; }; var output = ''; for (var i = 0; i < globals.allSpeciesNamesLoweCase.length; i++) { var hex = rgbToHex((1 - Math.abs(normalizedarray[i])) * 255); output += "%0A".concat(globals.allSpeciesNamesLoweCase[i]); if (normalizedarray[i] > 0) output += '%09%23ff' + hex + hex; if (normalizedarray[i] < 0) output += '%09%23' + hex + 'ff' + hex; if (normalizedarray[i] === 0) output += '%09%23ffffff'; } return output; } function currentModelID() { var model = -1; if (globals.selected.length === 0) return -1;else { globals.selected.forEach(function (e) { if (e.constructor.name === 'Alias') { model = e.getModelId(); } }); } return model; } function getDataOverlays(overlays) { return new Promise(function (resolve, reject) { var olarray = []; for (var olCount = 0; olCount < overlays.length; olCount++) { if (globals.Overlays.includes(overlays[olCount].name) === true) { olarray.push(overlays[olCount]); } } resolve(olarray); }); } function hideOverlays() { return new Promise(function (resolve, reject) { minerva.ServerConnector.getLoggedUser().then(function (user) { minerva.ServerConnector.getOverlays({ creator: user._login }).then(function (overlays) { function hideOverlay(ols) { return new Promise(function (resolve, reject) { if (ols.length > 0) { minervaProxy.project.map.hideDataOverlay(ols[0].id).then(function (r) { ols.splice(0, 1); hideOverlay(ols).then(function (s) { resolve(''); }); }); ; } else { resolve(''); } }); } getDataOverlays(overlays).then(function (ol) { hideOverlay(ol).then(function (rs) { $("[name='refreshOverlays']").click(); resolve(''); }); }); }); }); }); } function checkformodelID() { return new Promise(function (resolve, reject) { globals.checkbox_checked = document.getElementById("checkbox_submap").checked; if (globals.checkbox_checked === true && currentModelID() !== globals.modelid || globals.checkbox_checked === false && globals.modelid !== -1) { globals.ShortestPath = []; globals.countSPs = []; globals.SPTypes = []; globals.allSpeciesNamesLoweCase = []; globals.Betweenness = []; globals.Closeness = []; globals.InDegree = []; globals.OutDegree = []; globals.allReactions = []; globals.downloadtext = globals.samplestring; globals.centralities = []; globals.calculated = false; globals.allSpecies = []; globals.allSpeciesNames = []; globals.allReactions = []; globals.modelid = globals.checkbox_checked === true ? currentModelID() : -1; resolve(true); } else { globals.modelid = globals.checkbox_checked === true ? currentModelID() : -1; resolve(false); } }); } function searchListener(entites) { globals.selected = entites[0]; var str = ''; if (globals.selected.length > 0) { globals.selected.forEach(function (e) { if (e.constructor.name === 'Alias') str += "
".concat(e.getName(), " - ").concat(e.getElementId(), " - ").concat(e._type, "
"); }); } pluginContainer.find('.panel-test .panel-body').html(str); } function ShortestPath() { var output = 'Shortest Path: '; if (globals.firstelement && globals.secondelement) { var s = globals.allSpeciesNamesLoweCase.indexOf(globals.firstelement.getName().toLowerCase()); var t = globals.allSpeciesNamesLoweCase.indexOf(globals.secondelement.getName().toLowerCase()); var SP = ''; if (globals.ShortestPath[s][t] === Number.MAX_SAFE_INTEGER) { SP = 'N/A'; } else { SP += globals.ShortestPath[s][t] * globals.SPTypes[s][t]; } output += "".concat(SP); } pluginContainer.find('.panel-spresult .panel-body').html(output); } function setSecondElement() { var pickedRandomly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; if (globals.selected.length > 0) { var html = ''; globals.selected.forEach(function (e) { if (e.constructor.name === 'Alias') { html += "".concat(e.constructor.name, " - "); html += "".concat(e.getElementId(), " - ").concat(e.getName()); globals.secondelement = e; } }); pluginContainer.find('.panel-second-picked .panel-body').html(html); } else if (pickedRandomly && globals.pickedRandomly) if (globals.pickedRandomly.constructor.name === 'Alias') { var _html = "".concat(globals.pickedRandomly.constructor.name, " - "); _html += "".concat(globals.pickedRandomly.getElementId(), " - ").concat(globals.pickedRandomly.getName()); pluginContainer.find('.panel-second-picked .panel-body').html(_html); globals.secondelement = globals.pickedRandomly; } } function SetFirstElement() { var pickedRandomly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; if (globals.selected.length > 0) { var html = ''; globals.selected.forEach(function (e) { if (e.constructor.name === 'Alias') { html += "".concat(e.constructor.name, " - "); html += "".concat(e.getElementId(), " - ").concat(e.getName()); globals.firstelement = e; } }); pluginContainer.find('.panel-first-picked .panel-body').html(html); } else if (pickedRandomly && globals.pickedRandomly) if (globals.pickedRandomly.constructor.name === 'Alias') { var _html2 = "".concat(globals.pickedRandomly.constructor.name, " - "); _html2 += "".concat(globals.pickedRandomly.getElementId(), " - ").concat(globals.pickedRandomly.getName()); pluginContainer.find('.panel-first-picked .panel-body').html(_html2); globals.firstelement = globals.pickedRandomly; } } },{"../css/styles.css":1,"core-js/modules/es.array.concat":104,"core-js/modules/es.array.find":105,"core-js/modules/es.array.includes":106,"core-js/modules/es.array.index-of":107,"core-js/modules/es.array.map":108,"core-js/modules/es.array.slice":109,"core-js/modules/es.array.splice":110,"core-js/modules/es.number.constructor":111,"core-js/modules/es.object.to-string":112,"core-js/modules/es.promise":113,"core-js/modules/es.regexp.to-string":114,"core-js/modules/es.string.includes":115,"core-js/modules/es.string.split":116,"core-js/modules/web.dom-collections.for-each":117}],3:[function(require,module,exports){ 'use strict'; // For more information about browser field, check out the browser field at https://github.com/substack/browserify-handbook#browser-field. var styleElementsInsertedAtTop = []; var insertStyleElement = function(styleElement, options) { var head = document.head || document.getElementsByTagName('head')[0]; var lastStyleElementInsertedAtTop = styleElementsInsertedAtTop[styleElementsInsertedAtTop.length - 1]; options = options || {}; options.insertAt = options.insertAt || 'bottom'; if (options.insertAt === 'top') { if (!lastStyleElementInsertedAtTop) { head.insertBefore(styleElement, head.firstChild); } else if (lastStyleElementInsertedAtTop.nextSibling) { head.insertBefore(styleElement, lastStyleElementInsertedAtTop.nextSibling); } else { head.appendChild(styleElement); } styleElementsInsertedAtTop.push(styleElement); } else if (options.insertAt === 'bottom') { head.appendChild(styleElement); } else { throw new Error('Invalid value for parameter \'insertAt\'. Must be \'top\' or \'bottom\'.'); } }; module.exports = { // Create a tag with optional data attributes createLink: function(href, attributes) { var head = document.head || document.getElementsByTagName('head')[0]; var link = document.createElement('link'); link.href = href; link.rel = 'stylesheet'; for (var key in attributes) { if ( ! attributes.hasOwnProperty(key)) { continue; } var value = attributes[key]; link.setAttribute('data-' + key, value); } head.appendChild(link); }, // Create a