| [4fbca9c] | 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 |  | 
|---|
| [56f73b] | 11 | // include config.h | 
|---|
|  | 12 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 13 | #include <config.h> | 
|---|
|  | 14 | #endif | 
|---|
|  | 15 |  | 
|---|
| [765f16] | 16 | #include <string> | 
|---|
|  | 17 | #include <typeinfo> | 
|---|
| [56f73b] | 18 |  | 
|---|
| [765f16] | 19 | #include "LinearAlgebra/Vector.hpp" | 
|---|
| [4fbca9c] | 20 | #include "PdbKey.hpp" | 
|---|
|  | 21 |  | 
|---|
| [765f16] | 22 | #include "ParserTypes.hpp" | 
|---|
| [16462f] | 23 |  | 
|---|
| [765f16] | 24 | //template <class T> class FormatParser; | 
|---|
|  | 25 | //template<> class FormatParser< pdb >; | 
|---|
| [4fbca9c] | 26 |  | 
|---|
|  | 27 | /** | 
|---|
|  | 28 | * Holds tremolo-specific information which is not store in the atom class. | 
|---|
|  | 29 | */ | 
|---|
|  | 30 | class PdbAtomInfoContainer { | 
|---|
| [765f16] | 31 | //!> Grant all FormatParser specializations access, otherwise we have to fully define FormatParser<pdb> | 
|---|
|  | 32 | template<enum ParserTypes> friend class FormatParser; | 
|---|
| [4fbca9c] | 33 | public: | 
|---|
|  | 34 | PdbAtomInfoContainer(); | 
|---|
|  | 35 | ~PdbAtomInfoContainer(); | 
|---|
|  | 36 |  | 
|---|
|  | 37 | // getter and setter | 
|---|
| [16462f] | 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 | } | 
|---|
| [4fbca9c] | 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 |  | 
|---|
| [9dba5f] | 68 | const std::string& getDataKey(PdbKey::PdbDataKey key) const; | 
|---|
|  | 69 |  | 
|---|
| [4fbca9c] | 70 | private: | 
|---|
| [9dba5f] | 71 |  | 
|---|
| [873037] | 72 | static void fillknownDataKeys(); | 
|---|
|  | 73 | static void clearknownDataKeys(); | 
|---|
| [9dba5f] | 74 |  | 
|---|
|  | 75 | typedef std::map<PdbKey::PdbDataKey, std::string> knownDataKeysMap; | 
|---|
|  | 76 | static knownDataKeysMap knownDataKeys; | 
|---|
| [873037] | 77 | static bool knownDataKeys_Filled; | 
|---|
| [9dba5f] | 78 |  | 
|---|
| [16462f] | 79 | std::string token; | 
|---|
| [4fbca9c] | 80 | int serial; | 
|---|
|  | 81 | std::string name; | 
|---|
| [16462f] | 82 | char altLoc; | 
|---|
| [4fbca9c] | 83 | std::string resName; | 
|---|
|  | 84 | char chainID; | 
|---|
|  | 85 | int resSeq; | 
|---|
|  | 86 | char iCode; | 
|---|
| [16462f] | 87 | Vector XYZ; | 
|---|
| [4fbca9c] | 88 | float occupancy; | 
|---|
|  | 89 | float tempFactor; | 
|---|
| [16462f] | 90 | std::string element; | 
|---|
| [4fbca9c] | 91 | int charge; | 
|---|
|  | 92 | }; | 
|---|
|  | 93 |  | 
|---|
| [9dba5f] | 94 | std::ostream& operator<<(std::ostream &ost, const PdbAtomInfoContainer& m); | 
|---|
|  | 95 |  | 
|---|
| [16462f] | 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 |  | 
|---|
| [4fbca9c] | 103 | #endif /* PDBATOMINFOCONTAINER_HPP_ */ | 
|---|