MTK++ Latest version: 0.2.0

molecule.h
Go to the documentation of this file.
00001 
00035 #ifndef MOLECULE_H
00036 #define MOLECULE_H
00037 
00038 #include "Utils/constants.h"
00039 
00040 #include <iostream>
00041 #include <string>
00042 #include <vector>
00043 #include <map>
00044 #include <algorithm>
00045 #include <fstream>
00046 #include <iomanip>
00047 #include <stdlib.h>
00048 #include <sstream>
00049 
00050 namespace MTKpp
00051 {
00052 // ============================================================
00053 // - classes
00054 class collection;
00055 class submolecule;
00056 class atom;
00057 class vector3d;
00058 class rings;
00059 class conformers;
00060 class protonate;
00061 class fingerPrint;
00062 class functionalize;
00063 class hydrophobize;
00064 class pharmacophore;
00065 class stdLibrary;
00066 class stdFrag;
00067 struct stdAtom;
00068 class parameters;
00069 
00070 // ------------------------------------------------------------
00071 // - structs
00072 struct moleculeFlags;
00073 struct Bond;
00074 struct Angle;
00075 struct Torsion;
00076 struct Improper;
00077 struct ring;
00078 struct funcGroup;
00079 struct hydrophobe;
00080 struct conformer;
00081 struct bondParam;
00082 struct angleParam;
00083 struct torsionParam;
00084 struct improperParam;
00085 struct hBondParam;
00086 struct LJ612Param;
00087 struct LJ612SE;
00088 struct clique;
00089 
00090 // ============================================================
00091 // Class : molecule()
00092 // ------------------------------------------------------------
00097 // ============================================================
00098 
00099 class molecule
00100 {
00101 public:
00102 
00107     molecule(collection *parent = 0);
00108 
00110     virtual ~molecule();
00111 
00112     //-----------------------//
00113     // - GENERAL FUNCTIONS - //
00114     //-----------------------//
00115 
00120     collection*              getParent();
00121 
00126     void                     setName(const std::string& name);
00127 
00132     std::string              getName();
00133 
00138     void                     setChain(const std::string& chain);
00139 
00144     std::string              getChain();
00145 
00150     void                     setKind(const int& n);
00151 
00156     int                      getKind();
00157 
00162     void                     setMolId(const int& id);
00163 
00168     int                      getMolId();
00169 
00174     void                     setNumAtoms(const int& natoms);
00175 
00180     int                      getNumAtoms();
00181 
00186     int                      getNumHeavyAtoms();
00187 
00192     void                     setNumBonds(const int& nbonds);
00193 
00198     int                      getNumBonds();
00199 
00204     void                     setAtomIndex(const int& n);
00205 
00210     int                      getAtomIndex();
00211 
00216     void                     setMaxFileID(const int& n);
00217 
00222     int                      getMaxFileID();
00223 
00228     int                      getNumElectrons();
00229 
00234     void                     moveCenterOfMass(vector3d* center);
00235 
00240     void                     centerOfMass(vector3d* center);
00241 
00246     void                     centerOfMass(double center[3]);
00247 
00252     void                     setCoordinates(std::vector< vector3d > &coords);
00253 
00258     void                     getCoordinates(double coords[][3]);
00259 
00264     int                      getCoordinates(double coords[]);
00265 
00270     void                     getCoordinates(std::vector< vector3d > &coords);
00271 
00276     int*                     getHeavyAtomIndices();
00277 
00278     //
00279     //   \brief Get all atomic symbols
00280     //   \param symbols char array of symbols
00281     //
00282     //void                     getAtomSymbols(char symbols[][2]);
00283 
00288     char*                    getAtomSymbols();
00289 
00294     void                     getRes1LSymbols(char codes1L[]);
00295 
00300     void                     getRes3LSymbols(char codes3L[]);
00301 
00306     char*                    getHeavyAtomSymbols();
00307 
00312     char*                    getAtomTypes();
00313 
00318     char*                    getHeavyAtomTypes();
00319 
00324     int*                     getAtomKinds();
00325 
00330     void                     getAtomCharges(double charges[]);
00331 
00336     int                      getFormalCharge();
00337 
00342     double                   getStdCharge();
00343 
00348     void                     setTotalCharge(int c);
00349 
00354     int                      getTotalCharge();
00355 
00360     double                      getMolecularWeight();
00361 
00362     //---------------------------//
00363     // - SUBMOLECULE FUNCTIONS - //
00364     //---------------------------//
00365 
00370     virtual submolecule*     addSubMolecule();
00371 
00378     submolecule*             getSubMolecule(int id);
00379 
00387     submolecule*             getSubMolecule(int id, bool smolIndex, bool fileId);
00388 
00394     submolecule*             getSubMolecule(std::string name);
00395 
00400     virtual std::vector<submolecule*> getSubMoleculeList();
00401 
00407     std::vector<submolecule*> getSubMoleculeList(std::string name);
00408 
00415     std::vector<submolecule*> getSubMoleculeList(std::string name, int resId);
00416 
00421     std::vector<submolecule*> getSubMoleculeList(int resId);
00422 
00427     int                      getNumSubMolecules();
00428 
00429     //--------------------//
00430     // - ATOM FUNCTIONS - //
00431     //--------------------//
00432 
00437     std::vector<atom*>       getAtomList();
00438 
00443     std::vector<atom*>       getHeavyAtomList();
00444 
00453     atom*                    getAtom(int number, bool atomIndex = true,
00454                                                  bool fileId = false,
00455                                                  bool atomColIndex = false);
00456 
00462     atom*                    getAtom(stdAtom* pStdAtom);
00463 
00469     atom*                    getAtom(std::string name);
00470 
00475     void                     delAtom(atom* a);
00476 
00477     //----------//
00478     // - BOND - //
00479     //----------//
00480 
00491     virtual Bond*            addBond(atom* at1, atom* at2,
00492                                      const int& type = 0,
00493                                      const int& stereo = 0,
00494                                      const int& topology = 0,
00495                                      const double& size = 0.0);
00496 
00503     Bond*                    getBond(atom* at1, atom* at2);
00504 
00509     int                      getBonds(int bonds[]);
00510 
00515     int                      getBondParams(double bondParams[]);
00516 
00523     bool                     hasBond(atom* at1, atom* at2);
00524 
00529     int                      numBonds();
00530 
00536     void                     delBond(atom* at1,atom* at2);
00537 
00543     void                     add13Bond(atom* at1, atom* at2);
00544 
00551     bool                     has13Bond(atom* at1, atom* at2);
00552 
00558     void                     add14Bond(atom* at1, atom* at2);
00559 
00566     bool                     has14Bond(atom* at1, atom* at2);
00567 
00572     std::map<int, Bond*>     getBondMap();
00573 
00574     //-----------//
00575     // - ANGLE - //
00576     //-----------//
00577 
00586     Angle*                   addAngle(atom* at1,atom* at2,atom* at3,
00587                                       const double& ang);
00588 
00596     bool                     hasAngle(atom* at1,atom* at2,atom* at3);
00597 
00605     Angle*                   getAngle(atom* at1,atom* at2,atom* at3);
00606 
00613     void                     delAngle(atom* at1,atom* at2,atom* at3);
00614 
00619     std::map<ULONG_KIND, Angle*>    getAngleMap();
00620 
00625     int                      numAngles();
00626 
00631     int                      getAngles(int angles[]);
00632 
00637     int                      getAngleParams(double angleParams[]);
00638 
00639     //-------------//
00640     // - TORSION - //
00641     //-------------//
00642 
00652     Torsion*                 addTorsion(atom* at1,atom* at2,
00653                                         atom* at3,atom* at4,
00654                                         const double& tor);
00655 
00663     void                     delTorsion(atom* at1,atom* at2,
00664                                         atom* at3,atom* at4);
00665 
00674     bool                     hasTorsion(atom* at1,atom* at2,
00675                                         atom* at3,atom* at4);
00676 
00685     Torsion*                 getTorsion(atom* at1,atom* at2,
00686                                         atom* at3,atom* at4);
00687 
00696     void                     setTorsion(atom* at1,atom* at2,
00697                                         atom* at3,atom* at4,
00698                                         double t);
00699 
00704     std::map<ULONG_KIND, Torsion*>  getTorsionMap();
00705 
00710     int                      numTorsions();
00711 
00717     int                      getTorsions(int torsions[]);
00718 
00723     int                      getNumMMTorsions();
00724 
00731     int                      getMMTorsions(int torsions[], double torsionParams[]);
00732 
00733 
00734     //--------------//
00735     // - IMPROPER - //
00736     //--------------//
00737 
00747     Improper*                addImproper(atom* at1,atom* at2,atom* at3,atom* at4,const double& imp);
00748 
00756     void                     delImproper(atom* at1,atom* at2,atom* at3,atom* at4);
00757 
00766     bool                     hasImproper(atom* at1,atom* at2,atom* at3,atom* at4);
00767 
00772     std::map<int, Improper*> getImproperMap();
00773 
00778     int                      numImpropers();
00779 
00784     int                      getImpropers(int impropers[]);
00785 
00790     int                      getNumMMImpropers();
00791 
00798     int                      getMMImpropers(int impropers[], double improperParams[]);
00799 
00800     //-----------------------------//
00801     // - NON BONDED INTERACTIONS - //
00802     //-----------------------------//
00803 
00807     int                      getNumMMnonBondedPairs(double cutoff);
00808 
00812     int                      getMMnonBondedPairs(int nonBonded[], int nonBondedPtrs[], double nonBondedParams[],
00813                                                  int nonBonded14Ptrs[], double cutoff);
00814 
00815     //----------------//
00816     // - MM CHARGES - //
00817     //----------------//
00818 
00823     int                      getMMCharges(double charges[]);
00824 
00825     //-----------------//
00826     // - MM RESIDUES - //
00827     //-----------------//
00828 
00833     int                      getMMResidues(int residues[]);
00834 
00835     //-----------//
00836     // - RINGS - //
00837     //-----------//
00838 
00840     void                     determineRings();
00841 
00843     void                     kekulizeRings();
00844 
00846     std::string              getRingInfo();
00847 
00852     void                     addRing(std::vector<atom*> r);
00853 
00858     std::vector<ring*>       getRings();
00859 
00864     ring*                    getLastAddedRing();
00865 
00866     //----------------//
00867     // - CONFORMERS - //
00868     //----------------//
00869 
00882     std::vector<Bond*>       getRotatableBonds();
00883 
00888     void                     setRotatableTorsions(std::vector<Torsion*> tors);
00889 
00894     std::vector<Torsion*>    getRotatableTorsions();
00895 
00900     std::vector<Torsion*>    setupConformers();
00901 
00907     std::vector<Torsion*>    setupConformers(std::vector<atom*> frozenAtoms);
00908 
00914     std::vector<Torsion*>    setupConformers(std::vector<Bond*> rotBonds);
00915 
00921     std::vector<Torsion*>    setupConformers(std::vector<Torsion*> rotTorsions);
00922 
00928     void                     addConformer(std::string name, std::vector<double> t);
00929 
00935     void                     updateConformer(std::string name, std::vector<double> t);
00936 
00941     void                     delConformer(std::string name);
00942 
00948     conformer*               getConformer(std::string name);
00949 
00954     conformers*              getConformers();
00955 
00960     std::vector<std::string> getConformerNames();
00961 
00962     //------------------//
00963     // - FINGERPRINTS - //
00964     //------------------//
00965 
00969     void                     generateSimpleFP();
00970 
00975     std::vector<unsigned int>getSimpleFP();
00976 
00977     /*
00978        \brief Generate fragment fingerprint
00979     */
00980     //void                     generateFragmentFP();
00981 
00986     std::string              getFragmentFP();
00987 
00988     //------------------------//
00989     // - HYDROPHOBIC GROUPS - //
00990     //------------------------//
00991 
00996     int determineHydrophobicGroups();
00997 
01003     int addHydrophobicGroup(std::vector<atom*> ats);
01004 
01009     std::vector<hydrophobe*> getHydrophobicGroups();
01010 
01011     //-----------------------//
01012     // - FUNCTIONAL GROUPS - //
01013     //-----------------------//
01014 
01020     int                      determineFunctionalGroups(stdLibrary* pStdLib);
01021 
01026     void                     addFunctionalGroup(funcGroup* fg);
01027 
01035     void                     addFunctionalGroup(int fragAtoms, stdFrag* pStdFrag,
01036                                                 int molAtoms, std::vector<int> subGraph);
01037 
01043     void                     delFunctionalGroup(funcGroup* fG, int i);
01044 
01049     std::vector<funcGroup*>  getFunctionalGroups();
01050 
01056     funcGroup*               getFunctionalGroup(atom* pAt);
01057 
01062     int                      generateAdjMatrix();
01063 
01068     int                      generateHeavyAdjMatrix();
01069 
01074     int*                     getAdjMatrix();
01075 
01080     int*                     getHeavyAdjMatrix();
01081 
01086     int                      getAdjMatrixSize();
01087 
01092     int                      getHeavyAdjMatrixSize();
01093 
01098     int                      generateFeatureDistMatrix();
01099 
01104     int                      generateFeatureDistMatrix(std::vector< vector3d >
01105                                                        coords);
01106 
01111     double*                  getFeatureDistMatrix();
01112 
01117     std::vector<std::string> getFeatureGroups();
01118 
01123     std::vector<std::string> getFeatureLabels();
01124 
01129     std::vector<vector3d>    getFeatureCoordinates();
01130 
01139     int                      findPharmacophore(molecule* pMol,
01140                              std::vector<std::vector<unsigned int> > &mcp,
01141                              std::vector<vector3d> &mcpCoords,
01142                              double distMax = 0.5);
01143 
01151     int                      findPharmacophore(molecule* pMol,
01152                              std::vector<clique*> &cliqueList,
01153                              double distMax = 0.5);
01154 
01155 
01156     //----------------//
01157     // - PROPERTIES - //
01158     //----------------//
01159 
01165     void                     addProperty(const std::string& name,
01166                                          const std::string& value);
01167 
01173     std::string              getProperty(const std::string& name);
01174 
01179     void                     delProperty(const std::string& name);
01180 
01185     std::map<std::string, std::string>  getProperties();
01186 
01192     bool                     hasProperty(const std::string& name);
01193 
01194     /*
01195       \brief Set protonation state of molecule
01196 
01197       deprotonate carboxylic, phosphonic, and sulfonic acids
01198       protonates quaternary nitrogens, amidine and guanidine moieties
01199     */
01200     void                     setInSolution();
01201 
01202     //-----------------//
01203     // -  HYDROGENS  - //
01204     //-----------------//
01205 
01209     void                     addHydrogens();
01210 
01214      void                    removeHydrogens();
01215 
01216     //----------//
01217     // - MISC - //
01218     //----------//
01219 
01223     void                     determineValences();
01224 
01230     void                     determineHybridizations(int method, const std::string f);
01231 
01232     //-----------------//
01233     // -    FLAGS    - //
01234     //-----------------//
01235 
01237     std::string inFileType;
01238 
01240     bool bBondsAssigned;
01241 
01243     bool bDisulfideBondsAssigned;
01244 
01246     bool bAnglesAssigned;
01247 
01249     bool bTorsionsAssigned;
01250 
01252     bool bImpropersAssigned;
01253 
01255     bool bBondTypes1Assigned;
01256 
01258     bool bBondTypes2Assigned;
01259 
01261     bool bMMAtomTypesAssigned;
01262 
01264     bool bAtomValencesAssigned;
01265 
01267     bool bAtomHybridizationsAssigned;
01268 
01270     bool bRingsAssigned;
01271 
01273     bool bRingsKekulized;
01274 
01276     bool bInSolution;
01277 
01279     bool bHydrogensAdded;
01280 
01282     bool bError;
01283 
01284 protected:
01285 
01286     //-------------------//
01287     // - MOLECULE DATA - //
01288     //-------------------//
01289 
01291     std::string              itsName;
01292 
01294     std::string              itsChain;
01295 
01303     int                      itsKind;
01304 
01306     int                      itsMolId;
01307 
01309     int                      itsNumAtoms;
01310 
01312     int                      itsNumBonds;
01313 
01315     int                      itsSMolIndex;
01316 
01318     int                      itsAtomIndex;
01319 
01321     int                      itsMaxFileID;
01322 
01324     int                      totalCharge;
01325 
01327     vector3d*                pCenterMass;
01328 
01329     //-----------------------//
01330     // - BACKBONE POINTERS - //
01331     //-----------------------//
01332 
01334     collection*              pParent;
01335 
01337     submolecule*             pSubMolecule;
01338 
01340     atom*                    pAtom;
01341 
01343     Bond*                    pBond;
01344 
01346     parameters*              pParameters;
01347 
01349     bondParam*               pBondParam;
01350 
01352     angleParam*              pAngleParam;
01353 
01355     torsionParam*            pTorsionParam;
01356 
01358     hBondParam*              pHBondParam;
01359 
01361     LJ612Param*              pLJ612Param;
01362 
01364     LJ612SE*                 pLJ612SE;
01365 
01367     std::vector<torsionParam*> torsionParamList;
01368 
01370     typedef std::vector<torsionParam*>::iterator torsionParamIterator;
01371 
01373     std::vector<improperParam*> improperParamList;
01374 
01376     typedef std::vector<improperParam*>::iterator improperParamIterator;
01377 
01379     improperParam*           pImproperParam;
01380 
01382     Angle*                   pAngle;
01383 
01385     Torsion*                 pTorsion;
01386 
01388     Improper*                pImproper;
01389 
01391     rings*                   pRings;
01392 
01394     ring*                    pRing;
01395 
01397     conformers*              pConformers;
01398 
01400     conformer*               pConformer;
01401 
01403     protonate*               pProtonate;
01404 
01406     fingerPrint*             pFingerPrint;
01407 
01409     functionalize*           pFunctionalize;
01410 
01412     hydrophobize*            pHydrophobize;
01413 
01415     hydrophobe*              pHydrophobe;
01416 
01418     pharmacophore*           pPharmacophore;
01419 
01420     //----------------------//
01421     // - VECTOR ITERATORS - //
01422     //----------------------//
01423 
01425     typedef std::vector<submolecule*>::iterator  sMolIterator;
01426 
01428     typedef std::vector<atom*>::iterator         AtomIterator;
01429 
01431     typedef std::vector<Bond*>::iterator         BondIterator;
01432 
01434     typedef std::vector<conformer*>::iterator    ConformerIterator;
01435 
01437     typedef std::vector<ring*>::iterator         RingIterator;
01438 
01440     typedef std::vector<funcGroup*>::iterator    FuncGroupIterator;
01441 
01443     typedef std::vector<hydrophobe*>::iterator   HydrophobeIterator;
01444 
01445     //-------------------//
01446     // - MAP ITERATORS - //
01447     //-------------------//
01448 
01450     typedef std::map<int, Bond*>::iterator       BondMapIterator;
01451 
01453     typedef std::map<ULONG_KIND, Angle*>::iterator      AngleMapIterator;
01454 
01456     typedef std::map<ULONG_KIND, Torsion*>::iterator    TorsionMapIterator;
01457 
01459     typedef std::map<int, Improper*>::iterator   ImproperMapIterator;
01460 
01462     typedef std::map<std::string, std::string>::iterator PropertyMapIterator;
01463 
01464     //-----------------------//
01465     // - VECTOR CONTAINERS - //
01466     //-----------------------//
01467 
01469     std::vector<submolecule*>                    itsSubMoleculeList;
01470 
01472     std::vector<atom*>                           itsAtomList;
01473 
01475     std::vector<atom*>                           itsHeavyAtomList;
01476 
01478     std::vector<int>                             itsBond13List;
01479 
01481     std::vector<int>                             itsBond14List;
01482 
01484     std::vector<Bond*>                           itsRotatableBonds;
01485 
01487     std::vector<Torsion*>                        itsRotatableTorsions;
01488 
01490     std::vector<ring*>                           itsRings;
01491 
01493     std::vector<funcGroup*>                      itsFuncGroups;
01494 
01496     std::vector<hydrophobe*>                     itsHydrophobes;
01497 
01499     std::vector<conformer*>                      itsConformers;
01500 
01502     std::vector<unsigned int>                    itsSimpleFP;
01503 
01505     std::string                                  itsFragmentFP;
01506 
01508     //std::vector<unsigned int>                    its1DFP;
01509 
01511     int                                          *heavyAtomIndices;
01512 
01514     int                                          *adjMatrix;
01515 
01517     int                                          *heavyAdjMatrix;
01518 
01520     int                                          adjMatrixSize;
01521 
01523     int                                          heavyAdjMatrixSize;
01524 
01526     double                                       *featureDistMatrix;
01527 
01529     int                                          featureDistMatrixSize;
01530 
01532     std::vector<std::string>                     featureGroups;
01533 
01535     std::vector<std::string>                     featureLabels;
01536 
01538     std::vector<vector3d>                        featureCoordinates;
01539 
01541     char                                         *atomSymbols;
01542 
01544     char                                         *heavyAtomSymbols;
01545 
01547     char                                         *atomTypes;
01548 
01550     char                                         *heavyAtomTypes;
01551 
01553     int                                          *atomKinds;
01554 
01555     //--------------------//
01556     // - MAP CONTAINERS - //
01557     //--------------------//
01558 
01560     std::map<int, Bond*>                         itsBondMap;
01561 
01563     std::map<ULONG_KIND, Angle*>                 itsAngleMap;
01564 
01566     std::map<ULONG_KIND, Torsion*>               itsTorsionMap;
01567 
01569     std::map<int, Improper*>                     itsImproperMap;
01570 
01572     std::map<std::string, std::string>           itsPropertiesMap;
01573 };
01574 
01575 } // MTKpp namespace
01576 
01577 #endif // MOLECULE_H
01578 

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