From c1d7e66b25807c9441055f94d9e8bc8341de080f Mon Sep 17 00:00:00 2001
From: "Hartung, Michael" <michael.hartung@uni-hamburg.de>
Date: Fri, 30 Sep 2022 17:38:00 +0200
Subject: [PATCH] Allow custom edges in algorithms

---
 tasks/trust_rank.py        |  2 +-
 tasks/util/custom_edges.py | 10 ++++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/tasks/trust_rank.py b/tasks/trust_rank.py
index 2283d74..0b3d677 100755
--- a/tasks/trust_rank.py
+++ b/tasks/trust_rank.py
@@ -213,7 +213,7 @@ def trust_rank(task_hook: TaskHook):
     if custom_edges:
       edges = task_hook.parameters.get("input_network")['edges']
       g = add_edges(g, edges)
-    
+      
     task_hook.set_progress(1 / 4.0, "Computing edge weights.")
     weights = edge_weights(g, hub_penalty, inverse=True)
     
diff --git a/tasks/util/custom_edges.py b/tasks/util/custom_edges.py
index d0b8ea2..713f679 100644
--- a/tasks/util/custom_edges.py
+++ b/tasks/util/custom_edges.py
@@ -11,8 +11,10 @@ def add_edges(g, edge_list):
     mapping = make_node_id_map(g)
     edge_id_list = []
     for edge in edge_list:
-        a = mapping[edge['from']]
-        b = mapping[edge['to']]
-        edge_id_list.append((a, b))
-    g.add_edge_list(edge_list)
+        a = mapping[edge['from']] if edge['from'] in mapping else False
+        b = mapping[edge['to']] if edge['to'] in mapping else False
+        if a and b:
+            edge_id_list.append((a, b, 'protein-protein'))
+    e_type = g.edge_properties["type"]
+    g.add_edge_list(edge_id_list, eprops=[e_type])
     return g
\ No newline at end of file
-- 
GitLab