API reference#
This reference documents the public interface re-exported from the top-level
molfoundry package – everything listed in molfoundry.__all__. It is
generated directly from the source and its type hints, so it always matches the
installed version.
Building molecules and graphs#
Constructors that turn a textual description into a Graph, plus the
graph data structure itself.
Chemical attributes#
Value types used to label and describe atoms, bonds, and graphs.
Representation of the charge of an atom. |
|
Representation of the isotope of an atom. |
|
Identifies a chemical element and exposes its data from the shared |
|
Rules and rule composition#
Transformation rules and the algebra for combining them.
Build a |
|
Build a |
|
Build a |
|
Build a |
|
Which graphs a rule application may use, given the list of graphs it is applied to. |
|
Evaluates rule-composition expressions. |
|
A rule-composition expression. |
|
Every vertex with a label in |
|
The edges at a vertex number |
|
Every child condition holds (true for no children). |
|
At least one child condition holds (false for no children). |
|
The child condition does not hold. |
|
One graph of a rule-composition overlap, as seen by a predicate. |
|
A vertex of a |
|
An edge of a |
Rule spans#
Read-only views of a rule’s vertices and edges, from Rule.vertices and
Rule.edges. Instead of three separate graphs L, K and R, a rule exposes its
span: each element knows how the rule treats it (its Membership) and
carries its image on the left side (as matched) and on the right side (as
produced), or None where the rule does not have it.
One vertex of a rule's span, identified by its rule node |
|
One edge of a rule's span, joining two |
|
A rule vertex as it appears on one side (left or right) of the rewrite. |
|
A rule edge as it appears on one side (left or right) of the rewrite. |
|
How a rule vertex or edge behaves across the rewrite. |
Rule constraints and conditions#
Read-only views of where a rule may match: Rule.matchConstraintsAdjacency,
matchConstraintsLabelAny, matchConstraintsShortestPath,
matchConstraintsNoEdge and the nested application condition
Rule.matchCondition. Vertices are named by rule node id, as in GML. The same
classes state the constraints and condition of an identity rule built with
Rule.identity. Constraint is the type of any one match constraint,
and Condition the type of any node of a condition tree.
The comparison of an adjacency or shortest-path constraint. |
|
Vertex |
|
The label (term variable) |
|
The shortest path from |
|
No edge joins |
|
Always satisfied ( |
|
The match extends to a larger pattern (GML |
|
|
|
All |
|
At least one of |
|
A vertex a |
|
An edge a |
|
Derivation graphs#
Reaction networks built by applying rules, and the objects that describe how each derivation maps atoms.
Enumerates the atom-atom maps of a hyperedge. |
|
An atom-atom map of a hyperedge, as a sequence of |
|
One atom of an atom-atom map. |
|
The result of |
|
Drawing#
Printers and the settings that control how graphs, rules, derivations and
derivation graphs are drawn. GraphPrinter styles molecules and rules;
DGPrinter styles a whole derivation graph and embeds a
GraphPrinter for its molecules. Drawing graphs and rules shows every
setting with its result.
The depiction style for a molecule / graph. |
|
The rendering style for a depiction — how strokes and glyphs are drawn. |
|
Which layout engine positions atoms/vertices for a depiction. |
|
How an SVG resolves its light/dark theme. |
|
A marker drawn on top of a graph vertex — a colored shape carrying a short label. |
|
The marker shape a |
|
Configures how a derivation graph is rendered by |
|
Controls how a locked derivation graph is laid out for printing. |
|
Which algorithm positions a derivation graph. |
Strategies#
The strategy DSL that drives network expansion.
Pathways and integer flow#
Integer hyperflow models over a derivation graph: how often each reaction fires
to turn the declared inflow into the declared outflow. FlowModel solves
with Gurobi and FlowModelSMT with z3; both return FlowSolution
objects, whose certificates give a concrete firing order.
A Gurobi integer-flow model over a derivation graph. |
|
An SMT (z3) integer-flow model over a derivation graph. |
|
A solved integer hyperflow over a derivation graph: how many times each reaction fires, plus the inflow / outflow on each boundary species. |
|
A witness that a |
|
Whether a flow model's objective is minimized or maximized. |
Stochastic simulation#
Rule-based Gillespie simulation with on-demand network expansion.
Rule-based Gillespie stochastic simulation with on-demand network expansion. |
|
Exact multiphase (multi-compartment) stochastic simulation. |
|
Load a structured |
|
A loaded trajectory artifact, ready for downstream analysis. |
|
Per-species metadata from the trajectory artifact (one DG vertex). |
Post-processing and global state#
Summary output and the implicit global input collections.
Built-in mutable sequence. |
|
Built-in mutable sequence. |
Script inclusion#
Textual inclusion of one script into another. include() executes a file
in the caller’s namespace (its definitions leak into the includer, unlike
import) while maintaining a directory-prefix stack so that relative
filenames inside the included file resolve relative to it.
Execute another MolFoundry script in the caller's namespace. |
|
Convert a script-relative path to a working-directory-relative one. |
|
Push a prefix consulted by |
|
Pop the most recently pushed prefix. |
|
Wrap a filename to disable |