00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef MOLECULEUTILS_H
00029 #define MOLECULEUTILS_H
00030
00031
00032 #include <istream>
00033 #include <locale>
00034 #include <string>
00035 #include <iomanip>
00036
00037
00038
00039 #include <moleculeset.h>
00040
00041
00042 #define FINDENTRY 0
00043 #define READINGNODES 1
00044 #define READINGEDGES 2
00045 #define READINGUNKNOWN 3
00046
00047
00048 using namespace std;
00049
00050
00055 class MoleculeUtils {
00056
00057 public:
00058
00059
00061
00062
00063
00069 static void readMDLCtabBlock(
00070 Molecule& aMolecule,
00071 ifstream& inFile,
00072 bool genericAtomTypeFlag = false
00073 ) throw( CError );
00074
00078 static void readMDLHeaderBlock(
00079 Molecule& aMolecule,
00080 ifstream& inFile,
00081 string aName = "COMMENT"
00082 ) throw( CError );
00083
00088 static void readMDLNSDBlock( Molecule& aMolecule, ifstream& inFile ) throw( CError );
00089
00092 static void skipMDLEntry( Molecule& aMolecule, ifstream& inFile ) throw( CError );
00093
00096 static void writeMDLHeaderBlock( Molecule& aMolecule, ofstream& outFile );
00097
00101 static void writeMDLCtabBlock( Molecule& aMolecule, ofstream& outFile );
00102
00107 static void writeMDLNSDBlock( Molecule& aMolecule, ofstream& outFile );
00108
00111 static void writeKCF( Molecule& aMolecule, ofstream& outFile );
00112
00117 static void writeKCFNSDBlock( Molecule& aMolecule, ofstream& outFile );
00118
00121 static bool readKCFMolecule( KCFMolecule& aMolecule, ifstream& inFile ) throw( CError );
00122
00123
00126 static void writeDOTGraph( Molecule& aMolecule, ofstream& outFile, bool perretabels = false );
00127
00129
00130
00131
00132
00134
00135
00141 static double moleculeKernel(
00142 Molecule* mol1,
00143 Molecule* mol2,
00144 double (*pt2AtomKernel)(Atom*, Atom*) = &atomKernelSymbol,
00145 double (*pt2BondKernel)(Bond*, Bond*) = &bondKernelType,
00146 int convergenceCondition = 1000, int parameter2 = 1
00147 );
00148
00154 static double powerKernelUntilN( Molecule* mol1, Molecule* mol2, double (*pt2AtomKernel)( Atom*, Atom* ), double (*pt2BondKernel)(Bond*, Bond*), int maxPower, int minLength = 1 ) throw( CError );
00155
00160 static double powerKernelOrderN( Molecule* mol1, Molecule* mol2, double (*pt2AtomKernel)( Atom*, Atom* ), double (*pt2BondKernel)(Bond*, Bond*), int anOrder, int parameter2 = 1 ) throw( CError );
00161
00167 static double powerKernelConverge( Molecule* mol1, Molecule* mol2, double (*pt2AtomKernel)( Atom*, Atom* ), double (*pt2BondKernel)(Bond*, Bond*), int converge, int parameter2 = 1 ) throw( CError );
00168
00171 static vector< vector<double> >* rlk(
00172 vector< vector<double> >* r,
00173 vector< vector<double> >* rwork,
00174 vector< vector<double> >* rstart,
00175 Molecule* mol1,
00176 Molecule* mol2,
00177 int convergenceCondition,
00178 int parameter2,
00179 double (*pt2AtomKernel)(Atom*, Atom*),
00180 double (*pt2BondKernel)(Bond*, Bond*),
00181 int depth
00182 );
00183
00186 static bool converge(
00187 vector< vector<double> >* r1,
00188 vector< vector<double> >* r2,
00189 Molecule* mol1,
00190 Molecule* mol2,
00191 int convergenceCondition
00192 );
00193
00196 static double atomKernelSymbol( Atom* a1, Atom* a2 );
00197
00201 static double atomKernelMorganLabel( Atom* a1, Atom* a2 );
00202
00205 static double atomKernelPerretLabel( Atom* a1, Atom* a2 );
00206
00209 static double atomKernelPerretLabelExternalMatrix( Atom* a1, Atom* a2 );
00210
00211
00215 static double atomKernelExternalMatrix( Atom* a1, Atom* a2 );
00216
00219 static double atomKernelLabel( Atom* a1, Atom* a2 );
00220
00221
00225 static double bondKernelType( Bond* b1, Bond* b2 );
00226
00230 static double bondKernelPerretLabelStrict( Bond* b1, Bond* b2 );
00231
00237 static double bondKernelPerretLabel( Bond* b1, Bond* b2 );
00238
00239
00245 static double bondKernelRotable( Bond* b1, Bond* b2 );
00246
00248
00249
00250
00251
00253
00254
00257 static double threeDkernel(
00258 Molecule* mol1, Molecule* mol2,
00259 double (*pt2AtomKernel)( Atom*, Atom*),
00260 double (*pt2BondKernel)(float, float, float),
00261 float edgeKernelParameter );
00262
00265 static double threeDedgeKernelRBF( float dist1, float dist2 , float param );
00266
00269 static double threeDedgeKernelTriangle( float dist1, float dist2 , float param );
00270
00272
00273
00274
00275
00276
00278
00279
00282 static string getRingString( Bond* aBond ) throw( CError );
00283
00286 static void describeMap( map<Atom*, float>* aMap );
00287
00291 static void substractSet( vector<Atom*>* full, vector<Atom*>* exclude, vector<Atom*>* result);
00292
00295 static bool atomVectorHas( vector<Atom*>* atomVector, Atom* anAtom );
00296
00300 static void mergeSet( vector<Atom*>* v1, vector<Atom*>* v2, vector<Atom*>* result);
00301
00304 static void mergeBondSet( vector<Bond*>* v1, vector<Bond*>* v2, vector<Bond*>* result);
00305
00308 static void selectRingMemberBonds( vector<Bond*>* v1, vector<Atom*>* a, vector<Bond*>* v2 );
00309
00310
00312
00313
00314
00315
00316
00317 };
00318
00319 #endif