Module 6: Visualizing Anything#

Welcome back, Apprentice Master. In the preceding modules, you learned how MolSysMT unifies molecular data containers (Forms), data properties (Attributes), hierarchical levels (Elements), native objects (Native Forms), and multi-file trajectories (Combined Forms).

Now we arrive at the primary visual portal of MolSysMT: msm.view().

Molecular structural biology is inherently spatial and visual. If you cannot inspect your system 3D geometry, you are working blind. The power of MolSysMT is that msm.view() is completely form-agnostic: whether your system is a remote PDB string, a local trajectory file, a native MolSys object, or a list of multi-forms, the visualization interface remains identical.

1. Remote & Cloud Systems: msm.view('pdb_id:')#

Let’s begin by importing MolSysMT.

import molsysmt as msm
from molsysmt import systems

You can visualize any system directly from its RCSB PDB identifier using the 'pdb_id:' format string. MolSysMT automatically fetches the structure and renders it interactively in a single command:

# Visualize SARS-CoV-2 Main Protease directly from the PDB Cloud
msm.view('pdb_id:6LU7')
WARNING: Cross-chain covalent bonds were detected. (Hint: Verify whether these bonds are expected in your system. Docs: https://www.uibcdf.org/MolSysMT)
WARNING: Cross-chain covalent bonds were detected. (Hint: Verify whether these bonds are expected in your system. Docs: https://www.uibcdf.org/MolSysMT)
WARNING: Cross-chain covalent bonds were detected. (Hint: Verify whether these bonds are expected in your system. Docs: https://www.uibcdf.org/MolSysMT)
WARNING: Cross-chain covalent bonds were detected. (Hint: Verify whether these bonds are expected in your system. Docs: https://www.uibcdf.org/MolSysMT)

2. Local Files & Native Objects: msm.view(system)#

Whether your system is stored in a local PDB file, an H5MSM file, or an in-memory native molsysmt.MolSys object, msm.view() accepts any valid form directly:

# Load our demonstration T4 Lysozyme system
lysozyme = systems['T4 lysozyme L99A']['181l.bcif.gz']

# Render the local file
msm.view(lysozyme)

3. Multi-Forms & Trajectories: msm.view([topology, trajectory])#

As you learned in Module 5: Combined Forms, a molecular system can be represented by a list of complementary forms (such as a separate topology file and a trajectory file).

When you pass a trajectory or a multi-form system list to msm.view(), it automatically provides interactive animation controls and a trajectory slider to step through structures:

# Load Villin Headpiece topology and trajectory
villin_traj = systems['chicken villin HP35']['traj_chicken_villin_HP35_solvated.dcd']
villin_topo = systems['chicken villin HP35']['chicken_villin_HP35_solvated.h5msm']

# Render composite multi-form trajectory list
msm.view([villin_topo, villin_traj])

4. Selective Focus & Viewer Backends#

Complex systems with thousands of solvent molecules or ions can obscure important structural features. You can pass a selection parameter to msm.view() to focus the visual scene on specific components:

# Render only the protein component, hiding water molecules and ions
msm.view(lysozyme, selection='molecule_type=="protein"')

🏆 Challenge 6: The Scene Director#

  1. Load the Barnase-Barstar complex (systems['Barnase-Barstar']['barnase_barstar.h5msm']).

  2. Use msm.view() to render the full complex.

  3. Use msm.view() with selection='chain_id == "A"' to focus exclusively on Chain A.

  4. Rotate the 3D scene and zoom into the binding interface.

With visual inspection mastered, you now have complete clarity over system state. In Module 7: Selection Language Basics, we will master the selection language used to target specific molecular subsets.