diff --git a/app-test/legend_image.html b/app-test/legend_image.html index 258bb6f5a93d66d6337c2f183ce3e6f14b7b86b1..dbb6b44a8c6508df549f7552fd9ee0ef4b80bcf1 100644 --- a/app-test/legend_image.html +++ b/app-test/legend_image.html @@ -58,7 +58,6 @@ } function changeConfigStr(config) { - console.log(config); const netexp = document.getElementById('netexp1'); netexp.setAttribute('config', config); } diff --git a/src/app/components/analysis-panel/analysis-panel.component.ts b/src/app/components/analysis-panel/analysis-panel.component.ts index 24b6ea5651e06310424c0ca213879f41d52c159f..c26c718caef1cc4a6732a949c05ddbe2fefe12b3 100644 --- a/src/app/components/analysis-panel/analysis-panel.component.ts +++ b/src/app/components/analysis-panel/analysis-panel.component.ts @@ -377,6 +377,7 @@ export class AnalysisPanelComponent implements OnInit, OnChanges { * For the third case, fall back to a default case which can also be set by user. */ public inferNodeGroup(wrapper: Wrapper): string { + console.log(wrapper) if (wrapper.data.group !== undefined) { return wrapper.data.group } @@ -408,7 +409,6 @@ export class AnalysisPanelComponent implements OnInit, OnChanges { } } - /** * Maps analysis result returned from database to valid Vis.js network input * @@ -432,11 +432,10 @@ export class AnalysisPanelComponent implements OnInit, OnChanges { const scores = attributes.scores || {}; const details = attributes.details || {}; const wrappers: { [key: string]: Wrapper } = {}; - + for (const node of network.nodes) { // backend converts object keys to PascalCase: p_123 --> p123 const nodeObjectKey = node.split('_').join(''); - console.log(nodeObjectKey) if (nodeTypes[nodeObjectKey] === 'protein') { // node is protein from database, has been mapped on init to backend protein from backend // or was found during analysis @@ -474,6 +473,11 @@ export class AnalysisPanelComponent implements OnInit, OnChanges { if (typeof group === 'undefined' || typeof config.nodeGroups[group] === 'undefined') { group = 'default'; } + console.log("node group") + console.log(group) + console.log(config.nodeGroups) + console.log(config.nodeGroups[group]); + const node = JSON.parse(JSON.stringify(config.nodeGroups[group])); node.id = wrapper.id; node.label = this.inferNodeLabel(config, wrapper); @@ -551,7 +555,6 @@ export class AnalysisPanelComponent implements OnInit, OnChanges { // } for (const interaction of edges) { - console.log(interaction) const edge = {from: interaction.uniprotAc, to: interaction.drugId}; this.drugEdges.push(this.mapEdge(edge, 'protein-drug')); } diff --git a/src/app/main-network.ts b/src/app/main-network.ts index d82c6348fb9821a1e58cd5a83ba562ba7a9293f3..a0aa887c911b8b174cde89082b41ccd45cc4b491 100644 --- a/src/app/main-network.ts +++ b/src/app/main-network.ts @@ -46,13 +46,13 @@ export class ProteinNetwork { * @param config * @returns */ - private mapCustomNode(customNode: any, config: IConfig): Node { - let group = customNode.group; - if (typeof group === 'undefined' || typeof config.nodeGroups[group] === 'undefined') { - group = 'default'; + private mapCustomNode(customNode: any, config: IConfig): Node { + + if (config.nodeGroups[customNode.group] === undefined) { + throw `Node with id ${customNode.id} has undefined node group ${customNode.group}.` } - console.log(config.nodeGroups[group]) - let node = JSON.parse(JSON.stringify(config.nodeGroups[group])); + + let node = JSON.parse(JSON.stringify(config.nodeGroups[customNode.group])); // update the node with custom node properties, including values fetched from backend node = { @@ -77,18 +77,12 @@ export class ProteinNetwork { * @returns */ private mapCustomEdge(customEdge: NodeInteraction, config: IConfig): any { - let group = customEdge.group; - if (typeof group === 'undefined' || typeof config.edgeGroups[group] === 'undefined') { - group = 'default'; - } - let edge = JSON.parse(JSON.stringify(config.edgeGroups[group])); - console.log("edge") - console.log(edge) - - console.log("customEdge") - console.log(customEdge) + if (config.edgeGroups[customEdge.group] === undefined) { + throw `Edge "from ${customEdge.from}" - "to ${customEdge.to}" has undefined edge group ${customEdge.group}.` + } + let edge = JSON.parse(JSON.stringify(config.edgeGroups[customEdge.group])); edge = { ...edge, diff --git a/src/app/pages/explorer-page/explorer-page.component.ts b/src/app/pages/explorer-page/explorer-page.component.ts index b8077ce5a03a0488477161219f0947250963ccef..73fe52959d57cb9cb28e6015a81503b291353a09 100644 --- a/src/app/pages/explorer-page/explorer-page.component.ts +++ b/src/app/pages/explorer-page/explorer-page.component.ts @@ -384,7 +384,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { * @param values */ public setConfigEdgeGroup(key: string, edgeGroups: Array<EdgeGroup>) { - if (edgeGroups === undefined || !edgeGroups.length) { + if (edgeGroups === undefined || !Object.keys(edgeGroups).length) { // if edge groups are not set or empty, use default edge group(s) this.myConfig[key] = defaultConfig.edgeGroups; // stop if edgeGroups do not contain any information diff --git a/src/index.html b/src/index.html index 9a425110c4f518144c215206b6ab486a6f522c29..7311a881049a5bc58a7e19766e6d50ccf43976cd 100644 --- a/src/index.html +++ b/src/index.html @@ -38,22 +38,13 @@ <network-expander id="netexp1" config='{ - "nodeGroups":{ - "0.5":{"type":"gene","color":"#CCFF33FF","groupName":"0.5","shape":"circle"}, - "1.5":{"type":"gene","color":"#66FF33FF","groupName":"1.5","shape":"circle"}, - "2.0":{"type":"gene","color":"#33CC33FF","groupName":"2.0","shape":"circle"}, - "patient_group":{"type":"gene","color":"#FF0000FF","groupName":"-2.0","shape":"circle"} - }, - "edgeGroups":{ - "custom":{"color":"black","groupName":"Custom Group"} - }, - "identifier":"symbol", - "legendUrl":"https://exbio.wzw.tum.de/covex/assets/leg1.png" + "nodeGroups": {"0.5": {"type": "gene", "color": "rgb(204, 255, 51)", "groupName": "0.5", "shape": "circle"}, "patient_group": {"type": "patient", "color": "red", "groupName": "patient group", "shape": "circle"}}, + "edgeGroups": {"dashes": {"color": "black", "groupName": "Dashes Group", "dashes": [1, 2]}}, + "identifier": "symbol" }' - network='{ - "nodes":[{"id":"TP53","group":"0.5"},{"id":"C5","group":"0.5"},{"id":"Patient","group":"patient_group"},{"label":"PTEN","id":"PTEN","group":0.5}], - "edges":[] + "nodes": [{"id": "TP53", "group": "0.5"}, {"id": "C5", "group": "0.5"}, {"id": "Patient", "group": "patient_group"}, {"label": "PTEN", "id": "PTEN", "group": 0.5}], + "edges": [{"from": "TP53","to": "C5","group": "dashes", "label": "this is a label", "title": "this is a title"}] }' style="height: 100%; width: 100vw; display: block;" ></network-expander>