Adapter¶
The adapter module handles conversion to and from other chemistry toolkits (e.g. RDKit).
Base¶
Base Adapter class for MolPy.
This module provides the abstract base class for adapters that maintain bidirectional synchronization between MolPy's internal data structures and external representations.
Adapters do NOT execute external tools or spawn subprocesses.
Adapter ¶
Adapter(internal=None, external=None)
Bases: ABC, Generic[InternalT, ExternalT]
Abstract base class for representation adapters.
Adapters maintain bidirectional synchronization between MolPy's internal data structures (e.g., Atomistic, Frame) and external representations.
Adapters MUST NOT execute external tools or spawn subprocesses.
Source code in src/molpy/adapter/base.py
28 29 30 31 32 33 34 | |
check ¶
check()
Validate the adapter has enough state to do useful work.
This is intentionally lightweight and side-effect free. Concrete adapters may override with stronger validation.
Source code in src/molpy/adapter/base.py
125 126 127 128 129 130 131 132 133 134 135 136 | |
sync_to_external ¶
sync_to_external()
Sync from internal to external representation.
Subclasses should override _do_sync_to_external() to implement the actual synchronization logic.
Source code in src/molpy/adapter/base.py
92 93 94 95 96 97 98 99 100 101 102 103 | |
sync_to_internal ¶
sync_to_internal()
Sync from external to internal representation.
Subclasses should override _do_sync_to_internal() to implement the actual synchronization logic.
Source code in src/molpy/adapter/base.py
70 71 72 73 74 75 76 77 78 79 80 81 | |
RDKit¶
RDKit adapter for MolPy.
This module provides bidirectional synchronization between MolPy's Atomistic structures and RDKit's Chem.Mol objects.
RDKit is an optional dependency.
RDKitAdapter ¶
RDKitAdapter(internal=None, external=None)
Bases: Adapter[Atomistic, Mol]
Bridge between MolPy's atomistic representation and rdkit.Chem.Mol.
Source code in src/molpy/adapter/rdkit.py
129 130 131 132 133 134 135 136 137 138 | |
sync_to_internal ¶
sync_to_internal(update_topology=True)
Sync from external to internal representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update_topology
|
bool
|
Whether to update topology when internal already exists. |
True
|
Source code in src/molpy/adapter/rdkit.py
568 569 570 571 572 573 574 575 576 577 578 579 | |
Utils¶
ensure_parent_dir ¶
ensure_parent_dir(path)
Ensure the parent directory for path exists.
Source code in src/molpy/io/utils.py
41 42 43 44 | |