Path B - Module 28: The MolSysBuilder API#

To test your enzyme, you need a substrate. While proteins are easy to find in the PDB, specific industrial polymers like PET fragments often need to be built from scratch.

In this module, you will learn to use the MolSysBuilder to create a molecule of BHET, the primary product of PET degradation.

While editing, msm.get(builder, ...) can inspect the complete chemical/topological and structural state stored by the builder. Molecular-mechanics data and per-structure chemical-state associations are added to the materialized MolSys, not stored in the builder.

Conversions among MolSys, MolSysBuilder, and MolSysDict report fidelity exhaustively. In selected exports, atom order is canonical and structure_indices retains the requested order; strict=True rejects detected reduced-schema loss.

import numpy as np
import molsysmt as msm
from molsysmt import pyunitwizard as puw

builder = msm.MolSysBuilder()

1. Building from SMILES#

The fastest way to build small industrial molecules is using their chemical string (SMILES). BHET has a specific aromatic core with two hydroxyethyl branches.

# Declare a minimal carbonyl fragment from the BHET scaffold.
carbon = builder.add_atom(atom_name='C', atom_type='C')
oxygen = builder.add_atom(atom_name='O', atom_type='O')
builder.add_group([carbon, oxygen], group_name='BHT')
builder.add_bond(carbon, oxygen, bond_order=2, bond_type='covalent')
builder.set_coordinates(puw.quantity(np.array([[0.0, 0.0, 0.0], [0.123, 0.0, 0.0]]), 'nm'))
bhet_fragment = builder.build()
msm.info(bhet_fragment)

2. Manual Atom Addition#

If you need to add specific “Probe” atoms to your industrial reactor model, you can use the add_atom method of the builder.

ion_builder = msm.MolSysBuilder()
magnesium = ion_builder.add_atom(atom_name='MG', atom_type='Mg')
ion_builder.add_group([magnesium], group_name='MG', group_type='ion')
ion_builder.set_coordinates(puw.quantity(np.array([[1.0, 1.0, 1.0]]), 'nm'))
magnesium_probe = ion_builder.build()
print(f"Probe contains {msm.get(magnesium_probe, element='system', n_atoms=True)} atom.")

🏆 Path B Challenge: The Polymer Chemist#

  1. Use the builder to create an empty system.

  2. Add two Carbon atoms at coordinates [0,0,0] and [0,0,0.15] nm.

  3. Add a chemical bond between them (indices 0 and 1) using builder.add_bond().

  4. Verify that the system has 1 bond and 2 atoms using msm.info().

You can now build any molecular component! In Module 29, we will finish this phase by resolving structural ambiguities in experimental PETase crystals.