Diagram API

Introduction

The ccdc.diagram module has functionality for generating 2D diagrams.

The main class of the ccdc.diagram module is ccdc.diagram.DiagramGenerator.

>>> from ccdc.io import EntryReader
>>> from ccdc.diagram import DiagramGenerator
>>> entry_reader = EntryReader('CSD')
>>> mol = entry_reader.molecule('ABEBUF')
>>> diagram_generator = DiagramGenerator()
>>> img = diagram_generator.image(mol)  # img is a PIL image

API

class ccdc.diagram.DiagramGenerator(settings=None)[source]

Diagram generator.

class Settings(_settings=None)[source]

Settings base class for diagram generation.

background_color

The foreground color.

detect_intra_hbonds = False

Whether to detect intra-molecular hbonds.

element_coloring

Color atomic labels.

explicit_polar_hydrogens = False

Whether to use explicit polar hydrogens.

font_family

The name of the font family.

font_italic

Whether the font is italic or not.

font_size

The image font size.

font_weight

The weight of the font.

foreground_color

The foreground color.

highlight_color

Color used for highlighting atoms and bonds.

image_height

The image height.

image_width

The image width.

line_width

The image line width.

overwrite_existing_image = False

Whether to override the existing image of an entry.

return_type

The image method return type.

shrink_symbols = True

Whether to replace particular substructures with functional group labels.

image(argument, highlight_atoms=None, label_atoms=None)[source]

Return an image or list of images according to arguments.

Parameters:
Returns:

a PIL image, or a list of PIL images. It may return None if the diagram generation failed.