PResidue.h

Go to the documentation of this file.
00001 /*
00002     LoopTK: Protein Loop Kinematic Toolkit
00003     Copyright (C) 2007 Stanford University
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License along
00016     with this program; if not, write to the Free Software Foundation, Inc.,
00017     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018 */
00019 
00020 #ifndef __P_RESIDUE_H
00021 #define __P_RESIDUE_H
00022 
00023 #include "PEnums.h"
00024 #include "PResidueShell.h"
00025 #include "PResidueSpec.h"
00026 
00034 class PResidue {
00035  public:
00036   friend class PChain;
00037   friend struct DOFCacher;
00038 
00048   PResidue(PChain *loop, const string &shellName);
00049 
00059   PResidue(PChain *loop, const string &shellName, PResidueSpec &spec); 
00060 
00070   PResidue(PChain *loop, const string &shellName, PResidue *toConnect);
00071 
00081   PResidue(PChain *loop, const string &shellName, PResidueSpec &spec, PResidue *toConnect);
00082 
00083   ~PResidue();
00084 
00091   PResidue *NextResidue() const { return m_nextRes; }
00092 
00099   PResidue *PreviousResidue() const { return m_prevRes; }
00100 
00105   PBond *getDOF(const string &blockType, const string &atomId1, const string &atomId2);
00106 
00107 
00116   const ID_To_DOF_Map *getDOFsForBlock(const string &blockType);
00117 
00122   void RandomizeDOFs(const string &blockType, PChain *rootChain);
00123   void RandomizeDOFs(const string &blockType);
00124 
00125   void DetachBlocks(const string &blockType, const string &blockToDetachFrom);
00126   void ReattachBlocks(const string &blockType);
00127   void ReattachAllBlocks();
00128 
00132   PBond *getBond(const string &id1, const string &id2);
00133 
00139   PChain* getChain() const;
00140 
00146   string getResourceName() const { return m_shell->getName(); }
00147 
00151    string getName() const { return m_customName; }
00152 
00156    void setName(string name) { m_customName = name; }
00157 
00162   PBlock *getHeadBlock() { return m_blocks[m_shell->getHeadId()]; }
00163 
00168   PBlock *getTailBlock() { return m_blocks[m_shell->getTailId()]; }
00169   
00175   vector<PAtom *> *getAtoms() { return &m_atomCache; }
00176 
00182   HASH_MAP_STR(PAtom *) *getAtomMap() { return &m_atomMap; }
00183 
00190   PAtom *getAtom(const string &id) { 
00191         if(m_atomMap.find(id)==m_atomMap.end()) return NULL;
00192         else
00193                 return m_atomMap[id]; 
00194   }
00195 
00201   Vector3 getAtomPosition(const string &id) { return getAtom(id)->getPos(); }
00202 
00208   bool InStaticCollision() const;
00209 
00215   bool InSelfCollision() const;
00216 
00222   bool InAnyCollision() const;
00223   
00230   pair<PAtom *, PAtom *> FindStaticCollision() const;
00231 
00238   pair<PAtom *, PAtom *> FindSelfCollision() const;
00239 
00246   pair<PAtom *, PAtom *> FindAnyCollision() const;
00247 
00253   AtomCollisions* getAllCollidingStatic() const;
00254 
00260   AtomCollisions* getAllCollidingSelf() const;
00261 
00267   AtomCollisions* getAllCollidingEither() const;
00268 
00273   const PSpaceManager* getSpaceManager() const;
00274 
00280   PResidueSpec getSpec();
00281 
00286   void setPositions(const PAtomPositionsSpec &spec);
00287 
00291   int getPdbId() const { return m_pdb_id; }
00292 
00293 
00297   void inactivate();
00298 
00302   void activate();
00303 
00304 
00305  private:
00306 
00307   void EstablishLink(PResidue *prior);
00308   //these two functions are called by PChain:
00309   void SetChain(PChain *loop) { assert(loop != NULL); m_loop = loop; }
00310   //caches atoms, block types
00311   void finalize();
00312   void ChangeBlockState(const string &blockType, bool status);
00313 
00314   //for use by PChain: //should be called after finalize is called
00315   void CacheDOF(DOF_Cache &DOFcache);
00316   void CacheAtoms(Atom_Cache &AtomCache);
00317   void DestroyBonds();
00318 
00319   void ConstructAroundHead(PChain *loop);
00320   void BuildWithPositions(PChain *loop, const PResidueSpec &spec);
00321   void AddAuxInfo(PResidueSpec &spec);
00322 
00323   // Returns true iff all of shell's atoms are defined in spec.
00324   bool IsFullyDefined(const string &shellName, const PResidueSpec &spec);
00325 
00326 
00327   // collision detection helper methods
00328   bool InCollision(CollisionType type) const;
00329   pair<PAtom *, PAtom *> FindCollision(CollisionType type) const;
00330   AtomCollisions* getAllColliding(CollisionType type) const;
00331 
00332   //for use by DOF_Cacher
00333   void CacheSingleDOF(const string &blockType,PBond *bond);
00334 
00336   PResidueShell *m_shell;
00337   HASH_MAP_STR(PBlock *) m_blocks;
00338   PChain *m_loop;
00339   string m_customName;
00340 
00341   // Index of this residue in a PDB file
00342   int m_pdb_id;
00343   
00344   // Atoms in this residue
00345   HASH_MAP_STR(PAtom *) m_atomMap;
00346 
00347   // Next and previous residues in the chain
00348   PResidue *m_nextRes, *m_prevRes;
00349 
00350   //caches:
00351   //turning blocks on and off should update this cache (or should it?)
00352   vector<PAtom *> m_atomCache;
00353   typedef HASH_MAP_STR(vector<PBlock *>) BlockTypeCache;
00354   BlockTypeCache m_blockTypeCache; 
00355   HASH_MAP_STR(HASH_MAP_STRPAIR_OR(PBond *)) m_dofs;
00356   
00357 };
00358 
00359 #endif  // __P_RESIDUE_H

Generated on Wed May 16 20:22:08 2007 for LoopTK: Protein Loop Kinematic Toolkit by  doxygen 1.5.1