Skip to content
Snippets Groups Projects
Commit 9b171f07 authored by David Hoksza's avatar David Hoksza
Browse files

handling compoartments overlaps

parent 264565e2
No related branches found
No related tags found
No related merge requests found
......@@ -299,12 +299,7 @@ def resolve_compartments_overlap(g_cc: nx.MultiGraph, gs: List[nx.MultiGraph], c
lt.pan(gs[ix], min_shift)
def handle_overlaps(g_cc: nx.MultiGraph, gs: List[nx.MultiGraph]):
#First we group the connected components by compartment name
def get_compartment_dict(gs: List[nx.MultiGraph]) -> Dict[str, List[int]]:
cmp_ix: Dict[str, List[int]] = {}
for i in range(len(gs)):
cmp_name: str = gu.get_first_species(gs[i]).get_compartment_name()
......@@ -312,6 +307,16 @@ def handle_overlaps(g_cc: nx.MultiGraph, gs: List[nx.MultiGraph]):
cmp_ix[cmp_name] = []
cmp_ix[cmp_name].append(i)
return cmp_ix
def handle_overlaps(g_cc: nx.MultiGraph, gs: List[nx.MultiGraph], cmp_ix: Dict[str, List[int]]):
#First we group the connected components by compartment name
cmp_names = list(cmp_ix)
for i in range(len(cmp_ix)):
cmp_name1 = cmp_names[i]
......@@ -323,14 +328,19 @@ def handle_overlaps(g_cc: nx.MultiGraph, gs: List[nx.MultiGraph]):
if bb1.intersects_rectangle(bb2):
resolve_compartments_overlap(g_cc, gs, cmp_ix[cmp_name1], cmp_ix[cmp_name2], bb1, bb2)
def optimize_layout(g_cc, gs):
def clear_spaces(g_cc, gs):
NotImplemented
def optimize_layout(g_cc, gs, cmp_ix):
NotImplemented
def layout_ccs(g_cc: nx.MultiGraph, gs: List[nx.MultiGraph]):
# https://pypi.org/project/forcelayout/
initial_layout(g_cc, gs)
handle_overlaps(g_cc, gs)
cmp_ix = get_compartment_dict(gs)
handle_overlaps(g_cc, gs, cmp_ix)
clear_spaces(g_cc, gs, cmp_ix)
optimize_layout(g_cc, gs)
# layout = fl.draw_spring_layout(dataset=dataset, algorithm=fl.SpringForce)
......
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