[Feature] Integrate DOI Links, Handle Cycles in Pathway Viz (#407)

Co-authored-by: Tim Lorsbach <tim@lorsba.ch>
Reviewed-on: enviPath/enviPy#407
This commit is contained in:
2026-06-03 06:00:38 +12:00
parent 868bbf5c05
commit 14cfc1e4d7
7 changed files with 169 additions and 19 deletions

View File

@ -1773,7 +1773,7 @@ class Reaction(
return new_reaction
def smirks(self):
return f"{'.'.join([cs.smiles for cs in self.educts.all()])}>>{'.'.join([cs.smiles for cs in self.products.all()])}"
return f"{'.'.join([cs.smiles for cs in self.educts.all().order_by('-pk')])}>>{'.'.join([cs.smiles for cs in self.products.all().order_by('-pk')])}"
@property
def as_svg(self):
@ -1886,6 +1886,9 @@ class Pathway(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMix
if n not in queue:
queue.append(n)
for i in queue:
processed.add(i)
while len(queue):
current = queue.pop()
processed.add(current)
@ -2194,17 +2197,8 @@ class Pathway(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMix
depth_map[0] = list()
processed = set()
for n in self.nodes:
num_parents = in_count[str(n.uuid)]
if num_parents == 0:
# must be a root node or unconnected node
if n.depth != 0:
n.depth = 0
n.save()
# Only root node may have children
if out_count[str(n.uuid)] > 0:
depth_map[0].append(n)
for n in self.root_nodes:
depth_map[0].append(n)
# At most depth len(nodes) is possible
for i in range(self.nodes.count()):
@ -2227,7 +2221,7 @@ class Pathway(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMix
for depth, nodes in depth_map.items():
for n in nodes:
if n.depth != depth:
if n.depth != depth and depth != 0:
n.depth = depth
n.save()