cgsmiles.graph_layout module

Generate positions for 2D graphs of molecules.

cgsmiles.graph_layout.circular_layout(graph, radius, align_with=None)[source]

Generate circular layout for a molecule graph.

Parameters:
Returns:

a dict of positions

Return type:

dict

cgsmiles.graph_layout.vespr_layout(graph, default_bond=1, align_with=None)[source]

Generate VSEPR-like layout for a molecule graph.

Parameters:
  • graph (networkx.Graph) – the molecule to draw

  • default_bond (float) – the default bond length

  • align_with (numpy.ndarray) – axis to align longest axis with

Returns:

a dict of positions

Return type:

dict

cgsmiles.graph_layout.vespr_refined_layout(graph, default_bond=1, align_with=None, default_angle=120, target_energy=100000, lbfgs_options={})[source]

Generate VESPR layout but run an optimization to refine the intial positions according to a pseudo energy minization scheme.

This is method is considerably much slower than just doing the regular VESPR layout. However, it usually gives publication ready crisp molecule layouts.

Parameters:
  • graph (networkx.Graph) – the molecule to draw

  • default_bond (float) – the default bond length

  • align_with (numpy.ndarray) – axis to align longest axis with

  • default_angle (float) – the default angle in degrees

  • target_energy (float) – a target energy until which to minimize

  • lbfgs_options – keyword arguments given to LBFGS.minimize

Returns:

a dict of positions

Return type:

dict