This is part of the MolSSI Molecular Mechanics Interoperable Components (MMIC) project. This package provides translators between MMSchema and MDAnalysis.
mmic_mda provides 3 classes of translators for: molecules, trajectories, and forcefields.
# Import models for MDAnalysis
from mmic_mda.models import MdaMol, MdaFF, MdaTraj
# Create mda objects from MMSchema models
mda_mol = MdaMol.from_schema(mm_mol)
mda_ff = MdaFF.from_schema(mm_ff)
mda_traj = MdaTraj.from_schema(mm_traj)
# Convert mda objects to MMSchema models
mm_mol = mda_mol.to_schema()
mm_ff = mda_ff.to_schema()
mm_traj = mda_traj.to_schema()
Converting from MDAnalysis.Universe
to MMElemental.models.Molecule
is achieved with MdaToMolComponent
:
# Create input for converting Mda to MMSchema molecule
trans_in = {
"data_object": MDAnalysis.Universe,
"data_units": mmic_mda.units
}
# Run conversion
trans_out = MdaToMolComponent.compute(trans_in)
mm_mol = trans_out.schema_object -> MMElemental.models.Molecule
Converting from MMElemental.models.Molecule
to MDAnalysis.Universe
is achieved with MolToMdaComponent
:
# Create input for converting MMSchema to Mda molecule
trans_in = {
"schema_object": MDAnalysis.Universe,
"engine_version": '>=1.0.0' # reject conversion for MDAv < 1.0.0
)
# Run conversion
trans_out = MolToMdaComponent.compute(trans_in)
mda_uni = trans_out.data_object -> MDAnalysis.Universe
Copyright (c) 2021, MolSSI
Project based on the Computational Molecular Science Python Cookiecutter version 1.5.