Skip to main content

Logging RDKit Molecular Data

Created on December 2|Last edited on December 3

Open In Colab


RDKit is a popular open source toolkit for cheminformatics. W&B added support for rdkit data formats. You can now initialize wandb.Molecule from SMILES strings, rdkit.Chem.rdchem.Mol objects, and files in rdkit-supported formats, such as .mol.
This report showcases how you can log rdkit molecular data in Weights & Biases and visualize it both in 3D and 2D.

Molecules

Here's how you can log a log a 2D view of a molecule using wandb.Image data type and rdkit:
molecule = rdkit.Chem.MolFromSmiles("CC(=O)O")
rdkit.Chem.AllChem.Compute2DCoords(molecule)
rdkit.Chem.AllChem.GenerateDepictionMatching2DStructure(molecule, molecule)
pil_image = rdkit.Chem.Draw.MolToImage(molecule, size=(width, height))

wandb.log({"acetic_acid": wandb.Image(pil_image)})

Run set
1

Here are a few ways you can log a 3D representation for a molecule:
wandb.log({"protein": wandb.Molecule("6lu7.pdb")}
# from a .mol file:
wandb.log({"protein": wandb.Molecule.from_rdkit("resveratrol.mol")})
# from a SMILES string:
wandb.log({"protein": wandb.Molecule.from_smiles(smiles["ciprofloxacin"])})
# from an rdkit.Chem.rdchem.Mol object:
wandb.log({"molecule": wandb.Molecule.from_rdkit(acetic_acid)})

Run set
1