From 4ebba5f07cd0dbab14eba79bdb886f811cb0b702 Mon Sep 17 00:00:00 2001
From: AndiMajore <andi.majore@googlemail.com>
Date: Wed, 8 Feb 2023 17:53:43 +0100
Subject: [PATCH] fixed seed issue at quick drug search

---
 docker-django.env.dev |  2 +-
 drugstone/views.py    |  2 ++
 tasks/quick_task.py   | 14 ++++++++++----
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/docker-django.env.dev b/docker-django.env.dev
index 6f5a076..91d6c04 100644
--- a/docker-django.env.dev
+++ b/docker-django.env.dev
@@ -15,4 +15,4 @@ CELERY_BROKER_URL=redis://redis:6379/0
 FLOWER_PORT=8888
 FLOWER_BASIC_AUTH=drugstone:test
 GT_THREADS=2
-DB_UPDATE_ON_START=1
\ No newline at end of file
+DB_UPDATE_ON_START=0
\ No newline at end of file
diff --git a/drugstone/views.py b/drugstone/views.py
index 878eb0b..e6b20cf 100755
--- a/drugstone/views.py
+++ b/drugstone/views.py
@@ -291,7 +291,9 @@ def result_view(request) -> Response:
     if not node_types:
         node_types = {}
         node_attributes['node_types'] = node_types
+
     is_seed = node_attributes.get('is_seed')
+    print(result)
     if not is_seed:
         is_seed = {}
         node_attributes['is_seed'] = is_seed
diff --git a/tasks/quick_task.py b/tasks/quick_task.py
index 899674d..a49536e 100755
--- a/tasks/quick_task.py
+++ b/tasks/quick_task.py
@@ -1,7 +1,8 @@
 from tasks.task_hook import TaskHook
 
+
 def quick_task(task_hook: TaskHook):
-    def run_closeness(parameters, network):
+    def run_closeness(parameters, network, original_seeds=None):
         from .closeness_centrality import closeness_centrality
 
         def closeness_progress(progress, status):
@@ -9,6 +10,8 @@ def quick_task(task_hook: TaskHook):
 
         def closeness_set_result(result):
             result["network"]["edges"].extend(network["edges"])
+            if original_seeds is not None:
+                result['node_attributes']['is_seed'] = original_seeds
             task_hook.set_results(result)
 
         # Prepare intermediate hook
@@ -20,7 +23,6 @@ def quick_task(task_hook: TaskHook):
         # Run closeness centrality
         closeness_centrality(closeness_task_hook)
 
-
     def run_multi_steiner(parameters):
         from .multi_steiner import multi_steiner
 
@@ -35,7 +37,7 @@ def quick_task(task_hook: TaskHook):
             if len(seeds) == 0:
                 task_hook.set_results({"network": {"nodes": [], "edges": []}})
                 return
-
+            og_seeds = parameters.get('seeds')
             parameters.update({
                 "seeds": seeds,
                 "result_size": 10,
@@ -43,7 +45,11 @@ def quick_task(task_hook: TaskHook):
                 "target": "drug",
                 "include_non_approved_drugs": True
             })
-            run_closeness(parameters, result["network"])
+            is_seed = result.get('node_attributes')
+            run_closeness(parameters, result["network"], result['node_attributes']['is_seed'])
+            # parameters.update({
+            #     "seeds": og_seeds
+            # })
 
         parameters["num_trees"] = 1
         parameters["hub_penalty"] = 1
-- 
GitLab