.. _section_examples_summary_assigncharges:

Assigning Charges
=========================================================

The following code example shows how to assign partial charges.
The program reads all of the molecules in the input file, assigns partial
charges to each based on the selected method (the default is ``-method mmff94``),
and writes each charged molecule to the output file.

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

A description of the command line interface can be obtained by
executing the program with the --help argument.

.. oe:language:: c++

   .. code-block:: console

      prompt> assigncharges --help

.. oe:language:: python

   .. code-block:: console

      prompt> python assigncharges.py --help

.. oe:language:: java

   .. code-block:: console

      prompt> java AssignCharges --help

.. oe:language:: csharp

   .. code-block:: console

      prompt> AssignCharges --help


will generate the following output:

.. code-block:: console

   Simple parameter list

    Charging options
      -method : which set of charges to apply

    input/output options
      -in : Input molecule
      -out : Output molecule (usually an oeb)


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

.. oe:language:: python

   .. only:: oehtml

      .. admonition:: Download code

         :download:`assigncharges.py <../../../../wrappers/python/examples/quacpac/assigncharges.py>`

      .. literalinclude:: ../../../../wrappers/python/examples/quacpac/assigncharges.py

   .. only:: oepdf

      .. oe:source:: assigncharges.py
         :language: python

.. oe:language:: c++

   .. only:: oehtml

      .. admonition:: Download code

         :download:`assigncharges.cpp <../../../../sublibs/tklibs/quacpac/examples/assigncharges.cpp>`
         and
         :download:`assigncharges.txt <../../../../sublibs/tklibs/quacpac/examples/assigncharges.txt>`
         interface file

   .. only:: oepdf

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

      with interface file

      .. oe:source:: assigncharges.txt
         :language: c++

.. oe:language:: java

   .. only:: oehtml

      .. admonition:: Download code

         :download:`AssignCharges.java <../../../../wrappers/java/examples/openeye/examples/oequacpac/AssignCharges.java>`
         and
         :download:`AssignCharges.txt <../../../../wrappers/java/examples/openeye/examples/oequacpac/AssignCharges.txt>`
         interface file

   .. only:: oepdf

      .. oe:source:: AssignCharges.java
         :language: java

      with interface file

      .. oe:source:: AssignCharges.txt
         :language: java

.. oe:language:: csharp

   .. only:: oehtml

      .. admonition:: Download code

         :download:`AssignCharges.cs <../../../../wrappers/csharp/Csharp-Examples/OEQuacPac/AssignCharges.cs>`

   .. only:: oepdf

      .. oe:source:: AssignCharges.cs
         :language: csharp

.. seealso::

   * :oe:func:`OEProton::OEAssignCharges` function

