From cd31df52f974f70866c037d6629fb5bee14b736f Mon Sep 17 00:00:00 2001
From: AndiMajore <andi.majore@googlemail.com>
Date: Tue, 26 Jul 2022 00:08:33 +0200
Subject: [PATCH] adjusted for new result networks

---
 .../components/analysis-panel/analysis-panel.component.ts  | 7 +++----
 .../dialogs/launch-analysis/launch-analysis.component.ts   | 2 +-
 src/app/services/analysis/analysis.service.ts              | 2 +-
 src/index.html                                             | 2 +-
 4 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/app/components/analysis-panel/analysis-panel.component.ts b/src/app/components/analysis-panel/analysis-panel.component.ts
index b8b551a5..68f41188 100644
--- a/src/app/components/analysis-panel/analysis-panel.component.ts
+++ b/src/app/components/analysis-panel/analysis-panel.component.ts
@@ -190,8 +190,6 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit
 
         // Create
         const {nodes, edges} = this.createNetwork(this.result);
-        console.log(nodes)
-        console.log(edges)
         this.setInputNetwork.emit({nodes: nodes, edges: edges});
         this.nodeData.nodes = new vis.DataSet(nodes);
         this.nodeData.edges = new vis.DataSet(edges);
@@ -447,11 +445,12 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit
     })
     for (const nodeId of Object.keys(details)) {
       const nodeDetails = details[nodeId]
+      console.log(nodeId)
       nodeDetails.id = nodeDetails.id ? nodeDetails.id : (typeof nodeDetails.drugstoneId === 'string' ? nodeDetails.drugstoneId : nodeDetails.drugstoneId[0]);
       if (nodeDetails.drugstoneId && nodeDetails.drugstoneType === 'protein') {
         // node is protein from database, has been mapped on init to backend protein from backend
         // or was found during analysis
-        nodeDetails.group = nodeDetails.group ? nodeDetails.group : 'foundNode';
+        nodeDetails.group = result.targetNodes && result.targetNodes.indexOf(nodeId) !== -1 ? 'foundNode' : (nodeDetails.group ? nodeDetails.group : 'default' );
         nodeDetails.label = nodeDetails.label ? nodeDetails.label : nodeDetails[identifier];
         nodeDetails.id = nodeDetails[identifier][0] ? nodeDetails[identifier][0] : nodeDetails.id;
         this.proteins.push(nodeDetails);
@@ -466,6 +465,7 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit
       }
       // further analysis and the button function can be used to highlight seeds
       // option to use scores[node] as gradient, but sccores are very small
+      console.log(nodeDetails)
       nodes.push(NetworkSettings.getNodeStyle(nodeDetails as Node, config, false, false, 1))
     }
 
@@ -477,7 +477,6 @@ export class AnalysisPanelComponent implements OnInit, OnChanges, AfterViewInit
       e.to = e.to[0] === 'p' ? nodeIdMap[e.to] : e.to
       edges.push(e);
     }
-    console.log(edges)
     return {
       nodes,
       edges,
diff --git a/src/app/dialogs/launch-analysis/launch-analysis.component.ts b/src/app/dialogs/launch-analysis/launch-analysis.component.ts
index 7d1474f8..90f8701d 100644
--- a/src/app/dialogs/launch-analysis/launch-analysis.component.ts
+++ b/src/app/dialogs/launch-analysis/launch-analysis.component.ts
@@ -105,7 +105,7 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges {
 
   public async startTask() {
     // all nodes in selection have drugstoneId, hence exist in the backend
-    const seeds = this.analysis.getSelection().map((item) => item.data.drugstoneId).flatMap(l => l)
+    const seeds = this.analysis.getSelection().map((item) => item.id);
     const seedsFiltered = seeds.filter(el => el != null);
     const parameters: any = {
       seeds: seedsFiltered,
diff --git a/src/app/services/analysis/analysis.service.ts b/src/app/services/analysis/analysis.service.ts
index 14c7938e..07e5dbf9 100644
--- a/src/app/services/analysis/analysis.service.ts
+++ b/src/app/services/analysis/analysis.service.ts
@@ -232,7 +232,7 @@ export class AnalysisService {
       licenced: config.licencedDatasets,
       config: config,
       input_network: network,
-      seeds: isSuper ? network.nodes.filter(n => n.drugstoneId && n.drugstoneId[0] === 'p').map(n => n.drugstoneId) : this.getSelection().map((i) => i.id),
+      seeds: isSuper ? network.nodes.filter(n => n.drugstoneId && n.drugstoneId[0] === 'p').map(n => n.id) : this.getSelection().map((i) => i.id),
     };
     const resp = await this.http.post<any>(`${environment.backend}task/`, {
       algorithm: isSuper ? 'super' : 'quick',
diff --git a/src/index.html b/src/index.html
index 28222a51..48802835 100644
--- a/src/index.html
+++ b/src/index.html
@@ -45,8 +45,8 @@
 <div>
   <i>Protein-Protein Interactions</i>
   <select name="Protein-Protein Interactions" onchange="applyDataset()" id="ppi-dataset">
-    <option value="STRING">STRING</option>
     <option value="NeDRex">NeDRex</option>
+    <option value="STRING">STRING</option>
     <option value="biogrid">BioGRID</option>
     <option value="iid">IID</option>
     <option value="IntAct">IntAct</option>
-- 
GitLab