Environment Helper

GitHub Link to Code.

Environment detection helper for structure visualization.

This module provides utilities for detecting the execution environment, particularly for identifying Jupyter notebook contexts where certain visualization methods may not work properly.

class mdxplain.structure_visualization.helper.environment_helper.EnvironmentHelper

Helper class for detecting execution environment.

Provides methods to identify whether code is running in a Jupyter notebook, terminal, or other environment. This is useful for adapting visualization strategies.

Examples

>>> if EnvironmentHelper.is_jupyter_environment():
...     # Use Jupyter-compatible visualization
...     print("Running in Jupyter")
... else:
...     # Use standard terminal visualization
...     print("Running in terminal")
static is_jupyter_environment() bool

Detect if code is running in Jupyter notebook.

Checks for IPython kernel presence which indicates Jupyter notebook environment. Returns False for standard Python terminals and scripts.

Parameters

None

Returns

bool

True if running in Jupyter notebook, False otherwise

Examples

>>> is_jupyter = EnvironmentHelper.is_jupyter_environment()
>>> if is_jupyter:
...     print("Jupyter environment detected")
static is_pymol_available() bool

Detect if PyMOL Python module is available.

Attempts to import pymol module to check if PyMOL is installed and accessible in the current environment.

Parameters

None

Returns

bool

True if pymol can be imported, False otherwise

Examples

>>> if EnvironmentHelper.is_pymol_available():
...     print("PyMOL is available")
... else:
...     print("PyMOL not found")