InteractiveMolecule - Trident Chemwidgets - Docs v0.1

Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# InteractiveMolecule

class trident_chemwidgets.InteractiveMolecule(**kwargs)

  Bases: `ipywidgets.widgets.domwidget.DOMWidget`

  Plot an interactive molecule where the user can view properties associated with each constituent atom.

  A drawing of the target molecule will be displayed to the left of the cell output, with a card displayed on the right. The user can click any atom in the structure and the details associated with that atom will be displayed in the card to the right.

  Parameters

    - smiles (str) – Smiles string used to generate the atom view.

    - data (Union[List[Dict[str, Any]], pd.DataFrame]) – List of dicts or dataframe containing the data for each atom.

  Examples

      >>> import trident_chemwidgets as tcw
      >>> atom_data = ... # Atom data in a list of dicts or pd.DataFrame
      >>> imol = tcw.InteractiveMolecule('CCCCC', data=atom_data)
      >>> imol # Plot the actual widget on the notebook/lab

## Input data structure

The input for this widget can either be a list of dictionaries, with each dictionary containing the features of the atoms, or it can be a Pandas DataFrame. In either case, the ordering of the dictionaries in the list or the rows in the dataframe must match the standard ordering used by RDKit.

If you are using a standard RDKit-based featurizer, as is common in many ML for chemistry packages (e.g. DeepChem), this ordering should be the default. We cannot guarantee ordering for all featurizers/applications, so it is always a good idea to double check your atom ordering against that generated with the `GetAtoms` function in RDKit.

## Interaction features

### Atom information

Click within the circle surrounding each atom in the structure to display the data associated with that atom.

## Example

See Using the InteractiveMolecule widget.