PResources.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 PRESOURCES_H
00021 #define PRESOURCES_H
00022 
00023 #include "PBasic.h"
00024 #include "PHashing.h"
00025 
00026 //first block is block that's already defined, second is block to define
00027 typedef HASH_MAP_STRPAIR_OR(PBlockConnection *) BlockConnectionData;
00028 
00029 typedef HASH_MAP_STR(PAtomShell *) AtomShellData;
00030 typedef HASH_MAP_STR(PBlockShell *) BlockShellData;
00031 typedef HASH_MAP_STR(PResidueShell *) ResidueShellData;
00032 //@package Resource Management
00041 class PResources {
00042 
00043  friend class PInit;
00044 
00045  public:
00046 
00053   static void FreeResources();
00054 
00060   static PAtomShell *GetAtomShell(const string &name);
00061 
00067   static PBlockShell *GetBlockShell(const string &name);
00068 
00075   static PBlockConnection *GetBlockConnection(const string &definedName, const string &toDefineName); 
00076 
00082   static PResidueShell *GetResidueShell(const string &name);
00083 
00089   static Real GetEpsilonValue(const StringPair &elemPair);
00090 
00096   static string GetAtomIDMapping(const string &id, const string &resName);
00097 
00103   static vector<string> GetChiIndex(const string &resName, int chiIndex);
00104 
00109   static vector<vector<Real> > GetRotamer(const string &resName);
00110 
00115   static int GetRotamerSize(const string &resName);
00116 
00122   static bool ContainsAtomShell(const string &name) {
00123     return(m_atoms.find(name) != m_atoms.end());
00124   }
00125 
00131   static bool ContainsBlockShell(const string &name) {
00132     return(m_blocks.find(name) != m_blocks.end());
00133   }
00134 
00141   static bool ContainsBlockConnection(const string &definedName, const string &toDefineName) {
00142     return(m_blockConnections.find(make_pair(definedName, toDefineName)) != m_blockConnections.end());
00143   }
00144 
00150   static bool ContainsResidueShell(const string &name) {
00151     return(m_residues.find(name) != m_residues.end());
00152   }
00153 
00160   static bool ContainsAtomIDMapping(const string &id, const string &resName) {
00161     return(m_atomIDs.find(make_pair(resName, id)) != m_atomIDs.end());
00162   }
00163 
00170   static bool ContainsChiIndex(const string &resName, int chiIndex) {
00171     return(m_chiIndices.find(make_pair(resName, PUtilities::toStr(chiIndex))) != m_chiIndices.end());
00172   }
00173 
00180   static bool ContainsRotamer(const string &resName) {
00181     return(m_Rotamers.find(resName) != m_Rotamers.end());
00182   }
00183 
00189   static int numAtoms() { return m_atoms.size(); }
00190 
00196   static int numBlocks() { return m_blocks.size(); }
00197 
00203   static int numConnections() { return m_blockConnections.size(); }
00204 
00210   static int numResidues() { return m_residues.size(); }
00211 
00218   static int numChiIndices(const string &resName);
00219 
00225   static vector<string> getAtomNames() { return m_atomNames; }
00226 
00232   static vector<string> getBlockNames() { return m_blockNames; }
00233 
00239   static vector<StringPair> getConnectionNames() { return m_connectionNames; }
00240 
00246   static vector<string> getResidueNames() { return m_residueNames; }
00247  
00248  private:
00249   static void ResourceError(const string &id);
00250 
00251   static AtomShellData m_atoms;
00252   static BlockConnectionData m_blockConnections;
00253   static BlockShellData m_blocks;
00254   static ResidueShellData m_residues;
00255 
00256   static HASH_MAP_STRPAIR_EX(string) m_atomIDs;
00257   static HASH_MAP_STRPAIR_EX(vector<string>) m_chiIndices;
00258   static HASH_MAP_STRPAIR_OR(Real) m_epsilonVals;
00259   static HASH_MAP_STR(vector<vector<Real> >) m_Rotamers;
00260 
00261   static vector<string> m_atomNames, m_blockNames, m_residueNames;
00262   static vector<StringPair> m_connectionNames;
00263   
00264   static void AddAtomShell(PAtomShell *atomShell);
00265   static void AddBlockShell(PBlockShell *blockShell);
00266   static void AddBlockConnection(PBlockConnection *blockConnection);
00267   static void AddResidueShell(PResidueShell *resShell);
00268 
00269   static void AddAtomIDMapping(const string &resName, const string &fromID, const string &toID);
00270   static void AddChiIndex(const string &resName, int chiIndex, const vector<string> &bondedAtoms);
00271   static void AddEpsilonValue(const StringPair &atomTypes, Real val);
00272   static void AddRotamer(const string &resName, const vector<string> &chiDegrees);
00273 
00274   template <typename T>
00275   static void FreeResMap(T& resMap) {
00276     for(typename T::iterator it = resMap.begin(); it != resMap.end(); ++it) {
00277       delete it->second;
00278     }
00279 
00280     resMap.clear();
00281   }
00282 
00283 };
00284 
00285 #endif

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