cgsmiles.write_cgsmiles module

cgsmiles.write_cgsmiles.format_bonding(bonding)[source]

Given the list of bonding descriptors format them such that they can be added after a node/atom. This function wraps the descriptor in [ ] braces and makes sure that the bond order annotation is removed.

Parameters:

bonding (list[str]) – list of bonding descriptors

Returns:

the formatted bonding descriptor string

Return type:

str

cgsmiles.write_cgsmiles.format_node(molecule, current)[source]

Format a node from a molecule graph according to the CGsmiles syntax. The attribute fragname has to be set for the current node.

Parameters:
Returns:

the formatted string

Return type:

str

cgsmiles.write_cgsmiles.write_cgsmiles(molecule_graph, fragments, last_all_atom=True)[source]

Write a CGsmiles string given a low resolution molecule graph and any number of higher resolutions provided as fragment dicts.

Parameters:
Returns:

CGsmiles string

Return type:

str

cgsmiles.write_cgsmiles.write_cgsmiles_fragments(fragment_dict, smiles_format=True)[source]

Write fragments of molecule graph. To identify the fragments all nodes with the same fragname and fragid attributes are considered as fragment. Bonding between fragments is extracted from the bonding edge attributes.

Parameters:
  • fragment_dict (dict[str, networkx.Graph]) – a dict of fragment graphs

  • smiles_format (bool) – write all atom SMILES if True (default) otherwise write CGsmiles

Return type:

str

cgsmiles.write_cgsmiles.write_cgsmiles_graph(molecule)[source]

Write a CGsmiles graph sans fragments at different resolution.

Parameters:

molecule (networkx.Graph) – a molecule where each node as a fragname attribute that is used as name in the CGsmiles string.

Returns:

the CGsmiles string

Return type:

str

cgsmiles.write_cgsmiles.write_graph(molecule, smiles_format=False, default_element='*')[source]

Creates a CGsmiles string describing molecule. molecule should be a single connected component.

Parameters:
  • molecule (networkx.Graph) – The molecule for which a CGsmiles string should be generated.

  • smiles_format – If the nodes are written using the OpenSmiles standard format.

Returns:

The CGsmiles string describing molecule.

Return type:

str