m = Molecule.from_smiles("CCCCOCC")
m

"""
Explanation: 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 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.
End of explanation
"""


display(m)

"""
Explanation: The regular display() call works on Molecule objects too.
End of explanation
"""


m.visualize()

"""
Explanation: Explicit visualization works as one would expect:
End of explanation
"""


m.visualize(backend="rdkit")

"""
Explanation: This method can take a backend parameter, which defaults to rdkit:
End of explanation
"""


try:
    import openeye
    m.visualize(backend="openeye")
except ImportError:
    print("Visualizing with `backend=\"openeye\"` requires the OpenEye Toolkits")

"""
Explanation: openeye can also be used, if available:
End of explanation
"""


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

"""
Explanation: nglview, if installed, can only be used if conformers have been generated:
End of explanation
"""


m.generate_conformers()
m.visualize(backend="nglview")

"""
Explanation: 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:
End of explanation
"""


n = Molecule.from_smiles("c1ccccc1")
n.generate_conformers()
n

"""
Explanation: For example, a benzene ring will not have multiple conformers, so you won't see the trajectory player.
End of explanation
"""


