pd2af 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pd2af/__init__.py ADDED
@@ -0,0 +1,16 @@
1
+ """Transform a process-description map into an activity-flow map."""
2
+
3
+ from pd2af.core import TransformerResult, transform
4
+ from pd2af.modes import (
5
+ TransformationMode,
6
+ get_transformation_mode,
7
+ get_transformation_modes,
8
+ )
9
+
10
+ __all__ = [
11
+ "TransformationMode",
12
+ "TransformerResult",
13
+ "get_transformation_mode",
14
+ "get_transformation_modes",
15
+ "transform",
16
+ ]
pd2af/asp/__init__.py ADDED
@@ -0,0 +1 @@
1
+ """The ASP side: the atoms, the rules and the solver that answers them."""
@@ -0,0 +1,203 @@
1
+ """The clorm predicates the ASP program is written against."""
2
+
3
+ import clorm
4
+ import momapy.celldesigner
5
+
6
+
7
+ class keptSpeciesKey(clorm.Predicate):
8
+ """Activity-key wrapper: the AF activity reuses an input PD species by identity.
9
+
10
+ The single argument is the original CellDesigner species ID. The
11
+ solver looks it up in ``id_to_model_element`` to recover the
12
+ ``Species`` object.
13
+ """
14
+
15
+ species: clorm.ConstantStr
16
+
17
+
18
+ class promotedSubunitKey(clorm.Predicate):
19
+ """Activity-key wrapper: a PD subunit of a dissolved complex is promoted.
20
+
21
+ The subunit becomes a top-level activity, added to ``model.species``. The
22
+ single argument is the synthetic ASP ID of the subunit species.
23
+ Emitted by the ``no-complex`` mode.
24
+ """
25
+
26
+ species: clorm.ConstantStr
27
+
28
+
29
+ _ACTIVITY_KEY = keptSpeciesKey | promotedSubunitKey
30
+
31
+
32
+ class logicalOperatorKey(clorm.Predicate):
33
+ """Activity-source wrapper: the AF influence is sourced by a logical operator.
34
+
35
+ The operator (AND / OR / NOT / unknown) is authored in the input PD map. The
36
+ single argument is the original gate ID -- a CellDesigner
37
+ ``BooleanLogicGate`` or an SBGN-PD ``LogicalOperator``. The solver
38
+ looks it up in ``clingo_id_to_model_element`` to recover the gate
39
+ object. An operator is only ever an influence *source*, never a
40
+ target, so it widens ``_INFLUENCE_SOURCE`` but not the activity key.
41
+ """
42
+
43
+ gate: clorm.ConstantStr
44
+
45
+
46
+ # The source of an influence edge: an activity (the two activity-key
47
+ # wrappers) or a logical operator. The target is always an activity, so
48
+ # only the influence ``source`` field is widened to this union.
49
+ _INFLUENCE_SOURCE = _ACTIVITY_KEY | logicalOperatorKey
50
+
51
+
52
+ class activity(clorm.Predicate):
53
+ """An activity node in the new AF map.
54
+
55
+ Always wrapped by ``new(...)`` in rule heads. The ``key`` field
56
+ carries the activity's identity — one of the two activity-key
57
+ wrappers.
58
+ """
59
+
60
+ key: _ACTIVITY_KEY
61
+
62
+
63
+ # Influence edges in the new AF map. There is one typed predicate per
64
+ # output influence class; the rules first converge on an internal
65
+ # ``influences(SOURCE, TARGET, KIND)`` relation (ASP-only, never wrapped
66
+ # in ``new``) and then fan it out to these typed heads. Each is always
67
+ # wrapped by ``new(...)`` in rule heads.
68
+
69
+
70
+ class positivelyInfluences(clorm.Predicate):
71
+ """A positive-influence edge (source activates target)."""
72
+
73
+ source: _INFLUENCE_SOURCE
74
+ target: _ACTIVITY_KEY
75
+
76
+
77
+ class negativelyInfluences(clorm.Predicate):
78
+ """A negative-influence edge (source inhibits target)."""
79
+
80
+ source: _INFLUENCE_SOURCE
81
+ target: _ACTIVITY_KEY
82
+
83
+
84
+ class modulates(clorm.Predicate):
85
+ """A modulation edge: source influences target with an effect of unknown sign."""
86
+
87
+ source: _INFLUENCE_SOURCE
88
+ target: _ACTIVITY_KEY
89
+
90
+
91
+ class triggers(clorm.Predicate):
92
+ """A triggering edge (necessary stimulation): source is required for target."""
93
+
94
+ source: _INFLUENCE_SOURCE
95
+ target: _ACTIVITY_KEY
96
+
97
+
98
+ class unknownPositivelyInfluences(clorm.Predicate):
99
+ """A positive-influence edge whose existence is uncertain."""
100
+
101
+ source: _INFLUENCE_SOURCE
102
+ target: _ACTIVITY_KEY
103
+
104
+
105
+ class unknownNegativelyInfluences(clorm.Predicate):
106
+ """A negative-influence edge whose existence is uncertain."""
107
+
108
+ source: _INFLUENCE_SOURCE
109
+ target: _ACTIVITY_KEY
110
+
111
+
112
+ class unknownModulates(clorm.Predicate):
113
+ """A modulation edge whose existence is uncertain."""
114
+
115
+ source: _INFLUENCE_SOURCE
116
+ target: _ACTIVITY_KEY
117
+
118
+
119
+ class unknownTriggers(clorm.Predicate):
120
+ """A triggering edge whose existence is uncertain."""
121
+
122
+ source: _INFLUENCE_SOURCE
123
+ target: _ACTIVITY_KEY
124
+
125
+
126
+ class logicalOperator(clorm.Predicate):
127
+ """A logical operator node in the new AF map.
128
+
129
+ Always wrapped by ``new(...)`` in rule heads. ``key`` carries the
130
+ operator's identity; ``type_`` is the operator-type token
131
+ (``and`` | ``or`` | ``not_`` | ``unknown``). The NOT token is spelt
132
+ ``not_`` -- with a trailing underscore -- because bare ``not`` is a
133
+ reserved clingo keyword (default negation) and cannot appear as a
134
+ term. The builder maps the token to the momapy operator class per
135
+ output language
136
+ (``BooleanLogicGate`` subclass for CellDesigner, ``LogicalOperator``
137
+ subclass for SBGN-AF). A single token field -- rather than one
138
+ predicate per type -- mirrors the internal ``influences/3``
139
+ KIND-token idiom and avoids same-name collisions with the input
140
+ ontology's per-type operator functors.
141
+ """
142
+
143
+ key: logicalOperatorKey
144
+ type_: clorm.ConstantStr
145
+
146
+
147
+ class logicalOperatorInput(clorm.Predicate):
148
+ """An input edge of a logical operator: one activity feeding it.
149
+
150
+ Always wrapped by ``new(...)`` in rule heads. The input is an activity
151
+ key, or -- for SBGN-PD, where a logical operator's input may refer to
152
+ another logical operator -- the key of that operator, mirroring how
153
+ ``_INFLUENCE_SOURCE`` widens an influence source.
154
+ """
155
+
156
+ operator: logicalOperatorKey
157
+ input: _ACTIVITY_KEY | logicalOperatorKey
158
+
159
+
160
+ class new(clorm.Predicate):
161
+ """Top-level marker: this fact belongs to the *new* AF map being constructed.
162
+
163
+ As opposed to facts about the input PD map.
164
+ """
165
+
166
+ object_: (
167
+ activity
168
+ | positivelyInfluences
169
+ | negativelyInfluences
170
+ | modulates
171
+ | triggers
172
+ | unknownPositivelyInfluences
173
+ | unknownNegativelyInfluences
174
+ | unknownModulates
175
+ | unknownTriggers
176
+ | logicalOperator
177
+ | logicalOperatorInput
178
+ )
179
+
180
+
181
+ # The typed influence predicates emitted into ``new(...)``.
182
+ INFLUENCE_PREDICATES = (
183
+ positivelyInfluences,
184
+ negativelyInfluences,
185
+ modulates,
186
+ triggers,
187
+ unknownPositivelyInfluences,
188
+ unknownNegativelyInfluences,
189
+ unknownModulates,
190
+ unknownTriggers,
191
+ )
192
+
193
+
194
+ predicate_to_model_element_class = {
195
+ positivelyInfluences: momapy.celldesigner.PositiveInfluence,
196
+ negativelyInfluences: momapy.celldesigner.NegativeInfluence,
197
+ modulates: momapy.celldesigner.Modulation,
198
+ triggers: momapy.celldesigner.Triggering,
199
+ unknownPositivelyInfluences: momapy.celldesigner.UnknownPositiveInfluence,
200
+ unknownNegativelyInfluences: momapy.celldesigner.UnknownNegativeInfluence,
201
+ unknownModulates: momapy.celldesigner.UnknownModulation,
202
+ unknownTriggers: momapy.celldesigner.UnknownTriggering,
203
+ }