.. _tutorial1_UserInertialStarts_section:

UserInertialStarts
================================================================================

:oe:meth:`OEFastROCS::OEFastROCSOrientation::UserInertialStarts` allows custom
coordinates to be used as starting positions for optimization. Using the
:ref:`4TMN ligand<alternative_starts_figure_2>` from the
:ref:`tutorial_alternative_starts_introduction_section` as an example,
optimization can be done at the atom highlighted in green below:

.. _alternative_starts_figure_5:

.. figure:: ../../images/Tutorial_1_Figure_5.png
   :align: center
   :width: 400

   **4TMN Ligand with atom 34 highlighted green**

Before running the program, the index of the desired atom needs to be
identified.  This can be accomplished by loading the molecule in **VIDA** and
turning on atom indices.  In this example, the atom’s index is identified
as idx 34.  With this information, the x,y,z coordinates of atom idx 34 are
pulled via the code snippet below.
These coordinates are then used as user-defined starting coordinates:

.. oe:language:: c++

   .. oe:source:: tutorial1_inertialatheavyatoms_snippet.cpp
      :language:  c++
      :frag:      SNIPPET-4

   To use the :oe:meth:`OEFastROCS::OEFastROCSOrientation::UserInertialStarts`
   method, set
   :oe:meth:`OEFastROCS::OEShapeDatabaseOptions::SetInitialOrientation` and then
   input the starts
   vector using :oe:meth:`OEFastROCS::OEShapeDatabaseOptions::SetUserStarts`:

   .. oe:source:: tutorial1_inertialatheavyatoms_snippet.cpp
      :language:  c++
      :frag:      SNIPPET-5

   The first argument of
   :oe:meth:`OEFastROCS::OEShapeDatabaseOptions::SetUserStarts` is the
   startsCoords array created previously. This must be of the type
   ``float array``.  The second argument is the number of user-defined
   starting coordinates to optimize.

   In this example, only 1 user-defined starting point has been set.
   There is no limit to the number of user-defined starts however, it should
   be noted that performance is inversely proportional to the number of starts
   being optimized.

   To check that the starts have been set correctly, query
   :oe:meth:`OEFastROCS::OEShapeDatabaseOptions::GetInitialOrientation` and
   :oe:meth:`OEFastROCS::OEShapeDatabaseOptions::GetNumUserStarts`:

   .. oe:source:: tutorial1_inertialatheavyatoms_snippet.cpp
      :language:  c++
      :frag:      SNIPPET-6

   The output from the modified C++ script now looks like this:

   .. code-block:: console

      Opening database file 3tmn_lig.sdf ...
      This example will use 1 starts
      Searching for 4tmn_lig.sdf
      Score for mol 0(conf 0) 0.289689 shape 0.358462 color
      Score for mol 0(conf 0) 0.320501 shape 0.098301 color
      Score for mol 0(conf 0) 0.283724 shape 0.012400 color
      Score for mol 0(conf 0) 0.145704 shape 0.023627 color

   .. only:: oehtml

      .. admonition:: Download code

         The fully modified c++ script used in this tutorial can be found here
         :download:`userinertialstarts.cpp <../../../../../../sublibs/tklibs/fastrocs/examples/userinertialstarts.cpp>`

   .. only:: oepdf

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

.. oe:language:: python

   .. oe:source:: Tutorial1_InertialAtHeavyAtoms_Snippet.py
      :language:  python
      :frag:      SNIPPET-4

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


   To use the :oe:meth:`OEFastROCS::OEFastROCSOrientation::UserInertialStarts`
   method, set
   :oe:meth:`OEFastROCS::OEShapeDatabaseOptions::SetInitialOrientation` and then
   input the starts
   vector using :oe:meth:`OEFastROCS::OEShapeDatabaseOptions::SetUserStarts`:

   .. oe:source:: Tutorial1_InertialAtHeavyAtoms_Snippet.py
      :language:  python
      :frag:      SNIPPET-5

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


   The first argument of
   :oe:meth:`OEFastROCS::OEShapeDatabaseOptions::SetUserStarts` is the
   startsCoords vector created previously. This must be of the type
   ``OEFloatVector``.  The second argument is the number of user-defined
   starting coordinates to optimize.

   In this example, only 1 user-defined starting point has been set.
   There is no limit to the number of user-defined starts however, it should
   be noted that performance is inversely proportional to the number of starts
   being optimized.

   To check that the starts have been set correctly, query
   :oe:meth:`OEFastROCS::OEShapeDatabaseOptions::GetInitialOrientation` and
   :oe:meth:`OEFastROCS::OEShapeDatabaseOptions::GetNumUserStarts`:

   .. oe:source:: Tutorial1_InertialAtHeavyAtoms_Snippet.py
      :language:  python
      :frag:      SNIPPET-6

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


   The output from the modified Python script now looks like this:

   .. code-block:: console

      Opening database file 3tmn_lig.sdf ...
      This example will use 1 starts
      Searching for 4tmn_lig.sdf
      Score for mol 0(conf 0) 0.289689 shape 0.358462 color
      Score for mol 0(conf 0) 0.320501 shape 0.098301 color
      Score for mol 0(conf 0) 0.283724 shape 0.012400 color
      Score for mol 0(conf 0) 0.145704 shape 0.023627 color

   .. only:: oehtml

      .. admonition:: Download code

         The fully modified python script used in this tutorial can be found here
         :download:`UserInertialStartsExample.py <../../../../../../wrappers/python/examples/fastrocs/UserInertialStartsExample.py>`

   .. only:: oepdf

      .. oe:source:: UserInertialStartsExample.py
         :language: python

.. oe:language:: java

   .. oe:source:: Tutorial1_InertialAtHeavyAtoms_Snippet.java
      :language:  java
      :frag:      SNIPPET-4

   To use the :oe:meth:`OEFastROCS::OEFastROCSOrientation::UserInertialStarts`
   method, set
   :oe:meth:`OEFastROCS::OEShapeDatabaseOptions::SetInitialOrientation` and then
   input the starts
   vector using :oe:meth:`OEFastROCS::OEShapeDatabaseOptions::SetUserStarts`:

   .. oe:source:: Tutorial1_InertialAtHeavyAtoms_Snippet.java
      :language:  java
      :frag:      SNIPPET-5

   The first argument of
   :oe:meth:`OEFastROCS::OEShapeDatabaseOptions::SetUserStarts` is the
   startsCoords array created previously. This must be of the type
   ``OEFloatArray``.  The second argument is the number of user-defined
   starting coordinates to optimize.

   In this example, only 1 user-defined starting point has been set.
   There is no limit to the number of user-defined starts however, it should
   be noted that performance is inversely proportional to the number of starts
   being optimized.

   To check that the starts have been set correctly, query
   :oe:meth:`OEFastROCS::OEShapeDatabaseOptions::GetInitialOrientation` and
   :oe:meth:`OEFastROCS::OEShapeDatabaseOptions::GetNumUserStarts`:

   .. oe:source:: Tutorial1_InertialAtHeavyAtoms_Snippet.java
      :language:  java
      :frag:      SNIPPET-6

   The output from the modified Java script now looks like this:

   .. code-block:: console

      Opening database file 3tmn_lig.sdf ...
      This example will use 1 starts
      Searching for 4tmn_lig.sdf
      Score for mol 0(conf 0) 0.289689 shape 0.358462 color
      Score for mol 0(conf 0) 0.320501 shape 0.098301 color
      Score for mol 0(conf 0) 0.283724 shape 0.012400 color
      Score for mol 0(conf 0) 0.145704 shape 0.023627 color

   .. only:: oehtml

      .. admonition:: Download code

         The fully modified java script used in this tutorial can be found here
         :download:`UserInertialStartsExample.java <../../../../../../wrappers/java/examples/openeye/examples/oefastrocs/UserInertialStartsExample.java>`

   .. only:: oepdf

      .. oe:source:: UserInertialStartsExample.java
         :language: java
