00001
00002 #ifndef TEMPLATEMOLECULE_HH_
00003 #define TEMPLATEMOLECULE_HH_
00004
00005
00006 #include "NFcore.hh"
00007
00008 namespace NFcore
00009 {
00010
00011 class MoleculeType;
00012 class MapGenerator;
00013 class Molecule;
00014 class MappingSet;
00015 class ReactantContainer;
00016
00018
00035 class TemplateMolecule {
00036 public:
00037 TemplateMolecule(MoleculeType * moleculeType);
00038 ~TemplateMolecule();
00039
00040
00041
00042 MoleculeType *getMoleculeType() const {return moleculeType;};
00043 string getMoleculeTypeName() const;
00044
00045 int getN_symComps() const {return n_symComps; };
00046 int getN_symCompBonds() const {
00047 int symCompBondCounter=0;
00048 for(int i=0; i<n_symComps; i++) {
00049 if(symBondPartner[i]!=0) symCompBondCounter++;
00050 }
00051 return symCompBondCounter;
00052 }
00053 int getN_mapGenerators() const { return n_mapGenerators; }
00054 int getN_connectedTo() const { return n_connectedTo; };
00055
00056
00057 void addEmptyComponent(string cName);
00058 void addBoundComponent(string cName);
00059 void addComponentConstraint(string cName, string stateName);
00060 void addComponentConstraint(string cName, int stateValue);
00061 void addComponentExclusion(string cName, string stateName);
00062 void addComponentExclusion(string cName, int stateValue);
00063 void addBond(string thisBsiteName,TemplateMolecule *t2, string bSiteName2);
00064
00065
00066
00067
00068 void addConnectedTo(TemplateMolecule *t2, int otherConToIndex);
00069 void addConnectedTo(TemplateMolecule *t2, int otherConToIndex,bool otherHasRxnCenter);
00070 void clearConnectedTo();
00071
00072
00073
00074 const static int EMPTY=0;
00075 const static int OCCUPIED=1;
00076 const static int NO_CONSTRAINT=-1;
00077 void addSymCompConstraint(string cName, string uniqueId,
00078 int bondState,int stateConstraint);
00079 void addSymBond(string thisBsiteName, string thisCompId,
00080 TemplateMolecule *t2, string bSiteName2);
00081
00082
00083 static void bind(TemplateMolecule *t1, string bSiteName1, string compId1,
00084 TemplateMolecule *t2, string bSiteName2, string compId2);
00085
00086
00087 void addMapGenerator(MapGenerator *mg);
00088
00089
00090 bool contains(TemplateMolecule *tempMol);
00091
00092 const static bool FIND_ALL = false;
00093 const static bool SKIP_CONNECTED_TO = true;
00094 static void traverse(TemplateMolecule *tempMol, vector <TemplateMolecule *> &tmList, bool skipConnectedTo);
00095
00096
00097
00098 static int getNumDisjointSets(vector < TemplateMolecule * > &tMolecules,
00099 vector <vector <TemplateMolecule *> > &sets,
00100 vector <int> &uniqueSetId);
00101
00102
00103 bool compare(Molecule *m);
00104 bool compare(Molecule *m, ReactantContainer *rc, MappingSet *ms,bool holdMolClearToEnd=false);
00105 void clear();
00106 void clearTemplateOnly();
00107 bool tryToMap(Molecule *toMap, string toMapComponent,
00108 Molecule *mappedFrom, string mappedFromComponent);
00109 bool isSymMapValid();
00110
00111
00113
00114 static bool checkSymmetry(TemplateMolecule *tm1, TemplateMolecule *tm2, string bSite1, string bSite2);
00115 static bool checkSymmetryAroundBond(TemplateMolecule *tm1, TemplateMolecule *tm2, string bSite1, string bSite2);
00116
00117
00118
00119
00120 void printErrorAndExit(string message);
00121 void printDetails();
00122 void printDetails(ostream &o);
00123
00124
00125 string getPatternString();
00126 void printPattern();
00127 void printPattern(ostream &o);
00128
00129
00130
00131 protected:
00132
00133 static int TotalTemplateMoleculeCount;
00134
00135 MoleculeType *moleculeType;
00136 int uniqueTemplateID;
00137
00138
00139 int n_mapGenerators;
00140 MapGenerator **mapGenerators;
00141
00142
00148
00149
00150
00151 int n_emptyComps;
00152 int *emptyComps;
00153
00154
00155
00156 int n_occupiedComps;
00157 int *occupiedComps;
00158
00159
00160 int n_compStateConstraint;
00161 int *compStateConstraint_Comp;
00162 int *compStateConstraint_Constraint;
00163
00164
00165 int n_compStateExclusion;
00166 int *compStateExclusion_Comp;
00167 int *compStateExclusion_Exclusion;
00168
00169
00170 int n_bonds;
00171 int *bondComp;
00172 string *bondCompName;
00173 TemplateMolecule **bondPartner;
00174 string *bondPartnerCompName;
00175 int *bondPartnerCompIndex;
00176 bool *hasVisitedBond;
00177
00178
00179
00180
00181 int n_connectedTo;
00182 TemplateMolecule ** connectedTo;
00183 bool *hasTraversedDownConnectedTo;
00184 int *otherTemplateConnectedToIndex;
00185 bool *connectedToHasRxnCenter;
00186
00187
00189 int n_symComps;
00190 string *symCompName;
00191 string *symCompUniqueId;
00192 int *symCompStateConstraint;
00193 int *symCompBoundState;
00194 TemplateMolecule **symBondPartner;
00195 string *symBondPartnerCompName;
00196 int *symBondPartnerCompIndex;
00197 vector < vector <int> > canBeMappedTo;
00198 bool *hasTraversedDownSym;
00199
00200
00201 int n_totalComps;
00202 bool *isSymCompMapped;
00203 bool *compIsAlwaysMapped;
00204
00205 Molecule *matchMolecule;
00206 bool hasVisitedThis;
00207
00208
00209
00210 static queue <TemplateMolecule *> q;
00211 static queue <int> d;
00212 static vector <TemplateMolecule *>::iterator tmVecIter;
00213 static list <TemplateMolecule *>::iterator tmIter;
00214
00215 };
00216
00217 }
00218
00219
00220 #endif