/cmselemental

Basic models for the Computational Molecular Sciences (CMS)

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

CMSElemental

CI codecov Language grade: Python

A python package which provides data models & tools for the Computational Molecular Sciences (CMS).

Base Models

The most fundamental model is ProtoModel, a subclass of the pydantic BaseModel, which provides commonly used methods in CMS.

from cmselemental.models import ProtoModel

class Model(ProtoModel):
    ...

obj = Model(...)
is_same = obj.compare(other_obj)
stringified = obj.json()
data = obj.dict()

Serialization/deserialization

Routines for serializing to popular formats like JSON and YAML are available, with support for encoding Numpy arrays.

from cmselemental.util import serialize, deserialize

stringified = serialize(data, encodding="json", indent=4)
data = deserialize(stringified, encoding="json")