[Feature] Legacy API Layer (#80)

Co-authored-by: Tim Lorsbach <tim@lorsba.ch>
Reviewed-on: enviPath/enviPy#80
This commit is contained in:
2025-09-03 01:35:51 +12:00
parent 4e02910c62
commit 4158bd36cb
6 changed files with 785 additions and 5 deletions

View File

@ -889,6 +889,23 @@ class CompoundStructure(EnviPathModel, AliasMixin, ScenarioMixin, ChemicalIdenti
def as_svg(self, width: int = 800, height: int = 400):
return IndigoUtils.mol_to_svg(self.smiles, width=width, height=height)
@property
def related_pathways(self):
pathways = Node.objects.filter(node_labels__in=[self]).values_list('pathway', flat=True)
return Pathway.objects.filter(package=self.compound.package, id__in=set(pathways)).order_by('name')
@property
def related_reactions(self):
return (
Reaction.objects.filter(package=self.compound.package, educts__in=[self])
|
Reaction.objects.filter(package=self.compound.package, products__in=[self])
).order_by('name')
@property
def is_default_structure(self):
return self.compound.default_structure == self
class Rule(PolymorphicModel, EnviPathModel, AliasMixin, ScenarioMixin):
package = models.ForeignKey('epdb.Package', verbose_name='Package', on_delete=models.CASCADE, db_index=True)