| 1 | /* | 
|---|
| 2 | * PdbAtomInfoContainer.hpp | 
|---|
| 3 | * | 
|---|
| 4 | *  Created on: Dec 4, 2010 | 
|---|
| 5 | *      Author: heber | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | #ifndef PDBATOMINFOCONTAINER_HPP_ | 
|---|
| 9 | #define PDBATOMINFOCONTAINER_HPP_ | 
|---|
| 10 |  | 
|---|
| 11 | // include config.h | 
|---|
| 12 | #ifdef HAVE_CONFIG_H | 
|---|
| 13 | #include <config.h> | 
|---|
| 14 | #endif | 
|---|
| 15 |  | 
|---|
| 16 |  | 
|---|
| 17 | #include "PdbKey.hpp" | 
|---|
| 18 |  | 
|---|
| 19 | class PdbParser; | 
|---|
| 20 | class Vector; | 
|---|
| 21 |  | 
|---|
| 22 | #include <string> | 
|---|
| 23 | #include <typeinfo> | 
|---|
| 24 |  | 
|---|
| 25 | /** | 
|---|
| 26 | * Holds tremolo-specific information which is not store in the atom class. | 
|---|
| 27 | */ | 
|---|
| 28 | class PdbAtomInfoContainer { | 
|---|
| 29 | friend class PdbParser; | 
|---|
| 30 | public: | 
|---|
| 31 | PdbAtomInfoContainer(); | 
|---|
| 32 | ~PdbAtomInfoContainer(); | 
|---|
| 33 |  | 
|---|
| 34 | // getter and setter | 
|---|
| 35 | template <class T> T get(const PdbKey::PdbDataKey key) const  { | 
|---|
| 36 | switch (key) { | 
|---|
| 37 | default : | 
|---|
| 38 | std::cout << "Unknown key or not representable as " << typeid(T).name() << ": " << key << std::endl; | 
|---|
| 39 | break; | 
|---|
| 40 | } | 
|---|
| 41 | return (T)NULL; | 
|---|
| 42 | } | 
|---|
| 43 | void set(const PdbKey::PdbDataKey key, std::string value); | 
|---|
| 44 |  | 
|---|
| 45 | /** Scans a value from a short string and checks whether its empty. | 
|---|
| 46 | * | 
|---|
| 47 | * @param value value to set | 
|---|
| 48 | * @param _piece short string | 
|---|
| 49 | */ | 
|---|
| 50 | template <class T> static void ScanKey(T& value, std::string _piece) | 
|---|
| 51 | { | 
|---|
| 52 | ConvertTo<T> toValue; | 
|---|
| 53 | // scan all empty chars ' ' and skip | 
|---|
| 54 | std::string::iterator iter = _piece.begin(); | 
|---|
| 55 | for (;iter != _piece.end();++iter) | 
|---|
| 56 | if ((*iter != ' ') && (*iter != '\t')) | 
|---|
| 57 | break; | 
|---|
| 58 | // only set if there is something contained in the string | 
|---|
| 59 | if (iter != _piece.end()) { | 
|---|
| 60 | _piece.erase(_piece.begin(), iter); | 
|---|
| 61 | value = toValue(_piece); | 
|---|
| 62 | } | 
|---|
| 63 | } | 
|---|
| 64 |  | 
|---|
| 65 | const std::string& getDataKey(PdbKey::PdbDataKey key) const; | 
|---|
| 66 |  | 
|---|
| 67 | private: | 
|---|
| 68 |  | 
|---|
| 69 | static void fillknownDataKeys(); | 
|---|
| 70 | static void clearknownDataKeys(); | 
|---|
| 71 |  | 
|---|
| 72 | typedef std::map<PdbKey::PdbDataKey, std::string> knownDataKeysMap; | 
|---|
| 73 | static knownDataKeysMap knownDataKeys; | 
|---|
| 74 | static bool knownDataKeys_Filled; | 
|---|
| 75 |  | 
|---|
| 76 | std::string token; | 
|---|
| 77 | int serial; | 
|---|
| 78 | std::string name; | 
|---|
| 79 | char altLoc; | 
|---|
| 80 | std::string resName; | 
|---|
| 81 | char chainID; | 
|---|
| 82 | int resSeq; | 
|---|
| 83 | char iCode; | 
|---|
| 84 | Vector XYZ; | 
|---|
| 85 | float occupancy; | 
|---|
| 86 | float tempFactor; | 
|---|
| 87 | std::string element; | 
|---|
| 88 | int charge; | 
|---|
| 89 | }; | 
|---|
| 90 |  | 
|---|
| 91 | std::ostream& operator<<(std::ostream &ost, const PdbAtomInfoContainer& m); | 
|---|
| 92 |  | 
|---|
| 93 | template <> | 
|---|
| 94 | std::string PdbAtomInfoContainer::get<std::string>(const PdbKey::PdbDataKey key) const; | 
|---|
| 95 | template <> | 
|---|
| 96 | int PdbAtomInfoContainer::get<int>(const PdbKey::PdbDataKey key) const; | 
|---|
| 97 | template <> | 
|---|
| 98 | double PdbAtomInfoContainer::get<double>(const PdbKey::PdbDataKey key) const; | 
|---|
| 99 |  | 
|---|
| 100 | #endif /* PDBATOMINFOCONTAINER_HPP_ */ | 
|---|