ggmolvis.ggmolvis

GGMolVis

GGmolVis is a high-level API for creating molecular visualizations in Blender. It is built on top of the MolecularNodes Blender add-on. It provides a simple and intuitive interface for creating complex molecular visualizations with just a few lines of code.

Classes

class ggmolvis.ggmolvis.GGMolVis[source]

Top level class that contains all the elements of the visualization. It is similar to a Figure in matplotlib. It contains all the Molecule, Shape, Text, Camera, Light, and World objects. It also contains the global settings for the visualization like subframes. It is a singleton class, so only one instance will be created in a session.

During initialization, it creates a global camera and a global world for object transformation. The global camera is set to a default position and rotation. The global world transformation is set to no positional, rotational, or scaling transformation.

The artists are stored in a dictionary with keys as the type of the artist and values as the list of artists of that type.

Properties:

molecules: list

List of all Molecule objects in the visualization

shapes: list

List of all Shape objects in the visualization

texts: list

List of all Text objects in the visualization

cameras: list

List of all Camera objects in the visualization

lights: list

List of all Light objects in the visualization

worlds: list

List of all World transformation objects in the visualization

global_world: World

The global world transformation object

global_camera: Camera

The global camera object

subframes: int

Number of subframes to render. It will be a global setting for all objects. Default is 1

distance(atom1: AtomGroup | Atom, atom2: AtomGroup | Atom, name: str = 'distance', location: ndarray | list = None, rotation: ndarray | list = None, scale: ndarray | list = None, mol_color: str = 'default', mol_material: str = 'ambient', mol_style: str = 'sphere', line_color: str = 'black', line_material: str = 'backdrop', line_style: str = 'default')[source]

Create a Distance object and add it to the visualization.

line(start_points: ndarray, end_points: ndarray, name: str = 'line', location: ndarray | list = None, rotation: ndarray | list = None, scale: ndarray | list = None, color='black', material='backdrop')[source]

Create a Line object and add it to the visualization.

Parameters:
start_points: np.ndarray

The start points of the line

end_points: np.ndarray

The end points of the line

name: str

The name of the line. Default is ‘line’

location: np.ndarray or list

The location of the line. Default is None

rotation: np.ndarray or list

The rotation of the line. Default is None

scale: np.ndarray or list

The scale of the line. Default is None

color: str

The color of the line. Default is ‘black’

material: str

The material of the line. Default is ‘backdrop’

Returns:
line: Line

The created Line object

molecule(universe: AtomGroup | Universe, style: str = 'spheres', name: str = 'atoms', location: ndarray | list = None, rotation: ndarray | list = None, scale: ndarray | list = None, color='default', material='default')[source]

Create a Molecule object and add it to the visualization.

Parameters:
universe: MDAnalysis.AtomGroup or MDAnalysis.Universe

The AtomGroup or Universe object containing the atoms

style: str

The style of the molecule. Default is ‘spheres’

name: str

The name of the molecule. Default is ‘atoms’

location: np.ndarray or list

The location of the molecule. Default is None

rotation: np.ndarray or list

The rotation of the molecule. Default is None

scale: np.ndarray or list

The scale of the molecule. Default is None

color: str

The color of the molecule. Default is ‘default’

material: str

The material of the molecule. Default is ‘default’

Returns:
molecule: Molecule

The created Molecule object

Classes

GGMolVis()

Top level class that contains all the elements of the visualization.