.. _spruce_examples_make_design_units:

Creating 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 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_design_units <input biomolecular PDB> [<electron density mtz>] [<LoopModelingTemplateDB>]

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

.. oe:language:: python

   .. only:: oehtml

      .. admonition:: Download code

         :download:`make_design_units.py <../../../../wrappers/python/examples/spruce/make_design_units.py>`
         and both the
         :download:`3tpp.pdb <../../../../wrappers/test_data/OESpruceTests/3tpp.pdb>`
         (the input PDB file),
         :download:`3tpp.mtz <../../../../wrappers/test_data/OESpruceTests/3tpp.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_design_units.py>`

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

   .. only:: oepdf

      .. oe:source:: make_design_units.py
         :language: python


.. oe:language:: c++

   .. only:: oehtml

      .. admonition:: Download code

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

   .. only:: oepdf

      .. oe:source:: make_design_units.cpp
         :language: c++


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

.. oe:language:: c++

   .. code-block:: console

      make_design_units 3tpp.pdb 3tpp.mtz spruce_bace.loop_db

.. oe:language:: python

   .. code-block:: console

      make_design_units.py 3tpp.pdb 3tpp.mtz spruce_bace.loop_db

will generate the following output:

::

   DPI: 0.06, RFree: 0.18, Resolution: 1.60
   Processing BU # 0 with title: BETA-SECRETASE 1, chains A, alt: A
   Warning: For residue ARG -4   A 1   removing clashing solvent molecule HOH 597   A 2
   Warning: For residue ARG -4   A 1   removing clashing solvent molecule HOH 487 A A 1
   Warning: For residue ARG 7   A 1   removing clashing solvent molecule HOH 498   A 2
   Warning: For residue ARG 7   A 1   removing clashing solvent molecule HOH 730   A 2
   Warning: For residue ARG 7   A 1   removing clashing solvent molecule HOH 653   A 2
   Warning: For residue ARG 128   A 1   removing clashing solvent molecule HOH 523   A 2
   Warning: For residue ARG 128   A 1   removing clashing solvent molecule HOH 654   A 2
   Warning: For residue LYS 142   A 1   removing clashing solvent molecule HOH 550   A 2
   Warning: For residue LYS 142   A 1   removing clashing solvent molecule HOH 691   A 2
   Warning: For residue ARG 205   A 1   removing clashing solvent molecule HOH 423   A 2
   Warning: For residue ARG 205   A 1   removing clashing solvent molecule HOH 703   A 2
   Warning: For residue LYS 256   A 1   removing clashing solvent molecule HOH 604   A 2
   Found gap between ALA 157   A 1   and VAL 170   A 1  , with sequence GFPLNQSEVLAS
   Found gap between GLU 310   A 1   and THR 314   A 1  , with sequence DVA
   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
   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
   Processing BU # 1 with title: BETA-SECRETASE 1, chains A, alt: B
   Warning: For residue ARG -4   A 1   removing clashing solvent molecule HOH 597   A 2
   Warning: For residue ARG -4   A 1   removing clashing solvent molecule HOH 487 A A 1
   Warning: For residue LYS 9   A 1   removing clashing solvent molecule HOH 675   A 2
   Warning: For residue ARG 128   A 1   removing clashing solvent molecule HOH 523   A 2
   Warning: For residue ARG 128   A 1   removing clashing solvent molecule HOH 654   A 2
   Warning: For residue LYS 142   A 1   removing clashing solvent molecule HOH 448   A 2
   Warning: For residue LYS 142   A 1   removing clashing solvent molecule HOH 735   A 2
   Warning: For residue ARG 205   A 1   removing clashing solvent molecule HOH 423   A 2
   Warning: For residue ARG 205   A 1   removing clashing solvent molecule HOH 703   A 2
   Warning: For residue LYS 256   A 1   removing clashing solvent molecule HOH 604   A 2
   Found gap between ALA 157   A 1   and VAL 170   A 1  , with sequence GFPLNQSEVLAS
   Found gap between GLU 310   A 1   and THR 314   A 1  , with sequence DVA
   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
   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
   DU: BETA-SECRETASE 1(A)altA > 5HA(A-999), Iridium Category: HT, LaD: 1.00, ASaD: 1.00, DPI: 0.06, POL: false, POAS: false, AltConfs: false, PackRes: false, Excp: false, IrrRFree: false, PossCov: false
   DU: BETA-SECRETASE 1(A)altB > 5HA(A-999), Iridium Category: HT, LaD: 1.00, ASaD: 1.00, DPI: 0.06, POL: false, POAS: false, AltConfs: false, PackRes: false, Excp: false, IrrRFree: false, PossCov: false
   Skipping redundant DU with alts outside the site of interest, renaming existing to collapse alts
   Discarding redundant alt DU with title BETA-SECRETASE 1(A)altB > 5HA(A-999)

.. 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
