cgsmiles.drawing_utils module¶
- cgsmiles.drawing_utils.make_edge(p0, p1, bond_order, spacing=0.1, sep=0.0)[source]¶
Given two positions p0 and p1 as well as a bond_order generate a horizontal line or a double / triple line depending on the bond order.
- Parameters:
p0 (
numpy.ndarrayof shape 2)p1 (
numpy.ndarrayof shape 2)bond_order (int)
spacing (float)
sep (float)
- Returns:
list of list of starting and end points for the edge
- Return type:
- cgsmiles.drawing_utils.make_graph_edges(graph, pos, spacing=0.1, sep=0.2)[source]¶
Given a molecule graph generate starting and stop points for the edges taking into account the bond orders.
- Parameters:
graph (networkx.Graph) – Graph with bond oder attribute
pos (
numpy.ndarrayof shape ((2, len(graph)))) – 2D positions for the nodesspacing (float) – distance between pos and start of edge (default: 0.1)
sep (float) – separation for bond orders higher than 1 (default: 0.2)
- Returns:
list of normal edges, aromatic edgs, and a dict of all simple edges
- Return type:
- cgsmiles.drawing_utils.make_mapped_edges(graph, plain_edges)[source]¶
Mapped edges are all those edges between atoms that belong to the same fragment (i.e. where both nodes have the same fragid attribute).
- Parameters:
graph (networkx.Graph) – graph of the molecule with ‘fragid’ attribute
plain_edges (dict[frozenset([collections.abc.Hashable])]) – dict of edge coordinates indexed by node keys
- Returns:
dict of edges belonging to a particular fragid
- Return type:
- cgsmiles.drawing_utils.make_node_pies(graph, pos, cgmapping, colors, outline=False, radius=0.2, linewidth=0.2, use_weights=False)[source]¶
Generate the slices for the matplotlip pies used to draw nodes.
- Parameters:
graph (networkx.Graph) – graph of the molecule
pos (dict[
numpy.ndarray]) – dict of 2D node positionscgmapping (bool) – if the drawing includes a cgmapping; uses the fragid attribute for colors otherwise node keys are used
colors (dict) – dict of colors
radius (float) – radius fo the pie
outline (bool) – draw an outline for regular nodes
linewidth (float) – outline width of the pie
use_weights (bool) – use the weight attribute when drawing node pies
- Yields:
numpy.ndarray, dict – array slices and keyword arguments to be given to mpl.Pie class