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