%load_ext autoreload
%autoreload 2
import molsysmt as msm

Get lengths and angles from box#

molsys = msm.convert(msm.systems['Met-enkephalin']['met_enkephalin.h5msm'])
molsys_cub = msm.build.solvate(molsys, box_shape='cubic', clearance='14.0 angstroms', engine='PDBFixer')
molsys_oct = msm.build.solvate(molsys, box_shape='truncated octahedral',  clearance='14.0 angstroms', engine='PDBFixer')
molsys_dod = msm.build.solvate(molsys, box_shape='rhombic dodecahedral', clearance='14.0 angstroms', engine='PDBFixer')
box = msm.get(molsys_cub, element='system', box=True)
msm.pbc.get_lengths_and_angles_from_box(box)
(<Quantity([[3.1236 3.1236 3.1236]], 'nanometer')>,
 <Quantity([[1.570796 1.570796 1.570796]], 'radian')>)
box = msm.get(molsys_oct, element='system', box=True)
msm.pbc.get_lengths_and_angles_from_box(box)
(<Quantity([[3.1236 3.1236 3.1236]], 'nanometer')>,
 <Quantity([[1.230959 1.910633 1.230959]], 'radian')>)
box = msm.get(molsys_dod, element='system', box=True)
msm.pbc.get_lengths_and_angles_from_box(box)
(<Quantity([[3.1236 3.1236 3.1236]], 'nanometer')>,
 <Quantity([[1.047198 1.047198 1.570796]], 'radian')>)
molsys_cub = msm.build.solvate(molsys, box_shape='cubic', clearance='14.0 angstroms')
molsys_oct = msm.build.solvate(molsys, box_shape='truncated octahedral',  clearance='14.0 angstroms')
molsys_dod = msm.build.solvate(molsys, box_shape='rhombic dodecahedral', clearance='14.0 angstroms')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[8], line 1
----> 1 molsys_cub = msm.build.solvate(molsys, box_shape='cubic', clearance='14.0 angstroms')
      2 molsys_oct = msm.build.solvate(molsys, box_shape='truncated octahedral',  clearance='14.0 angstroms')
      3 molsys_dod = msm.build.solvate(molsys, box_shape='rhombic dodecahedral', clearance='14.0 angstroms')

File ~/repos@uibcdf/molsysmt/molsysmt/_private/digestion/digest.py:122, in digest.<locals>.digestor.<locals>.wrapper(*args, **kwargs)
    120     return func(all_args['self'], **final_args)
    121 else:
--> 122     return func(**final_args)

File ~/repos@uibcdf/molsysmt/molsysmt/build/solvate.py:115, in solvate(molecular_system, box_shape, clearance, anion, n_anions, cation, n_cations, ionic_strength, water_model, engine, to_form, verbose)
    110     modeller.addSolvent(openmm_forcefield, model=solvent_model, boxVectors = box_vectors, ionicStrength=ionic_strength,
    111                         positiveIon=cation, negativeIon=anion)
    113 else:
--> 115    modeller.addSolvent(openmm_forcefield, model=solvent_model, padding=clearance,
    116                        ionicStrength=ionic_strength, positiveIon=cation,
    117                        negativeIon=anion)
    119 # fixing a bug of OpenMM
    120 list_atoms = list(modeller.topology.atoms())

File ~/Myopt/miniconda3/envs/molsysmt@uibcdf_3.12/lib/python3.12/site-packages/openmm/app/modeller.py:521, in Modeller.addSolvent(self, forcefield, model, boxSize, boxVectors, padding, numAdded, boxShape, positiveIon, negativeIon, ionicStrength, neutralize, residueTemplates)
    517         raise ValueError('Neither the box size, box vectors, nor padding was specified, and the Topology does not define unit cell dimensions')
    519 # Have the ForceField build a System for the solute from which we can determine van der Waals radii.
--> 521 system = forcefield.createSystem(self.topology, residueTemplates=residueTemplates)
    522 nonbonded = None
    523 for i in range(system.getNumForces()):

File ~/Myopt/miniconda3/envs/molsysmt@uibcdf_3.12/lib/python3.12/site-packages/openmm/app/forcefield.py:1266, in ForceField.createSystem(self, topology, nonbondedMethod, nonbondedCutoff, constraints, rigidWater, removeCMMotion, hydrogenMass, residueTemplates, ignoreExternalBonds, switchDistance, flexibleConstraints, drudeMass, **args)
   1262 rigidResidue = [False]*topology.getNumResidues()
   1264 # Find the template matching each residue and assign atom types.
-> 1266 templateForResidue = self._matchAllResiduesToTemplates(data, topology, residueTemplates, ignoreExternalBonds)
   1267 for res in topology.residues():
   1268     if res.name == 'HOH':
   1269         # Determine whether this should be a rigid water.

File ~/Myopt/miniconda3/envs/molsysmt@uibcdf_3.12/lib/python3.12/site-packages/openmm/app/forcefield.py:1486, in ForceField._matchAllResiduesToTemplates(self, data, topology, residueTemplates, ignoreExternalBonds, ignoreExtraParticles, recordParameters)
   1484                 break
   1485 if matches is None:
-> 1486     raise ValueError('No template found for residue %d (%s).  %s  For more information, see https://github.com/openmm/openmm/wiki/Frequently-Asked-Questions#template' % (res.index, res.name, _findMatchErrors(self, res)))
   1487 else:
   1488     if recordParameters:

ValueError: No template found for residue 0 (TYR).  The atoms and bonds in the residue match TYR, but the set of externally bonded atoms is missing 1 N atom.  Is the chain missing a terminal capping group?  For more information, see https://github.com/openmm/openmm/wiki/Frequently-Asked-Questions#template