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