polymerist.polymers.monographs ============================== .. py:module:: polymerist.polymers.monographs .. autoapi-nested-parse:: Tools for generating and manipulating monomer connectivity graphs Attributes ---------- .. autoapisummary:: polymerist.polymers.monographs.MonoGraph Classes ------- .. autoapisummary:: polymerist.polymers.monographs.MonomerGraph polymerist.polymers.monographs.MonomerGraphSerializer Module Contents --------------- .. py:class:: MonomerGraph(incoming_graph_data=None, **attr) Bases: :py:obj:`networkx.Graph` A graph representation of the connectivity of monomer fragments in a polymer topology .. py:attribute:: MONOMER_NAME_ATTR :type: ClassVar[str] :value: 'monomer_name' .. py:attribute:: FLAVOR_DICT_ATTR :type: ClassVar[dict[int, int]] :value: 'neighbor_flavors' .. py:attribute:: BONDTYPE_ATTR :type: ClassVar[str] :value: 'bondtype' .. py:method:: get_monomer_name_at_node_index(node_idx: int) -> Optional[str] Recover the assigned monomer name for the node at the given index .. py:method:: get_flavor_dict_at_node_index(node_idx: int) -> Optional[dict[int, int]] Recover the assigned dictionary of neighbor flavors for the node at the given index .. py:property:: num_monomers :type: int Number of monomer units represented in the current polymer .. py:property:: is_unbranched :type: bool Whether the monomer graph represents straight chain(s) without branching .. py:attribute:: is_linear .. py:property:: terminal_monomers :type: Generator[int, None, None] Generates the indices of all nodes corresponding to terminal monomers (i.e. those wiht only one outgoing bond) .. py:property:: num_chains :type: int The number of disconnected chains represented by the MonoGraph .. py:property:: chains :type: Generator[MonomerGraph, None, None] Generates all disconnected polymers chains in the graph sequentially .. py:property:: unique_monomer_names :type: set[str] The collection of unique monomer names embedded in the graph nodes .. py:method:: draw(label_monomers: bool = True, label_bonds: bool = True, **kwargs) -> None Visualize graph structure with NetworkX .. py:attribute:: visualize .. py:method:: insert_chemical_info(chemical_info: dict[str, dict]) -> None Insert SMILES, SMARTS, and atom/linker count info into nodes from minimal set of monomer info templates .. py:method:: from_smidge_string(smidge_string: str, start_node_idx: int = 0) -> MonomerGraph :classmethod: Parse a SMIDGE ("SMILES-like Monomer Interconnectivity & Degree Graph Encoding") string and read it into a networkX Graph .. py:method:: to_smidge_string(start_node_idxs: Optional[Union[int, Sequence[int]]] = None) -> str Convert a monomer graph into a SMIDGE ("SMILES-like Monomer Interconnectivity & Degree Graph Encoding") string .. py:data:: MonoGraph .. py:class:: MonomerGraphSerializer Bases: :py:obj:`polymerist.genutils.fileutils.jsonio.serialize.TypeSerializer` JSON serializer for storing MonomerGraphs as SMIDGE strings .. py:method:: encode(python_obj: MonomerGraph) -> str :staticmethod: .. py:method:: decode(json_obj: str) -> MonomerGraph :staticmethod: