PHydrogenBondTracker.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 PHYDRO_BOND_TRACKER
00021 #define PHYDRO_BOND_TRACKER
00022 
00023 #include "PBasic.h"
00024 #include "PConstants.h"
00025 #include <set>
00026 
00027 
00028 
00029 
00030 //should i make this a global float that can be changed by the user through some static function?
00031 #define HYDRO_BOND_CUTOFF 4.5
00032 
00033 
00034 typedef pair<PAtom *, PAtom *> PHydrogenBond;
00035 
00036 struct HydroBondCompare {
00037   //first atom will be N, second will be O
00038   PHydrogenBond ConvertHB(PHydrogenBond hb) const {
00039     PHydrogenBond ret;
00040     if (hb.first->getName()==PID::N) {
00041       ret.first = hb.first;
00042       ret.second = hb.second;
00043   } else {
00044       ret.first = hb.second;
00045       ret.second = hb.first;
00046     }
00047     return ret;
00048   }
00049   
00050   bool operator() (const PHydrogenBond &hb1, const PHydrogenBond &hb2) const {
00051     PHydrogenBond comp1 = ConvertHB(hb1);
00052     PHydrogenBond comp2 = ConvertHB(hb2);
00053     if (comp1.first==comp2.first) {
00054       if (comp1.second==comp2.second) return false;
00055       else
00056       return comp1.second<comp2.second;
00057     } else {
00058       return comp1.first<comp2.first;
00059     }  
00060   }
00061 };
00062 
00063 typedef set<PHydrogenBond,HydroBondCompare> HydroBondSet;
00064 
00065 class PHydrogenBondTracker {
00066  public:
00067   virtual HydroBondSet& GetHydrogenBonds()=0;
00068   static PHydrogenBondTracker *Create(PProtein *toTrack);
00069 };
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 
00080 
00081 
00082 class PHydrogenBondTrackerObject:public PRotateEventHandler, public PHydrogenBondTracker {
00083  public:
00084   friend class PHydrogenBondTracker;
00085   ~PHydrogenBondTrackerObject();
00086   HydroBondSet& GetHydrogenBonds();
00087   void HandleRotation(PChain *p,ChainMove justExecuted);
00088  private:
00089   PHydrogenBondTrackerObject(PProtein *toTrack);
00090   void GenerateAtomsToCheck();
00091   void FindHydrogenBonds();
00092   PProtein *m_trackedProtein;
00093   HydroBondSet m_hydroBonds;
00094   list<PAtom *> m_atomsToCheck;
00095   bool m_mustRegenerateBonds;
00096 };
00097 
00098 
00099 
00100 
00101 
00102 #endif

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