Skip to content

SBGN-AF model

pd2af.building.sbgn.model

Build the SBGN-AF model from clingo activity / influence atoms.

make_and_add_model is the AF model pass: it walks the activity atoms (keptSpeciesKey / promotedSubunitKey keys, each resolving to an input SBGN-PD entity pool, phenotype or promoted subunit) and the influence atoms, and populates context.model with canonical, content-deduped compartments, activities and influences.

Each entity pool becomes a :class:BiologicalActivity carrying a typed :class:UnitOfInformation (the entity class) and a label that is the canonical serialization of the whole entity pool (:mod:pd2af.building.sbgn.labels). In the merged reading (keep_species off) the label is built with state variables stripped, so the distinct forms of the same base entity collapse to one merged activity, and the entity's unit-of-information block is moved off the label onto the typed :class:UnitOfInformation glyph (a curator's AF map carries ct:mRNA on the glyph -- no brackets -- not [ct:mRNA] in the label); otherwise the label keeps both blocks and distinct forms stay distinct under content-based model equality. A PD :class:Phenotype process becomes an AF :class:Phenotype activity. Dedup is honoured by interning every constructed element through the shared content cache (register_or_reuse) and resolving influence endpoints through the deduped activities, mirroring the model-element dedup invariant.

Functions:

Name Description
make_and_add_model

Build context.model from the clingo atoms (pass 1).

make_and_add_model

make_and_add_model(context: BuilderContext, clingo_model: Any)

Build context.model from the clingo atoms (pass 1).

Source code in src/pd2af/building/sbgn/model.py
def make_and_add_model(
    context: pd2af.building.context.BuilderContext, clingo_model: typing.Any
):
    """Build ``context.model`` from the clingo atoms (pass 1)."""
    context.model = momapy.builder.get_or_make_builder_cls(momapy.sbgn.af.SBGNAFModel)()
    pd2af.building.model.collect_atoms(context, clingo_model)
    context.subunit_to_top_level = pd2af.building.model.build_subunit_to_top_level(
        context.input_map.model.entity_pools
    )
    _make_and_add_compartments(context)
    _make_and_add_activities(context)
    pd2af.building.model.make_and_add_operators(
        context,
        _OPERATOR_TYPE_TO_OPERATOR_CLASS,
        momapy.sbgn.af.LogicalOperatorInput,
        context.model.logical_operators,
    )
    _make_and_add_influences(context)