[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 |
|
---|
| 16 |
|
---|
[4fbca9c] | 17 | #include "PdbKey.hpp"
|
---|
| 18 |
|
---|
[9dba5f] | 19 | class PdbParser;
|
---|
[16462f] | 20 | class Vector;
|
---|
| 21 |
|
---|
[4fbca9c] | 22 | #include <string>
|
---|
[16462f] | 23 | #include <typeinfo>
|
---|
[4fbca9c] | 24 |
|
---|
| 25 | /**
|
---|
| 26 | * Holds tremolo-specific information which is not store in the atom class.
|
---|
| 27 | */
|
---|
| 28 | class PdbAtomInfoContainer {
|
---|
[9dba5f] | 29 | friend class PdbParser;
|
---|
[4fbca9c] | 30 | public:
|
---|
| 31 | PdbAtomInfoContainer();
|
---|
| 32 | ~PdbAtomInfoContainer();
|
---|
| 33 |
|
---|
| 34 | // getter and setter
|
---|
[16462f] | 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 | }
|
---|
[4fbca9c] | 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 |
|
---|
[9dba5f] | 65 | const std::string& getDataKey(PdbKey::PdbDataKey key) const;
|
---|
| 66 |
|
---|
[4fbca9c] | 67 | private:
|
---|
[9dba5f] | 68 |
|
---|
[873037] | 69 | static void fillknownDataKeys();
|
---|
| 70 | static void clearknownDataKeys();
|
---|
[9dba5f] | 71 |
|
---|
| 72 | typedef std::map<PdbKey::PdbDataKey, std::string> knownDataKeysMap;
|
---|
| 73 | static knownDataKeysMap knownDataKeys;
|
---|
[873037] | 74 | static bool knownDataKeys_Filled;
|
---|
[9dba5f] | 75 |
|
---|
[16462f] | 76 | std::string token;
|
---|
[4fbca9c] | 77 | int serial;
|
---|
| 78 | std::string name;
|
---|
[16462f] | 79 | char altLoc;
|
---|
[4fbca9c] | 80 | std::string resName;
|
---|
| 81 | char chainID;
|
---|
| 82 | int resSeq;
|
---|
| 83 | char iCode;
|
---|
[16462f] | 84 | Vector XYZ;
|
---|
[4fbca9c] | 85 | float occupancy;
|
---|
| 86 | float tempFactor;
|
---|
[16462f] | 87 | std::string element;
|
---|
[4fbca9c] | 88 | int charge;
|
---|
| 89 | };
|
---|
| 90 |
|
---|
[9dba5f] | 91 | std::ostream& operator<<(std::ostream &ost, const PdbAtomInfoContainer& m);
|
---|
| 92 |
|
---|
[16462f] | 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 |
|
---|
[4fbca9c] | 100 | #endif /* PDBATOMINFOCONTAINER_HPP_ */
|
---|