This is part of the MolSSI Molecular Mechanics Interoperable Components (MMIC) project. This package provides translators between MMSchema and ParmEd.
mmic_parmed provides 4 classes of translators for: molecules, forcefields, trajectories (incomplete), and simulation (incomplete).
from mmic_parmed.models import ParmedMol
# Convert MMSchema to ParmEd molecule
pa_mol = ParmedMol.from_schema(mm_mol) -> parmed.structure.Structure
# Convert ParmEd to MMSchema molecule
mm_mol = ParmedMol.to_schema(pa_mol) -> mmelemental.models.molecule.Molecule
The from_schema
and to_schema
methods in the ParmedMol
model use translation components provided by mmic_parmed and MMElemental to convert between MMSchema and ParmEd.
from mmic_parmed.components import ParmedToMolComponent, MolToParmedComponent
from mmic_parmed.models.import ParmedMol
from mmelemental.models.molecule import Molecule
# Create MMSchema molecule
mm_mol = Molecule.from_file(path_to_file)
# Create translation input
inp = {
"schema_object": mm_mol,
"schema_version": 1,
}
# Run translator compute
outp = MolToParmedComponent.compute(inp)
# Extract parmed structure
pa_mol = outp.data_object.data
# Create ParmEd input
pa_struct = parmed.load_file(path_to_file)
pa_mol = mmic_parmed.models.ParmedMol(mol=pa_struct)
# Create translation input
inp = {
"data_object": pa_mol
}
# Running translator compute
outp = Translator.compute(inp)
# Extract MMSchema molecule
mm_mol = outp.schema_object
Copyright (c) 2021, MolSSI
Project based on the Computational Molecular Science Python Cookiecutter version 1.5.