cgsmiles.graph_layout_utils module¶
- cgsmiles.graph_layout_utils.assign_angles(graph, default_angle=120)[source]¶
Assign angle values for all angles in a molecule graph. We assume they are all 120 if atoms have 2 or 3 neighbors. Otherwise, they are skipped. On top we take care that five membered rings and triangles have the correct angle sum.
- Parameters:
graph (networkx.Graph)
- Returns:
tuple with node keys corresponding to the angle and the reference angle value
- Return type:
tuple([[collections.abc.Hashable,collections.abc.Hashable,collections.abc.Hashable,int])
- cgsmiles.graph_layout_utils.assign_bonds(graph, pos, default_bond=None)[source]¶
Iterate over all edges and compute the distance between the edges defined by the pos coordinate array.
- Parameters:
graph (networkx.Graph)
pos (
numpy.ndarrayof shape ((n,2)))default_bond (float) – default bond distance
- Returns:
tuple of node keys and distance
- Return type:
tuple([collections.abc.Hashable, collections.abc.Hashable, float])
- cgsmiles.graph_layout_utils.find_triplets(graph)[source]¶
Find all triplets of nodes in the graph.
- Parameters:
graph (networkx.Graph)
- Returns:
the node keys corresponding to the triplet the central node is the common one.
- Return type:
tuple([collections.abc.Hashable,collections.abc.Hashable,collections.abc.Hashable])
- cgsmiles.graph_layout_utils.rotate_subgraph(graph, anchor, reference, target, points, angle=120)[source]¶
Given a graph of which each node is associated with a point in 2D. Take a target edge and remove it from the subgraph. Then take the first connected component and rotate this subgraph by angle degrees about the reference point given by the first node in the target edge.
- Parameters:
graph (networkx.Graph) – the graph
target (tuple(collections.abc.Hashable, collections.abc.Hashable)) – the target edge
points (dict[collections.abc.Hashable:
numpy.ndarray]) – the dict of 2D positionsangle (float) – the angle to rotate by
- Returns:
the updated positions dict
- Return type: