Logging RDKit Molecular Data

Publish your model insights with interactive plots for performance metrics, predictions, and hyperparameters. Made by Anmol Mann using Weights & Biases
Anmol Mann

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)})
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)})