adjusted migration
Some checks failed
CI / test (pull_request) Failing after 17s
API CI / api-tests (pull_request) Failing after 24s

Initial bayer app

Show Pack Classification

Adjusted docker compose to bayer specifics

Adjusted Dockerfile for Bayer

Adding secret flags to group, add secret pools to packages

Adjusted View for Package creation

Prep configs, added Package Create Modal

wip

More on PES

wip

wip

Wip

minor

PW interactions

API PES

wip

Make Select Widget reflect required

make required generallay available

Update UI if pathway mode is set to build

Added ais

circle adjustments

Initial Zoom, fix AD Creation

wip

auth log, bb4g fix

missing import

Added viz hint if PES is part of reaction

Add Edge check for pes

flip boolean

...

pes

Added extra

...

In / Out Edges Viz, Submitting Button Text

...

Make PES Link clickable

Return proper http response instead of error

Fixed error return, removed unused options

Fix PES Link HTML for other entities

Fixed molfile assignment, adjusted Export

Package Export/Import cycle

highlight Description links

implemented non persistent

Harmonised proposed field in Json output

Added pesLink field to PW Api output

PES Fields in API Output

removed debug

Fix Classification import, Fix PES Deserialization

underline pes link in templates

Fix alter name/desc for node, make /node /edge funcitonal

provide setting link and copy button

Implemented Compound Names / Reaction Names View Option

Unconnected Nodes

Make links thicker, reduce timeout trigger time

Show proposed info in popover

Pathway Build no stereo removal

Include probs in reaction name option viz

Detect clicks outside nodes/edges
This commit is contained in:
Tim Lorsbach
2026-03-06 15:15:08 +01:00
parent 72a63b4876
commit 421d33dddc
76 changed files with 1614124 additions and 2943 deletions

View File

@ -12,6 +12,7 @@ from django.conf import settings as s
from ninja import Schema
from pydantic import HttpUrl, ValidationError
from bayer.models import PESCompound, PESStructure
from epdb.exceptions import PackageImportException
from epdb.models import (
AdditionalInformation,
@ -34,7 +35,7 @@ logger = logging.getLogger(__name__)
Package = s.GET_PACKAGE_MODEL()
if TYPE_CHECKING:
from epdb.logic import SPathway
from epdb.logic import SPathway, GroupManager
class LicenseExportSchema(Schema):
@ -56,6 +57,9 @@ class RefExportSchema(Schema):
return str(value)
class RefGroupExportSchema(RefExportSchema): ...
class RefCompoundExportSchema(RefExportSchema): ...
@ -105,6 +109,26 @@ class CompoundStructureExportSchema(RefCompoundStructureExportSchema):
scenarios: List[RefScenarioExportSchema]
class PESCompoundExportSchema(RefCompoundExportSchema):
name: str
description: str
aliases: List[str]
default_structure: RefCompoundStructureExportSchema
structures: List["PESCompoundStructureExportSchema"]
scenarios: List[RefScenarioExportSchema]
class PESCompoundStructureExportSchema(RefCompoundStructureExportSchema):
name: str
description: str
aliases: List[str]
smiles: str
molfile: Optional[str]
normalized_structure: bool
scenarios: List[RefScenarioExportSchema]
pes_link: HttpUrl
############
# Reaction #
############
@ -227,7 +251,9 @@ class PackageExportSchema(Schema):
uuid: str
reviewed: bool
license: LicenseExportSchema | None = None
compounds: List[CompoundExportSchema]
classification_level: str = "Internal"
data_pool: RefGroupExportSchema | None = None
compounds: List[CompoundExportSchema | PESCompoundExportSchema]
reactions: List[ReactionExportSchema]
simple_rules: List[RuleExportSchema]
composite_rules: List[ParallelRuleExportSchema]
@ -240,14 +266,30 @@ class PackageExportSchema(Schema):
value = obj.get("uuid") if isinstance(obj, dict) else obj.uuid
return str(value)
@staticmethod
def resolve_classification_level(obj):
if isinstance(obj, dict):
return obj["classification_level"]
return obj.Classification(obj.classification_level).name
@staticmethod
def resolve_compounds(obj):
res = []
if isinstance(obj, dict):
for c in obj.get("compounds", []):
res.append(CompoundExportSchema.model_validate(c))
return res
return obj.compounds.all()
is_pes = any([cs.get("pes_link", None) is not None for cs in c.get("structures", [])])
if is_pes:
res.append(PESCompoundExportSchema.model_validate(c))
else:
res.append(CompoundExportSchema.model_validate(c))
else:
for c in obj.compounds.all():
if isinstance(c, PESCompound):
res.append(PESCompoundExportSchema.from_orm(c))
else:
res.append(CompoundExportSchema.from_orm(c))
return res
@staticmethod
def resolve_simple_rules(obj):
@ -311,12 +353,18 @@ class PackageImporter:
return self._import_package_from_json()
def _import_compounds(
self,
package: Package,
compounds: List[CompoundExportSchema],
self,
package: Package,
compounds: List[CompoundExportSchema | PESCompoundExportSchema],
):
for c in compounds:
new_c = Compound()
if isinstance(c, PESCompoundExportSchema):
c_cls = PESCompound
else:
c_cls = Compound
new_c = c_cls()
new_c.uuid = str(uuid.uuid4()) if not self.preserve_uuids else c.uuid
new_c.package = package
new_c.name = c.name
@ -327,7 +375,13 @@ class PackageImporter:
self._cache[c.uuid] = new_c
for cs in c.structures:
new_cs = CompoundStructure()
if isinstance(cs, PESCompoundStructureExportSchema):
cs_cls = PESStructure
else:
cs_cls = CompoundStructure
new_cs = cs_cls()
new_cs.uuid = str(uuid.uuid4()) if not self.preserve_uuids else cs.uuid
new_cs.compound = new_c
new_cs.name = cs.name
@ -336,6 +390,9 @@ class PackageImporter:
new_cs.smiles = cs.smiles
new_cs.molfile = cs.molfile
if cs_cls == PESStructure:
new_cs.pes_link = cs.pes_link
new_cs.normalized_structure = cs.normalized_structure
new_cs.save()
@ -514,6 +571,7 @@ class PackageImporter:
package_uuid = parsed.uuid
package_license = License.objects.get(link=parsed.license.link) if parsed.license else None
package_classification_level = Package.Classification[parsed.classification_level.upper()]
package = Package()
package.uuid = package_uuid
@ -521,6 +579,10 @@ class PackageImporter:
package.description = parsed.description
package.reviewed = False
package.license = package_license
package.classification_level = package_classification_level
if package_classification_level == Package.Classification.SECRET:
package.data_pool = Group.objects.get(uuid=parsed.data_pool.uuid)
package.save()