From 9950112311c663ba09ce94011c14e3ab3e9b0c12 Mon Sep 17 00:00:00 2001 From: jebus Date: Sat, 28 Jun 2025 06:40:58 +1200 Subject: [PATCH] Implemented Reaction Page (#5) Co-authored-by: Tim Lorsbach Reviewed-on: https://git.envipath.com/enviPath/enviPy/pulls/5 --- epdb/models.py | 13 ++++++ templates/objects/reaction.html | 77 ++++++++++++++++++++++++++++++++- 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/epdb/models.py b/epdb/models.py index a009f1b9..5d7a69ad 100644 --- a/epdb/models.py +++ b/epdb/models.py @@ -612,6 +612,19 @@ class Reaction(EnviPathModel, AliasMixin, ScenarioMixin): r.save() return r + def smirks(self): + return f"{'.'.join([cs.smiles for cs in self.educts.all()])}>>{'.'.join([cs.smiles for cs in self.products.all()])}" + + @property + def as_svg(self): + return IndigoUtils.smirks_to_svg(self.smirks(), False, width=800, height=400) + + @property + def related_pathways(self): + return Pathway.objects.filter( + id__in=Edge.objects.filter(edge_label=self).values('pathway_id')).order_by('name') + + class Pathway(EnviPathModel, AliasMixin, ScenarioMixin): package = models.ForeignKey('epdb.Package', verbose_name='Package', on_delete=models.CASCADE, db_index=True) diff --git a/templates/objects/reaction.html b/templates/objects/reaction.html index 94150e43..9b50b960 100644 --- a/templates/objects/reaction.html +++ b/templates/objects/reaction.html @@ -23,9 +23,82 @@ -
-

{{ reaction.description }}

+ + +
+

+ Description +

+
+
+ {{ reaction.description }} +
+
+ + + +
+
+
+ {{ reaction.as_svg|safe }} +
+
+
+ + + +
+
+ {% for educt in reaction.educts.all %} + {{ educt.name }} + {% endfor %} + + {% for product in reaction.products.all %} + {{ product.name }} + {% endfor %} +
+
+ + + +
+
+ {{ reaction.smirks }} +
+
+ + +
+

+ Pathways +

+
+
+
+ {% for r in reaction.related_pathways %} + {{ r.name }} + {% endfor %} +
+
+