polymerist.polymers.monographs

Tools for generating and manipulating monomer connectivity graphs

Attributes

MonoGraph

Classes

MonomerGraph

A graph representation of the connectivity of monomer fragments in a polymer topology

MonomerGraphSerializer

JSON serializer for storing MonomerGraphs as SMIDGE strings

Module Contents

class polymerist.polymers.monographs.MonomerGraph(incoming_graph_data=None, **attr)[source]

Bases: networkx.Graph

A graph representation of the connectivity of monomer fragments in a polymer topology

MONOMER_NAME_ATTR: ClassVar[str] = 'monomer_name'
FLAVOR_DICT_ATTR: ClassVar[dict[int, int]] = 'neighbor_flavors'
BONDTYPE_ATTR: ClassVar[str] = 'bondtype'
get_monomer_name_at_node_index(node_idx: int) str | None[source]

Recover the assigned monomer name for the node at the given index

get_flavor_dict_at_node_index(node_idx: int) dict[int, int] | None[source]

Recover the assigned dictionary of neighbor flavors for the node at the given index

property num_monomers: int

Number of monomer units represented in the current polymer

property is_unbranched: bool

Whether the monomer graph represents straight chain(s) without branching

is_linear
property terminal_monomers: Generator[int, None, None]

Generates the indices of all nodes corresponding to terminal monomers (i.e. those wiht only one outgoing bond)

property num_chains: int

The number of disconnected chains represented by the MonoGraph

property chains: Generator[MonomerGraph, None, None]

Generates all disconnected polymers chains in the graph sequentially

property unique_monomer_names: set[str]

The collection of unique monomer names embedded in the graph nodes

draw(label_monomers: bool = True, label_bonds: bool = True, **kwargs) None[source]

Visualize graph structure with NetworkX

visualize
insert_chemical_info(chemical_info: dict[str, dict]) None[source]

Insert SMILES, SMARTS, and atom/linker count info into nodes from minimal set of monomer info templates

classmethod from_smidge_string(smidge_string: str, start_node_idx: int = 0) MonomerGraph[source]

Parse a SMIDGE (“SMILES-like Monomer Interconnectivity & Degree Graph Encoding”) string and read it into a networkX Graph

to_smidge_string(start_node_idxs: int | Sequence[int] | None = None) str[source]

Convert a monomer graph into a SMIDGE (“SMILES-like Monomer Interconnectivity & Degree Graph Encoding”) string

polymerist.polymers.monographs.MonoGraph
class polymerist.polymers.monographs.MonomerGraphSerializer[source]

Bases: polymerist.genutils.fileutils.jsonio.serialize.TypeSerializer

JSON serializer for storing MonomerGraphs as SMIDGE strings

static encode(python_obj: MonomerGraph) str[source]
static decode(json_obj: str) MonomerGraph[source]