<jupyter_start><jupyter_text>**Note**: The content below demonstrates usage of `nglview` with `openforcefield`. This can be tricky to get working. Install with:    conda install -c conda-forge nglview    And configure for use with Jupyter with:    jupyter-nbextension enable nglview --py --sys-prefix    To use with Jupyterlab, configure with:    jupyter labextension install  nglview-js-widgets    jupyter-labextension install @jupyter-widgets/jupyterlab-manager  Built-in visualizations in `openforcefield`PR [560](https://github.com/openforcefield/openforcefield/pull/560) introduced rich representation for the `Molecule` objects. This means you can visualize them in your Jupyter Notebooks.We have implemented three backends:- rdkit- openeye- nglview (requires conformers)There are two ways to invoke the visualization:- implicitly, by _evaluating_ the object in a cell- explicitly, by calling `Molecule.visualize()` _Implicit_ visualization will try to use `nglview` if there are conformers and fall back to `rdkit` and `openeye` (in that order) if they are not available.<jupyter_code>m = Molecule.from_smiles("CCCCOCC")
m<jupyter_output><empty_output><jupyter_text>The regular `display()` call works on `Molecule` objects too.<jupyter_code>display(m)<jupyter_output><empty_output><jupyter_text>_Explicit_ visualization works as one would expect:<jupyter_code>m.visualize()<jupyter_output><empty_output><jupyter_text>This method can take a `backend` parameter, which defaults to `rdkit`:<jupyter_code>m.visualize(backend="rdkit")<jupyter_output><empty_output><jupyter_text>`openeye` can also be used, if available:<jupyter_code>try:
    import openeye
    m.visualize(backend="openeye")
except ImportError:
    print("Visualizing with `backend=\"openeye\"` requires the OpenEye Toolkits")<jupyter_output><empty_output><jupyter_text>`nglview`, if installed, can only be used if conformers have been generated:<jupyter_code># NBVAL_SKIP
try:
    m.visualize(backend="nglview")  # this will fail because we have no conformers yet
except ValueError as excinfo:
    # Catch the exception and print its message
    print(str(excinfo))<jupyter_output>Visualizing with NGLview requires that the molecule has conformers.<jupyter_text>But, once you generate them, it works! You can zoom in/out, rotate and translate the molecule. You can even inspect the different conformers (if available) using the trajectory player:<jupyter_code># NBVAL_SKIP
m.generate_conformers()
m.visualize(backend="nglview")<jupyter_output><empty_output><jupyter_text>For example, a benzene ring will not have multiple conformers, so you won't see the trajectory player.<jupyter_code># NBVAL_SKIP
n = Molecule.from_smiles("c1ccccc1")
n.generate_conformers()
n<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0890658942795076, 'fraction_numerical': 0.002896451846488052, 'mean_word_length': 6.632596685082873, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '282791', 'license': 'MIT', 'n_tokens_mistral': 907, 'n_tokens_neox': 859, 'n_words': 264, 'path': 'examples/visualization/visualization.ipynb', 'repo_name': 'ijpulidos/openff-toolkit', 'size': '2762'}