narupatools.frame.converter

Conversion methods for Narupa FrameData.

Module Attributes

PDB_STD_RESIDUES

Set of standard residues as defined by the PDB file format.

Functions

convert

Convert between two representations of a molecular system.

frame_data_to_dictionary

Convert a Narupa FrameData to a python dictionary.

frame_to_pdb_string

Convert a Narupa FrameData to the contents of a PDB file.

narupatools.frame.converter.convert(source: _TSource, target: Type[_TTarget], *, fields: infinite_sets.infinite_sets.InfiniteSet[str] = everything())_TTarget
narupatools.frame.converter.convert(source: _TSource, target: _TTarget, *, fields: infinite_sets.infinite_sets.InfiniteSet[str] = everything())_TTarget

Convert between two representations of a molecular system.

This converts to and from Narupa’s FrameData, using it as an intermediary to allow conversions between various packages such as ASE and MDAnalysis.

Parameters
  • source – Object which contains molecular information.

  • target – Target type to convert to.

  • fields – Fields to convert.

Raises

NoConversionDefinedError – No conversion defined between these two objects.

Returns

Object of the requested type.

narupatools.frame.converter.frame_data_to_dictionary(frame: narupa.trajectory.frame_data.FrameData, /, *, fields: infinite_sets.infinite_sets.InfiniteSet[str] = everything(), existing: Optional[Dict[str, Union[None, str, int, float, bool, narupatools.state.typing.SerializableIterable, narupatools.state.typing.SerializableMapping]]] = None)Dict[str, Union[None, str, int, float, bool, narupatools.state.typing.SerializableIterable, narupatools.state.typing.SerializableMapping]]

Convert a Narupa FrameData to a python dictionary.

Parameters
  • frame – Frame to convert to a dictionary.

  • fields – Fields to copy from the frame.

  • existing – Existing dictionary to copy into.

narupatools.frame.converter.frame_to_pdb_string(frame_data: narupa.trajectory.frame_data.FrameData)str

Convert a Narupa FrameData to the contents of a PDB file.

This is useful for interacting with processes which accept a PDB file as input.

Parameters

frame_data – FrameData to convert.

Returns

Contents of a PDB file as a string.

Classes

DictConverter()

Converter between a Narupa FrameData and a python dictionary.

FrameConverter()

Provides conversions to and from a Narupa FrameData.

Exceptions

NoConversionDefinedError(source, target)

Error raised when there is no conversion defined between two objects.