.. _SdfFormat:

sdf format
==========

Aliases
-------

``sdf``, ``sdf_file``

Implementation: :class:`SdfFormat <dpdata.plugins.rdkit.SdfFormat>`

Overview
--------


Structure-data file (SDF) containing one or more conformers.

`RDKit <https://www.rdkit.org/>`_ provides cheminformatics capabilities
for SDF reading and writing.

All records must describe the same molecular topology so they can be
represented as conformers of one :class:`dpdata.BondOrderSystem`. Reading
and writing requires RDKit.
















Quick examples
--------------

The examples use the preferred alias ``sdf``; any alias listed above is equivalent.

.. code-block:: python

   import dpdata
   
   # Molecular graph and conformers
   bond_order_system = dpdata.BondOrderSystem("input_file", fmt="sdf")
   
   # Write molecular graph data
   bond_order_system.to("sdf", "output_path")

Conversions
-----------

.. _SdfFormat_from_bond_order_system:

Convert from this format to BondOrderSystem
```````````````````````````````````````````

.. py:function:: dpdata.BondOrderSystem(file_name, fmt: Literal['sdf'] = None, **kwargs) -> dpdata.bond_order_system.BondOrderSystem
   :noindex:
.. py:function:: dpdata.BondOrderSystem(file_name, fmt: Literal['sdf_file'] = None, **kwargs) -> dpdata.bond_order_system.BondOrderSystem
   :noindex:
.. py:function:: dpdata.BondOrderSystem.from_sdf(file_name, **kwargs) -> dpdata.bond_order_system.BondOrderSystem
   :noindex:
.. py:function:: dpdata.BondOrderSystem.from_sdf_file(file_name, **kwargs) -> dpdata.bond_order_system.BondOrderSystem
   :noindex:

   
Load same-topology SDF records as one RDKit molecule.


:Parameters:

    **file_name** : str or os.PathLike
        Input ``.sdf`` file. All records must share a topology.

    **\*\*kwargs** : dict
        Additional format arguments accepted for API compatibility.



:Returns:

    BondOrderSystem
        converted system















.. _SdfFormat_to_bond_order_system:

Convert from BondOrderSystem to this format
```````````````````````````````````````````

.. py:function:: dpdata.BondOrderSystem.to(fmt: Literal['sdf'], file_name, frame_idx=-1, **kwargs)
   :noindex:
.. py:function:: dpdata.BondOrderSystem.to(fmt: Literal['sdf_file'], file_name, frame_idx=-1, **kwargs)
   :noindex:
.. py:function:: dpdata.BondOrderSystem.to_sdf(file_name, frame_idx=-1, **kwargs)
   :noindex:
.. py:function:: dpdata.BondOrderSystem.to_sdf_file(file_name, frame_idx=-1, **kwargs)
   :noindex:

   
Write conformers to an SDF file.


:Parameters:

    **file_name** : str or os.PathLike
        Destination ``.sdf`` file.

    **frame_idx** : int, default=-1
        Conformer to write. ``-1`` writes every conformer as a separate
        SDF record.

    **\*\*kwargs** : dict
        Additional format arguments accepted for API compatibility.
















