.. _section_example_oechem_molextract:

Extract molecules by title
================================================================================

A program that extracts molecules from a file based on their
title. The program can take as input either a specific title or a file
containing a list of titles.

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

.. oe:language:: c++

   .. code-block:: console

      prompt> molextract -title Mol0001 -i dbase.oeb.gz -o Mol0001.oeb.gz
      prompt> molextract -list names.txt dbase.oeb.gz output.oeb.gz

.. oe:language:: python

   .. code-block:: console

      prompt> molextract.py -title Mol0001 -i dbase.oeb.gz -o Mol0001.oeb.gz
      prompt> molextract.py -list names.txt dbase.oeb.gz output.oeb.gz

.. oe:language:: java

   .. code-block:: console

      prompt> MolExtract -title Mol0001 -i dbase.oeb.gz -o Mol0001.oeb.gz
      prompt> MolExtract -list names.txt dbase.oeb.gz output.oeb.gz

.. oe:language:: csharp

   .. code-block:: console

      prompt> MolExtract -title Mol0001 -i dbase.oeb.gz -o Mol0001.oeb.gz
      prompt> MolExtract -list names.txt dbase.oeb.gz output.oeb.gz

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

.. oe:language:: c++

   .. only:: oehtml

      .. admonition:: Download code

         :download:`molextract.cpp <../../../../../sublibs/tklibs/oechem/examples/molextract.cpp>`

   .. only:: oepdf

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

.. oe:language:: python

   .. only:: oehtml

      .. admonition:: Download code

         :download:`molextract.py <../../../../../wrappers/python/examples/oechem/molextract.py>`

      .. literalinclude:: ../../../../../wrappers/python/examples/oechem/molextract.py


   .. only:: oepdf

      .. oe:source:: molextract.py
         :language: python

.. oe:language:: java

   .. only:: oehtml

      .. admonition:: Download code

         :download:`MolExtract.java <../../../../../wrappers/java/examples/openeye/examples/oechem/MolExtract.java>`

   .. only:: oepdf

      .. oe:source:: MolExtract.java
         :language: java

.. oe:language:: csharp

   .. only:: oehtml

      .. admonition:: Download code

         :download:`MolExtract.cs <../../../../../wrappers/csharp/Csharp-Examples/OEChem/MolExtract.cs>`

   .. only:: oepdf

      .. oe:source:: MolExtract.cs
         :language: csharp

.. seealso::

   * :oe:meth:`OEChem::OEMolBase::GetTitle` method
