stk.Smiles

class stk.Smiles[source]

Bases: MoleculeKeyMaker

Used to get the SMILES of molecules.

Warning

SMILES strings generated with stk version v2025.07.17.0 or sooner (using rdkit version 2024.9.1 or sooner) will be different than newer versions due to a change in handling the valence of organic atoms bound to metals. Details can be found in the rdkit release notes 2025_03_1. No changes occur in stk construction. An example change in SMILES: CCCO->[Fe+2] becomes CCC[OH]->[Fe+2].

Examples

Adding SMILES to a Molecule’s JSON

You want to use the isomeric, canonical SMILES from RDKit as part of a JSON representation of a molecule

import stk

jsonizer = stk.MoleculeJsonizer(
    key_makers=(stk.Smiles(), ),
)
# Get the JSON representation, including an SMILES.
json = jsonizer.to_json(stk.BuildingBlock('NCCN'))
Parameters:
  • key_name – The name of the key.

  • get_key – Takes a single parameter, molecule, and returns the key to use for that molecule. The value passed to the parameter must be a Molecule instance.

Methods

get_key

Get the key of molecule.

get_key_name

Get the name of the key.

get_key(molecule)[source]

Get the key of molecule.

Parameters:

molecule (Molecule) – The molecule for which a key is needed.

Returns:

The key of molecule.

Return type:

str

get_key_name()[source]

Get the name of the key.

Returns:

The name of the key.

Return type:

str