/home/msneddon/eclipse/galileoSR1_cpp/workspace/NFsim/src/NFcore/templateMolecule.hh

Go to the documentation of this file.
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                 /* get functions */
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                 /* functions that allow you to set constraints */
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                 /* Methods for adding a disjoint component to a template pattern
00066                  *  e.g.  X.Y
00067                  */
00068                 void addConnectedTo(TemplateMolecule *t2, int otherConToIndex);
00069                 void addConnectedTo(TemplateMolecule *t2, int otherConToIndex,bool otherHasRxnCenter);
00070                 void clearConnectedTo();
00071 
00072 
00073                 /* functions that allow you to set constraints for symmetric sites */
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                 /* static function for binding two templates together */
00083                 static void bind(TemplateMolecule *t1, string bSiteName1, string compId1,
00084                                 TemplateMolecule *t2, string bSiteName2, string compId2);
00085 
00086                 /* functions that provide mapping capabilities */
00087                 void addMapGenerator(MapGenerator *mg);
00088 
00089                 /* functions that are needed to perform TemplateMolecule operations */
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                 /* searches the list of template molecules and identifies the number of disjoint
00097                    sets, and also returns the mapping onto those sets*/
00098                 static int getNumDisjointSets(vector < TemplateMolecule * > &tMolecules,
00099                                 vector <vector <TemplateMolecule *> > &sets,
00100                                 vector <int> &uniqueSetId);
00101 
00102                 /* functions that are needed to match to a molecule instance */
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                 //returns false if they are not symmetric, or true if they are
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         /* functions that handle output for debugging and error messages */
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                 // Handling of transformations
00139                 int n_mapGenerators;
00140                 MapGenerator **mapGenerators;
00141 
00142 
00148 
00149 
00150                 // Which of the unique components must be empty (no bonds)
00151                 int n_emptyComps;
00152                 int *emptyComps;
00153 
00154                 // Which of the unique components must be occupied (bonded to something, something
00155                 // that is not specified)
00156                 int n_occupiedComps;
00157                 int *occupiedComps;
00158 
00159                 // State value constraints
00160                 int n_compStateConstraint;
00161                 int *compStateConstraint_Comp; //index of the constrained component
00162                 int *compStateConstraint_Constraint; //the constrained value
00163 
00164                 // State value exclusions (state != exclusion)
00165                 int n_compStateExclusion;
00166                 int *compStateExclusion_Comp;
00167                 int *compStateExclusion_Exclusion;
00168 
00169                 // The set of connections that a particular site is connected to
00170                 int n_bonds;
00171                 int *bondComp;
00172                 string *bondCompName;
00173                 TemplateMolecule **bondPartner;
00174                 string *bondPartnerCompName; //used if nonsymmetric bond is connected to partner symmetric site
00175                 int *bondPartnerCompIndex; //used if nonsymmetric bond is connected to partner nonsymmetric site else =-1
00176                 bool *hasVisitedBond;
00177 
00178 
00179                 //This stores disjoint sets, in other words, this Template is
00180                 //connected to some other Template via .. the dot operator "."
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; //Used to match up a particular component when creating bonds
00192                 int *symCompStateConstraint;
00193                 int *symCompBoundState;  //either Empty (0), Occupied (1), or No constraint(2)
00194                 TemplateMolecule **symBondPartner; //the bound template, if this component is bound
00195                 string *symBondPartnerCompName;
00196                 int *symBondPartnerCompIndex;
00197                 vector < vector <int> > canBeMappedTo; //might want to change this to a 2d array for memory/speed?
00198                 bool *hasTraversedDownSym;
00199 
00200                 //Used when matching to a given molecule
00201                 int n_totalComps;
00202                 bool *isSymCompMapped;
00203                 bool *compIsAlwaysMapped;
00204 
00205                 Molecule *matchMolecule;
00206                 bool hasVisitedThis;
00207 
00208 
00209                 //For depth first traversals on a template molecule
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

Generated on Thu Dec 9 11:02:48 2010 for NFsim by  doxygen 1.5.4