trident_chemwidgets.widgets package - Trident Chemwidgets - Docs v0.1

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

# trident_chemwidgets.widgets package

## Submodules

## trident_chemwidgets.widgets.histogram module

class trident_chemwidgets.widgets.histogram.Histogram(**kwargs: Any)

  Bases: `DOMWidget`

  Plot an interactive histogram based on the distribution of the given data and the selected variable.

  The histogram will be displayed to the left of the cell output, with a molecule gallery displayed to the right. The molecule gallery can show the structures present in the currently-selected subset of the data.

  Parameters

    - data (pd.DataFrame) – DataFrame used to generate the histogram.

    - smiles (str) – Name of the column that contains the SMILES string of each molecule.

    - x (str) – Name of the column used to generate the x-axis of the histogram.

    - x_label (str) – Label for the x-axis of the histogram, defaults to the value of x if not provided.

    - x_date_format (str) – Date format string to display datetime values on the x axis.

  Notes

  Valid date format strings for the x_date_format arguments can be found here: https://github.com/d3/d3-time-format#locale_format. For example, a common date format string might be ‘%Y-%m-%d’ to display the 4-digit year, 2-digit month, and 2-digit day (i.e. 2021-12-25).

  Examples

      >>> import trident_chemwidgets as tcw
      >>> import pandas as pd
      >>> dataset = pd.read_csv(PATH)
      >>> histogram = tcw.Histogram(data=dataset, smiles='smiles', x='tpsa')
      >>> histogram

  data

    An instance of a Python dict.

    One or more traits can be passed to the constructor to validate the keys and/or values of the dict. If you need more detailed validation, you may use a custom validator method.

    Changed in version 5.0: Added key_trait for validating dict keys.

    Changed in version 5.0: Deprecated ambiguous `trait`, `traits` args in favor of `value_trait`, `per_key_traits`.

  prep_data_for_plot()

    Transforms and correctly selects the data that will be transformed into dict and will be used by React to generate the histogram.

    Returns

      data in dictionary format.

    Return type

      dict

  savedSelected

    An instance of a Python list.

  property selection

    Current selection of molecules made by the user.

  x_format_date_string

    A trait for unicode strings.

  x_is_date

    A boolean (True, False) trait.

  x_label

    A trait for unicode strings.

## trident_chemwidgets.widgets.interactive_molecule module

class trident_chemwidgets.widgets.interactive_molecule.InteractiveMolecule(**kwargs: Any)

  Bases: `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

  data

    An instance of a Python list.

  prepare_data(data: DataFrame) → List

    Transforms a dataset from the dataframe format to a list of dictionaries that will be interpreted by React.

    Parameters

      data (pd.DataFrame) – Dataframe that will be transformed.

    Returns

      List of data transformed to the correct format.

    Return type

      List

  smiles

    A trait for unicode strings.

## trident_chemwidgets.widgets.jsme module

class trident_chemwidgets.widgets.jsme.JSME(**kwargs: Any)

  Bases: `DOMWidget`

  Display the JSME editor and sync drawn molecule SMILES strings to Python.

  The JSME interface will be displayed to the left of the cell output, with a molecule gallery displayed to the right. The molecule gallery can show the structures designed and input by the user.

  Parameters

    base_smiles (str) – Base smiles used to generate an initial molecule in the JSME input window.

  Examples

      >>> import trident_chemwidgets as tcw
      >>> jsme = tcw.JSME()
      >>> jsme

  A depiction of the structure, and all others that have been added to the saved internal molecule list will be displayed in the gallery to the right. You can access the list of input smiles using the smiles property of the widget.

      >>> jsme.smiles

  You can specify a base_smiles that will allow you to quickly generate derivatives. At any point, you can reset the input window to this predefined base smiles value by clicking the RESET TO BASE SMILES button beneath the input window.

      >>> jsme = tcw.JSME(base_smiles='CC(C)Cc1ccc(cc1)[C@@H](C)C(=O)O')
      >>> jsme

  base_smiles

    A trait for unicode strings.

  smiles

    An instance of a Python list.

## trident_chemwidgets.widgets.scatter module

class trident_chemwidgets.widgets.scatter.Scatter(**kwargs: Any)

  Bases: `DOMWidget`

  Plot an interactive scatter plot based on the given data and the selected variables to generate the axis.

  The scatter plot will be displayed to the left of the cell output, with a molecule gallery displayed to the right. The molecule gallery can show the structures present in the currently-selected subset of the data.

  Parameters

    - data (pd.DataFrame) – Data used to generate the scatter plot.

    - smiles (str) – Name of the column that contains the SMILES string of each molecule.

    - x (str) – Name of the column used to generate the x-axis of the scatter plot.

    - y (str) – Name of the column used to generate the y-axis of the scatter plot.

    - hue (str) – Name of the column used to color the points of the scatter plot.

    - x_label (str) – Label for the x-axis of the histogram, defaults to the value of x if not provided.

    - y_label (str) – Label for the y-axis of the histogram, defaults to the value of y if not provided.

    - hue_label (str) – Label for the point colors of the histogram, defaults to the value of hue if not provided.

    - x_date_format (str) – Date format string to display datetime values on the x axis.

    - y_date_format (str) – Date format string to display datetime values on the y axis.

  Notes

  Valid date format strings for the x_date_format and y_date_format arguments can be found here: https://github.com/d3/d3-time-format#locale_format. For example, a common date format string might be ‘%Y-%m-%d’ to display the 4-digit year, 2-digit month, and 2-digit day (i.e. 2021-12-25).

  Examples

      >>> import trident_chemwidgets as tcw
      >>> import pandas as pd
      >>> dataset = pd.read_csv(PATH)
      >>> scatter = tcw.Scatter(data=dataset, smiles='smiles', x='mwt', y='logp')
      >>> scatter

  data

    An instance of a Python dict.

    One or more traits can be passed to the constructor to validate the keys and/or values of the dict. If you need more detailed validation, you may use a custom validator method.

    Changed in version 5.0: Added key_trait for validating dict keys.

    Changed in version 5.0: Deprecated ambiguous `trait`, `traits` args in favor of `value_trait`, `per_key_traits`.

  hue_label

    A trait for unicode strings.

  hue_max

    A float trait.

  hue_min

    A float trait.

  hue_type

    A trait for unicode strings.

  prep_data_for_plot()

    Transforms and selects the data correctly for use by the plot.

    Returns

      Data in dict format to be used in plot.

    Return type

      dict

  savedSelected

    An instance of a Python list.

  property selection

    Current selection of molecules made by the user.

  x_format_date_string

    A trait for unicode strings.

  x_is_date

    A boolean (True, False) trait.

  x_label

    A trait for unicode strings.

  y_format_date_string

    A trait for unicode strings.

  y_is_date

    A boolean (True, False) trait.

  y_label

    A trait for unicode strings.

## Module contents