MTK++ Latest version: 0.2.0

pharmacophore.h
Go to the documentation of this file.
00001 
00033 #ifndef PHARMACOPHORE_H
00034 #define PHARMACOPHORE_H
00035 
00036 #include <iostream>
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040 #include <algorithm>
00041 #include <cmath>
00042 #include "Utils/vector3d.h"
00043 
00044 namespace MTKpp
00045 {
00046 
00047 class molecule;
00048 class atom;
00049 //class vector3d;
00050 
00051 // ============================================================
00052 // Class : clique
00053 // ------------------------------------------------------------
00058 // ============================================================
00059 class clique
00060 {
00061 public:
00063     clique();
00064 
00066     virtual ~clique();
00067 
00076     static bool less(const clique *lhs, const clique *rhs) {
00077       return lhs->score < rhs->score;
00078     }
00079 
00088     static bool greater(const clique *lhs, const clique *rhs) {
00089       return lhs->score > rhs->score;
00090     }
00091 
00097     inline friend bool operator==(clique &lhs, clique &rhs) {
00098       unsigned int nHits = 0;
00099       unsigned int counter = 0;
00100       unsigned int lhsSize = lhs.indicesA.size();
00101       unsigned int rhsSize = rhs.indicesA.size();
00102       if (lhsSize != rhsSize) return false;
00103 
00104       // Not sure about this test, may remove some useful cliques
00105       if (std::abs(lhs.score - rhs.score) < 0.00001) {
00106         return true;
00107       }
00108 
00109       for (unsigned int i = 0; i < lhsSize; i++) {
00110         for (unsigned int j = 0; j < rhsSize; j++) {
00111           if (lhs.indicesA[i] == rhs.indicesA[j]) {
00112             if (lhs.indicesB[i] == rhs.indicesB[j]) {
00113               counter++;
00114             }
00115           }
00116         }
00117       }
00118 
00119       for (unsigned int i = 0; i < lhsSize; i++) {
00120         for (unsigned int j = 0; j < rhsSize; j++) {
00121           double coordDiff = lhs.coords[i].dist(rhs.coords[j]);
00122           if (std::abs(coordDiff) < 0.0001) {
00123             nHits++;
00124             break;
00125           }
00126         }
00127       }
00128 
00129       if ((counter == rhsSize) or (nHits == rhsSize)) {
00130         return true;
00131       }
00132       return false;
00133     }
00134 
00139     bool compare(clique* rhs);
00140 
00142     double score;
00143 
00145     double score2;
00146 
00148     double dMax;
00149 
00151     std::vector<vector3d> coords;
00152 
00154     std::vector<int> indicesA;
00155 
00157     std::vector<int> indicesB;
00158 };
00159 
00160 // ============================================================
00161 // Class : pharmacophore()
00162 // ------------------------------------------------------------
00168 // ============================================================
00169 class pharmacophore
00170 {
00171 public:
00177     pharmacophore(molecule *parent, double distMax = 0.5);
00178 
00180     virtual ~pharmacophore();
00181 
00189     int run(molecule* mol,
00190             std::vector<std::vector<unsigned int> > &mcp,
00191             std::vector<vector3d> &mcpCoords);
00192 
00199     int getCliques(molecule* mol, std::vector<clique*> &cliqueList);
00200 
00201 protected: // DATA
00202 
00213     int generateCorrMatrix(unsigned int nFeaturesA, unsigned int nFeaturesB,
00214                            std::vector<std::string> featureLabelsA,
00215                            std::vector<std::string> featureLabelsB,
00216                            int crpdeMatrix[]);
00217 //                           int* crpdeMatrix);
00218 
00230     int getCGood(double &cGood, unsigned int nFeaturesA, unsigned int nFeaturesB,
00231                  std::vector<std::string> featureLabelsA,
00232                  double* featureDistMatrixA,
00233                  double* featureDistMatrixB,
00234                  int crpdeMatrix[]);
00235 
00253     int getClique(unsigned int iA, unsigned int jB,
00254                    unsigned int nFeaturesA, unsigned int nFeaturesB,
00255                    std::vector<std::string> featureLabelsA,
00256                    double* featureDistMatrixA, double* featureDistMatrixB,
00257                    int crpdeMatrix[], double cGood,
00258                    std::vector<std::vector<unsigned int> > &clique,
00259                    double &score, double &score2, double &dMax);
00260 
00261     //---------------//
00262     // -  POINTERS - //
00263     //---------------//
00264 
00266     molecule*                pParent;
00267 
00269     atom*                    pAtom;
00270 
00272     double                   deltaDistMax;
00273 };
00274 
00275 } // MTKpp namespace
00276 
00277 #endif // PHARMACOPHORE_H

Generated on Fri Dec 23 2011 09:28:51 for MTK++ by Doxygen 1.7.5.1