DistPicker.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (C) 2003-2006 Rational Discovery LLC
00003 //
00004 //   @@ All Rights Reserved @@
00005 //  This file is part of the RDKit.
00006 //  The contents are covered by the terms of the BSD license
00007 //  which is included in the file license.txt, found at the root
00008 //  of the RDKit source tree.
00009 //
00010 #ifndef _RD_DISTPICKER_H
00011 #define _RD_DISTPICKER_H
00012 
00013 #include <RDGeneral/types.h>
00014 
00015 namespace RDPickers {
00016 
00017   /*! \brief function to lookup distance from 1D lower triangular distance matrix
00018    *
00019    *
00020    *    \param distMat - a pointer to a 1D lower triangular distance matrix \n
00021    *    \param i - row index \n
00022    *    \param j - column index \n
00023    *
00024    *  RETURNS:
00025    *
00026    *    if (i == j) : 0.0
00027    *    if (i > j) : distMat[i*(i-1)/2 + j]
00028    *    if (j < i) : distMat[j*(j-1)/2 + i]
00029    */
00030   double getDistFromLTM(const double *distMat, unsigned int i, unsigned int j);
00031       
00032   /*! \brief Abstract base class to do perform item picking (typically molecules) using a 
00033    *         distance matrix
00034    *
00035    *  This class should never be instantiated by itself. One of the child classes need to be
00036    *  used. The picking algorithm itself is missing here and only the child calsses implement that
00037    *  This class contains a pointer to a distance matrix, but it is not responsible for cleaning it up
00038    */
00039   class DistPicker {
00040     
00041   public:
00042     /*! \brief Default constructor
00043      *
00044      */
00045     DistPicker(){};
00046     virtual ~DistPicker() {};
00047     
00048     /*! \brief this is a virtual function specific to the type of algorihtm used
00049      *
00050      *  The child classes need to implement this function
00051      *
00052      *  ARGUMENTS:
00053      *
00054      *    \param distMat - distance matrix - a vector of double. It is assumed that only the 
00055      *              lower triangle elements of the matrix are supplied in a 1D array
00056      *    \param poolSize - the size of teh pool to pick the items from. It is assumed that the
00057      *              distance matrix above contains the right number of elements; i.e.
00058      *              poolSize*(poolSize-1)
00059      *    \param pickSize - the number items to pick from pool (<= poolSize)
00060      * 
00061      *    \return a vector with indices of the picked items.
00062      */
00063     virtual RDKit::INT_VECT pick(const double *distMat, unsigned int poolSize,
00064                                  unsigned int pickSize) const = 0;
00065   };
00066 };
00067 
00068 #endif