.. _spruce_examples_make_apo_design_units:

Creating apo OEDesignUnits from a PDB file
==========================================

Preparation of a biological structure file (PDB, mmCIF) to a fully charged,
hydrogenated, molecular componentized object (design unit; DU; :ref:`OEDesignUnit <OEBio_OEDesignUnit>`)
is one of the more advanced functionalities offered through **Spruce TK**.
This example shows how to construct apo DUs using an input PDB file and the
:oe:func:`OESpruce::OEMakeDesignUnits` function.


Command Line Interface
----------------------

This example uses an input PDB file, and will output a set of DUs from it to a temporary
directory (see :oe:func:`OESpruce::OEMakeDesignUnits` for details on the API).

.. code-block:: console

   make_apo_design_units <input biomolecular PDB> <site_residue> [<electron density mtz>] <LoopModelingTemplateDB>]

Code
----------------------

.. oe:language:: python

   .. only:: oehtml

      .. admonition:: Download code

         :download:`make_apo_design_units.py <../../../../wrappers/python/examples/spruce/make_apo_design_units.py>`
         and both the
         :download:`1w50.pdb <../../../../wrappers/test_data/OESpruceTests/1w50.pdb>`
         (the input PDB file),
         :download:`1w50.mtz <../../../../wrappers/test_data/OESpruceTests/1w50.mtz>`
         (the input MTZ file), and
         :download:`spruce_bace.loop_db <../../../../wrappers/test_data/OESpruceTests/spruce_bace.loop_db>`
         (the input loopDB file)


   .. :ref:`Full listing. <listing-make_apo_design_units.py>`

   ..   literalinclude:: ../../../../wrappers/python/examples/spruce/make_apo_design_units.py


   .. only:: oepdf

      .. oe:source:: make_apo_design_units.py
         :language: python

.. oe:language:: c++

   .. only:: oehtml

      .. admonition:: Download code

         :download:`make_apo_design_units.cpp <../../../../sublibs/tklibs/spruce/examples/make_apo_design_units.cpp>`
         and both the
         :download:`1w50.pdb <../../../../wrappers/test_data/OESpruceTests/1w50.pdb>`
         (the input PDB file),
         :download:`1w50.mtz <../../../../wrappers/test_data/OESpruceTests/1w50.mtz>`
         (the input MTZ file), and
         :download:`spruce_bace.loop_db <../../../../wrappers/test_data/OESpruceTests/spruce_bace.loop_db>`
         (the input loopDB file)

Example
--------------------------------------------------------------------------------

.. oe:language:: python

   .. code-block:: console

      make_apo_design_units.py 1w50.pdb "ASP:228: :A" 1w50.mtz  spruce_bace.loop_db

.. oe:language:: c++

   .. code-block:: console

      make_apo_design_units 1w50.pdb "ASP:228: :A" 1w50.mtz  spruce_bace.loop_db


will generate the following output (failing to add partial charges to iodine):

::

   DPI: 0.13, RFree: 0.28, Resolution: 1.75
   Processing BU # 0 with title: BETA-SECRETASE 1, chains A
   Found gap between ALA 157   A 1   and ALA 168   A 1  , with sequence GFPLNQSEVL
   Opened database spruce_bace.loop_db
   LoopDatabase Info:
       276 loops from RSCB last synced on 03-19-2020, were added to LoopTemplateDatabase on 03-19-2020 using Spruce Toolkit 1.0.0.a
       The loop database was built with a max loop length of 22, a termini crop length of 2, and excluding regular secondary structures
   Warning: Failed to charge miscellaneous components
   Warning: Unable to add partial charges and radii to DesignUnit: BETA-SECRETASE 1(A)__DU__biounit
   Iridium Category: NA, DPI: 0.13, RFree: 0.28, Resolution: 1.75

.. seealso::

   * :oe:func:`OESpruce::OEMakeDesignUnits` function
   * :oe:func:`OEBio::OEReadDesignUnit` and :oe:func:`OEBio::OEWriteDesignUnit` functions in the **OEChem TK** manual
   * :ref:`OEDesignUnit <OEBio_OEDesignUnit>` class in the **OEChem TK** manual
