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

tuple of node keys and distance

Return type:

tuple([collections.abc.Hashable, collections.abc.Hashable, float])

cgsmiles.graph_layout_utils.assing_dihedral_angles(graph)[source]
cgsmiles.graph_layout_utils.check_and_fix_cis_trans(graph, points)[source]
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:
Returns:

the updated positions dict

Return type:

dict