cgsmiles.drawing_utils module

cgsmiles.drawing_utils.angle_between(v1, v2)[source]
cgsmiles.drawing_utils.angle_of_interest(v1, v2)[source]
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:
Returns:

list of list of starting and end points for the edge

Return type:

list(list([float, float]))

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.ndarray of shape ((2, len(graph)))) – 2D positions for the nodes

  • spacing (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:

list, list, dict

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:
Returns:

dict of edges belonging to a particular fragid

Return type:

dict[list]

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 positions

  • cgmapping (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

cgsmiles.drawing_utils.rotate_2D(x, y, theta)[source]
cgsmiles.drawing_utils.rotation_from_x_axis(v)[source]