mofbuilder.visualization.Viewer#

class mofbuilder.visualization.Viewer(comm=None, ostream=None, filepath=None)[source]#

Bases: object

Visualization interface using py3Dmol for MOFbuilder.

Parameters:
  • comm (Any | None)

  • ostream (Any | None)

  • filepath (str | None)

comm#

MPI communicator (usually MPI.COMM_WORLD).

Type:

Any

rank#

The MPI rank of this process.

Type:

int

nodes#

The total number of MPI ranks/nodes.

Type:

int

ostream#

VeloxChem-style output stream for logging/info.

Type:

OutputStream

eG_dict#

Dictionary mapping index to name (graph elements).

Type:

Optional[Dict[Any, Any]]

merged_lines#

Data lines to be visualized; formatted input for XYZWriter.

Type:

Optional[Any]

eG_name_idx_dict#

Reverse-lookup of eG_dict, mapping names to indices.

Type:

Optional[Dict[Any, int]]

__init__()[source]#

Initialize the Viewer with MPI context and output stream.

_reverse_eG_dict()[source]#

Reverse the element graph dictionary for label lookup.

lines_show()[source]#

Visualize merged_lines as a 3D molecular scene with labels.

Parameters:
  • w (int)

  • h (int)

  • res_indices (bool)

  • res_name (bool)

Return type:

None

lines_show(w=800, h=600, res_indices=True, res_name=True)[source]#

Display merged_lines in a 3D viewer with optional residue names and indices.

Parameters:
  • w (int) – Width of viewer in pixels.

  • h (int) – Height of viewer in pixels.

  • res_indices (bool) – If True, show residue indices as labels.

  • res_name (bool) – If True, show residue names as labels.

Raises:

ImportError – If py3Dmol is not installed.

Return type:

None

Note

  • Requires py3Dmol for visualization.

  • Uses self.merged_lines, typically a list of atom-info lines output from the builder.

  • Residue labels skip any lines with resname “TNO”.

  • If both res_name and res_indices are True, the label concatenates both.