polymerist.polymers.smidgelib.smidgewrite
Automata for reading SMIDGE strings into their graph representations
Attributes
Classes
Information accessed by machine states during the SMIDGE writing process |
|
Abstract base for automaton states used in writing MID graphs to SMIDGE strings |
|
Read a node index off the stack and check if it has already been visited |
|
Visit a node, check if it has predecessors, and mark it as visited |
|
Add an entry for the current node to the output tokens |
|
Add an entry for the current edge to the output tokens |
|
Determine branching and next-node behavior |
|
Add a nodes DFS successor to the traversal stack |
|
Remove any node with no successors from the DFS traversal map |
|
Mark position of branch point in stack for backtrack |
|
Mark the end of a branch |
|
Register machine for translating SMIDGE strings to and from monomer graphs |
Module Contents
- polymerist.polymers.smidgelib.smidgewrite.LOGGER
- class polymerist.polymers.smidgelib.smidgewrite.SMIDGEWriterRegister[source]
Information accessed by machine states during the SMIDGE writing process
- monograph: polymerist.polymers.monographs.MonomerGraph
- tokens: list[int] = []
- curr_idx: int = 0
- visited: set
- node_stack: list[int] = []
- successors: dict[int, list[int]]
- predecessors: dict[int, int]
- finished: bool = False
- property prev_idx: int | None
The index of the precursor to the currently active node
- property node_successors: list[int]
The nodes which follow the current node in the DFS traversal (could be empty)
- class polymerist.polymers.smidgelib.smidgewrite.SMIDGEWriterState[source]
Bases:
abc.ABCAbstract base for automaton states used in writing MID graphs to SMIDGE strings
- state_action(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
- abstractmethod transition(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
Define which states should follow the current one based on input
- class polymerist.polymers.smidgelib.smidgewrite.CheckIsVisitedNode[source]
Bases:
SMIDGEWriterStateRead a node index off the stack and check if it has already been visited
- state_action(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
- transition(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
Define which states should follow the current one based on input
- class polymerist.polymers.smidgelib.smidgewrite.VisitNode[source]
Bases:
SMIDGEWriterStateVisit a node, check if it has predecessors, and mark it as visited
- state_action(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
- transition(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
Define which states should follow the current one based on input
- class polymerist.polymers.smidgelib.smidgewrite.WriteNode[source]
Bases:
SMIDGEWriterStateAdd an entry for the current node to the output tokens
- state_action(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
- transition(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
Define which states should follow the current one based on input
- class polymerist.polymers.smidgelib.smidgewrite.WriteEdge[source]
Bases:
SMIDGEWriterStateAdd an entry for the current edge to the output tokens
- state_action(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
- transition(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
Define which states should follow the current one based on input
- class polymerist.polymers.smidgelib.smidgewrite.DetermineNodeSuccessors[source]
Bases:
SMIDGEWriterStateDetermine branching and next-node behavior
- transition(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
Define which states should follow the current one based on input
- class polymerist.polymers.smidgelib.smidgewrite.PushNodeSuccessor[source]
Bases:
SMIDGEWriterStateAdd a nodes DFS successor to the traversal stack
- state_action(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
- transition(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
Define which states should follow the current one based on input
- class polymerist.polymers.smidgelib.smidgewrite.UpdateNodeSuccessors[source]
Bases:
SMIDGEWriterStateRemove any node with no successors from the DFS traversal map
- state_action(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
- transition(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
Define which states should follow the current one based on input
- class polymerist.polymers.smidgelib.smidgewrite.BranchStart[source]
Bases:
SMIDGEWriterStateMark position of branch point in stack for backtrack
- state_action(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
- transition(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
Define which states should follow the current one based on input
- class polymerist.polymers.smidgelib.smidgewrite.BranchEnd[source]
Bases:
SMIDGEWriterStateMark the end of a branch
- state_action(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
- transition(register: SMIDGEWriterRegister) SMIDGEWriterState[source]
Define which states should follow the current one based on input
- class polymerist.polymers.smidgelib.smidgewrite.SMIDGEWriter[source]
Register machine for translating SMIDGE strings to and from monomer graphs
- state: SMIDGEWriterState
- write_smidge_connected_component(monograph: polymerist.polymers.monographs.MonomerGraph, start_node_idx: int | None = None) polymerist.polymers.monographs.MonomerGraph[source]
Parse a single connected component of a monomer graph into a SMIDGE string
- write_smidge(monograph: polymerist.polymers.monographs.MonomerGraph, start_node_idxs: int | Sequence[int] | None = None) str[source]
Parse all connected components of a monograph into a complete SMIDGE string