Skip to content

MolSSI/mmic_parmed

GitHub Actions Build Status codecov Language grade: Python

ParmEd translator for MMSchema

This is part of the MolSSI Molecular Mechanics Interoperable Components (MMIC) project. This package provides translators between MMSchema and ParmEd.

image

mmic_parmed provides 4 classes of translators for: molecules, forcefields, trajectories (incomplete), and simulation (incomplete).

Models

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

Components

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

MMSchema to ParmEd 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

ParmEd to MMSchema molecule

# 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

Copyright (c) 2021, MolSSI

Acknowledgements

Project based on the Computational Molecular Science Python Cookiecutter version 1.5.