Canon.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #ifndef _RD_CANON_H_
00007 #define _RD_CANON_H_
00008
00009 namespace RDKit {
00010 class ROMol;
00011 class Atom;
00012 class Bond;
00013 };
00014
00015 namespace Canon {
00016 const int MAX_NATOMS=1000;
00017 const int MAX_CYCLES=50;
00018
00019
00020 typedef enum {
00021 WHITE_NODE=0,
00022 GREY_NODE,
00023 BLACK_NODE,
00024 } AtomColors;
00025
00026
00027 typedef enum {
00028 MOL_STACK_ATOM=0,
00029 MOL_STACK_BOND,
00030 MOL_STACK_RING,
00031 MOL_STACK_BRANCH_OPEN,
00032 MOL_STACK_BRANCH_CLOSE,
00033 } MolStackTypes;
00034
00035
00036 typedef union{
00037 RDKit::Atom *atom;
00038 RDKit::Bond *bond;
00039 } MolStackUnion;
00040
00041
00042 class MolStackElem {
00043 public:
00044
00045 explicit MolStackElem(RDKit::Atom *at) {
00046 type = MOL_STACK_ATOM;
00047 obj.atom = at;
00048 };
00049
00050
00051
00052
00053
00054
00055
00056 explicit MolStackElem(RDKit::Bond *bond,int idx) {
00057 type = MOL_STACK_BOND;
00058 obj.bond = bond;
00059 number = idx;
00060 };
00061
00062 explicit MolStackElem(int idx) {
00063 type = MOL_STACK_RING;
00064 number = idx;
00065 };
00066
00067 explicit MolStackElem(const char *chr,int idx) {
00068 switch(chr[0]){
00069 case '(':
00070 type = MOL_STACK_BRANCH_OPEN;
00071 break;
00072 case ')':
00073 type = MOL_STACK_BRANCH_CLOSE;
00074 break;
00075 default:
00076 break;
00077 }
00078 number=idx;
00079 }
00080 MolStackTypes type;
00081 MolStackUnion obj;
00082 int number;
00083 };
00084 typedef std::vector<MolStackElem> MolStack;
00085
00086
00087
00088 typedef std::pair< int, std::pair< int, RDKit::Bond * > > PossibleType;
00089
00090 PossibleType makePossible(int rank,int atomIdx,RDKit::Bond *bond);
00091
00092 int _possibleComp(const PossibleType &arg1,const PossibleType &arg2);
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 void canonicalizeFragment(RDKit::ROMol &mol,int atomIdx,
00109 std::vector<AtomColors> &colors,
00110 std::vector<int> &ranks,
00111 MolStack &molStack);
00112
00113 };
00114
00115 #endif