From 067e7e537165282b2e3de4788b2faef11d3264dd Mon Sep 17 00:00:00 2001 From: AndiMajore <andi.majore@googlemail.com> Date: Tue, 28 Sep 2021 13:23:30 +0200 Subject: [PATCH] remove necessity of adding edges --- .../explorer-page/explorer-page.component.ts | 44 ++++++++++--------- src/index.html | 4 +- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/app/pages/explorer-page/explorer-page.component.ts b/src/app/pages/explorer-page/explorer-page.component.ts index be407ec6..d8968093 100644 --- a/src/app/pages/explorer-page/explorer-page.component.ts +++ b/src/app/pages/explorer-page/explorer-page.component.ts @@ -53,14 +53,15 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { public id: undefined | string; @Input() - public set config(config: string | undefined |object) { - if (config== null) { + public set config(config: string | undefined | object) { + if (config == null) { return; } if (this.id == null) setTimeout(() => { this.config = config; }, 200); + console.log(config) // add settings to config const configObj = typeof config === 'object' ? config : JSON.parse(config); this.myConfig = merge(this.myConfig, configObj); @@ -109,10 +110,11 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { @Input() public set network(network: string | undefined | object) { + console.log(network) if (network == null) { return; } - this.networkJSON = typeof network === 'object' ? JSON.stringify(network) : network ; + this.networkJSON = typeof network === 'object' ? JSON.stringify(network) : network; this.createNetwork(); } @@ -173,7 +175,7 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { public selectedAnalysisToken: string | null = null; - @Input() inputNetwork = { }; + @Input() inputNetwork = {}; @Input() set taskId(token: string | null) { if (token == null || token.length === 0) @@ -289,17 +291,17 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { private async getNetwork() { const network = JSON.parse(this.networkJSON); - if (this.myConfig.identifier === 'ensg') { // @ts-ignore network.nodes.forEach(node => { node.id = this.removeEnsemblVersion(node.id); }); - // @ts-ignore - network.edges.forEach(edge => { - edge.from = this.removeEnsemblVersion(edge.from); - edge.to = this.removeEnsemblVersion(edge.to); - }); + if (network.edges != null) + // @ts-ignore + network.edges.forEach(edge => { + edge.from = this.removeEnsemblVersion(edge.from); + edge.to = this.removeEnsemblVersion(edge.to); + }); } // map data to nodes in backend @@ -315,7 +317,6 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { // at this point, we have nodes synched with the backend // use netexIds where posssible, but use original id as node name if no label given const nodeIdMap = {}; - network.nodes.forEach((node) => { // set node label to original id before node id will be set to netex id node.label = node.label ? node.label : node.id; @@ -326,14 +327,15 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { // adjust edge labels accordingly and filter const edges = new Array(); - network.edges.forEach(edge => { - edge.from = nodeIdMap[edge.from]; - edge.to = nodeIdMap[edge.to]; - // check if edges have endpoints - if (edge.from !== undefined && edge.to !== undefined) { - edges.push(edge); - } - }); + if (network.edges != null) + network.edges.forEach(edge => { + edge.from = nodeIdMap[edge.from]; + edge.to = nodeIdMap[edge.to]; + // check if edges have endpoints + if (edge.from !== undefined && edge.to !== undefined) { + edges.push(edge); + } + }); // remove edges without endpoints network.edges = edges; this.inputNetwork = network; @@ -833,8 +835,8 @@ export class ExplorerPageComponent implements OnInit, AfterViewInit { } setInputNetwork(network: any) { - if(network == null) - this.inputNetwork={nodes: this.proteins, edges : this.edges} + if (network == null) + this.inputNetwork = {nodes: this.proteins, edges: this.edges} else this.inputNetwork = network; } diff --git a/src/index.html b/src/index.html index 95e57fd8..81b9ff5d 100644 --- a/src/index.html +++ b/src/index.html @@ -44,9 +44,7 @@ <network-expander id="netexp1" pluginId="2" - config='{"showSimpleAnalysis":true, "nodeGroups":{"patient":{"type":"patient","color":"black","font":{"color":"#ffffff"},"groupName":"Patient","shape":"image","image":"https://static.thenounproject.com/png/22780-200.png"},"condition":{"type":"condition","color":"black","font":{"color":"black"},"groupName":"Condition","shape":"text"},"important":{"type":"gene","color":"#ff881f","font":{"color":"#000000"},"groupName":"Important Gene","shape":"star"},"gene":{"type":"gene","color":"#4da300","font":{"color":"#000000"},"groupName":"Gene","shape":"circle"},"foundDrug":{"type":"drug","color":{"border":"#F12590","background":"#F12590","highlight":{"border":"#F12590","background":"#F12590"}},"font":{"color":"#f0f0f0"},"groupName":"Drug","shape":"diamond"}},"edgeGroups":{"genotype":{"color":"black","groupName":"Relevant Gene"},"has-condition":{"color":"#000000","groupName":"Has Condition","dashes":[2,2]},"default":{"color":"#000000","groupName":"default edge"},"ggi":{"color":"#000000","groupName":"Interaction","dashes":[3,2]}},"identifier":"symbol","title":"Breast cancer example network","nodeShadow":true,"edgeShadow":false,"autofillEdges":false,"showLegend":true}' - network='{"nodes":[{"id":"patient-1","group":"patient","x":592,"y":446},{"id":"patient-2","group":"patient","x":235,"y":87},{"id":"patient-3","group":"patient","x":105,"y":369},{"id":"ATM","label":"ATM","group":"gene","x":289,"y":242},{"id":"BARD1","label":"BARD1","group":"gene","x":44,"y":250},{"id":"BRCA1","label":"BRCA1","group":"gene","x":466,"y":576},{"id":"BRCA2","label":"BRCA2","group":"gene","x":507,"y":285},{"id":"BRIP1","label":"BRIP1","group":"gene","x":54,"y":474},{"id":"CHEK2","label":"CHEK2","group":"gene","x":216,"y":590},{"id":"CDH1","label":"CDH1","group":"gene","x":320,"y":-57},{"id":"NF1","label":"NF1","group":"gene","x":481,"y":111},{"id":"NBN","label":"NBN","group":"gene","x":-57,"y":314},{"id":"PALB2","label":"PALB2","group":"gene","x":450,"y":190},{"id":"PTEN","label":"PTEN","group":"important","x":305,"y":494},{"id":"RAD51C","label":"RAD51C","group":"gene","x":182,"y":-90},{"id":"RAD51D","label":"RAD51D","group":"gene","x":368,"y":73},{"id":"STK11","label":"STK11","group":"gene","x":686,"y":330},{"id":"TP53","label":"TP53","group":"important","x":333,"y":316},{"id":"subtype-1","label":"Subtype 1","group":"condition","x":556,"y":171},{"id":"subtype-2","label":"Subtype 2","group":"condition","x":-87,"y":221}],"edges":[{"from":"BRCA1","to":"BRCA2","group":"ggi"},{"from":"ATM","to":"BARD1","group":"ggi"},{"from":"BRCA1","to":"CHEK2","group":"ggi"},{"from":"RAD51C","to":"RAD51D","group":"ggi"},{"from":"STK11","to":"TP53","group":"ggi"},{"from":"TP53","to":"PALB2","group":"ggi"},{"from":"TP53","to":"RAD51D","group":"ggi"},{"from":"TP53","to":"NF1","group":"ggi"},{"from":"TP53","to":"BRCA1","group":"ggi"},{"from":"TP53","to":"BRCA2","group":"ggi"},{"from":"PTEN","to":"BRCA1","group":"ggi"},{"from":"PTEN","to":"BRCA2","group":"ggi"},{"from":"TP53","to":"PTEN","group":"ggi"},{"from":"ATM","to":"PTEN","group":"ggi"},{"from":"CDH1","to":"RAD51D","group":"ggi"},{"from":"CDH1","to":"PALB2","group":"ggi"},{"from":"NBN","to":"BRIP1","group":"ggi"},{"from":"BRIP1","to":"PTEN","group":"ggi"},{"from":"patient-1","to":"BRCA1","group":"genotype"},{"from":"patient-1","to":"TP53","group":"genotype"},{"from":"patient-1","to":"BRCA2","group":"genotype"},{"from":"patient-1","to":"PTEN","group":"genotype"},{"from":"patient-2","to":"TP53","group":"genotype"},{"from":"patient-2","to":"NF1","group":"genotype"},{"from":"patient-2","to":"BARD1","group":"genotype"},{"from":"patient-3","to":"TP53","group":"genotype"},{"from":"patient-3","to":"PTEN","group":"genotype"},{"from":"patient-3","to":"NBN","group":"genotype"},{"from":"patient-1","to":"subtype-1","group":"has-condition"},{"from":"patient-2","to":"subtype-1","group":"has-condition"},{"from":"patient-3","to":"subtype-2","group":"has-condition"}]}'> - }'></network-expander> + network='{"nodes":[{"id": "PTEN"}]}'></network-expander> </div> <!--<div >--> -- GitLab