Skip to content
Snippets Groups Projects
Commit 33e07606 authored by Hartung, Michael's avatar Hartung, Michael
Browse files

Allow custom edges in algorithms

parent 22cf7552
No related branches found
No related tags found
No related merge requests found
Checking pipeline status
......@@ -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)
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment