| [3ae731] | 1 | /* | 
|---|
|  | 2 | * PdbParser.hpp | 
|---|
|  | 3 | * | 
|---|
|  | 4 | *  Created on: Aug 17, 2010 | 
|---|
|  | 5 | *      Author: heber | 
|---|
|  | 6 | */ | 
|---|
|  | 7 |  | 
|---|
|  | 8 | #ifndef PDBPARSER_HPP_ | 
|---|
|  | 9 | #define PDBPARSER_HPP_ | 
|---|
|  | 10 |  | 
|---|
| [56f73b] | 11 | // include config.h | 
|---|
|  | 12 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 13 | #include <config.h> | 
|---|
|  | 14 | #endif | 
|---|
|  | 15 |  | 
|---|
| [3ae731] | 16 | #include <string> | 
|---|
| [765f16] | 17 |  | 
|---|
| [4fbca9c] | 18 | #include "FormatParser.hpp" | 
|---|
| [765f16] | 19 | #include "FormatParserTrait.hpp" | 
|---|
|  | 20 | #include "FormatParserInterface.hpp" | 
|---|
|  | 21 | #include "FormatParser_common.hpp" | 
|---|
|  | 22 | #include "ParserTypes.hpp" | 
|---|
| [8bf9c6] | 23 | #include "types.hpp" | 
|---|
| [765f16] | 24 |  | 
|---|
| [4fbca9c] | 25 | #include "PdbAtomInfoContainer.hpp" | 
|---|
|  | 26 | #include "PdbKey.hpp" | 
|---|
| [3ae731] | 27 |  | 
|---|
| [765f16] | 28 | class molecule; | 
|---|
|  | 29 |  | 
|---|
|  | 30 | // declaration of specialized FormatParserTrait | 
|---|
|  | 31 | template<> | 
|---|
|  | 32 | struct FormatParserTrait<pdb> | 
|---|
|  | 33 | { | 
|---|
|  | 34 | //!> Name of the parser | 
|---|
|  | 35 | static const std::string name; | 
|---|
|  | 36 | //!> suffix of the files the parser understands to read and write | 
|---|
|  | 37 | static const std::string suffix; | 
|---|
|  | 38 | //!> ParserTypes enumeration for the parser | 
|---|
|  | 39 | static const enum ParserTypes type; | 
|---|
|  | 40 | }; | 
|---|
|  | 41 |  | 
|---|
| [3ae731] | 42 | /** | 
|---|
| [4fbca9c] | 43 | * Loads a PDB format 3.2 file into the World and saves the World as a PDB file. | 
|---|
| [3ae731] | 44 | */ | 
|---|
| [765f16] | 45 | template <> | 
|---|
|  | 46 | class FormatParser< pdb >  : virtual public FormatParserInterface, public FormatParser_common | 
|---|
| [3ae731] | 47 | { | 
|---|
|  | 48 | public: | 
|---|
| [765f16] | 49 | FormatParser(); | 
|---|
|  | 50 | virtual ~FormatParser(); | 
|---|
| [3ae731] | 51 | void load(std::istream* file); | 
|---|
| [73916f] | 52 | void save(std::ostream* file, const std::vector<atom *> &atoms); | 
|---|
| [3ae731] | 53 |  | 
|---|
| [765f16] | 54 | bool operator==(const FormatParser< pdb>& b) const; | 
|---|
| [4fbca9c] | 55 | void printAtomInfo(const atom *newAtom) const; | 
|---|
| [3ae731] | 56 |  | 
|---|
| [6bc86c] | 57 | protected: | 
|---|
|  | 58 | void AtomInserted(atomId_t); | 
|---|
|  | 59 | void AtomRemoved(atomId_t); | 
|---|
|  | 60 |  | 
|---|
| [3ae731] | 61 | private: | 
|---|
| [4fbca9c] | 62 | enum PdbKey::KnownTokens getToken(string &line); | 
|---|
| [b0a2e3] | 63 | void readAtomDataLine(const unsigned int _step, string &line, molecule *newmol); | 
|---|
| [3ae731] | 64 | void parseAtomDataKeysLine(string line, int offset); | 
|---|
| [b0a2e3] | 65 | void readNeighbors(const unsigned int _step, std::string &line); | 
|---|
| [4fbca9c] | 66 | //  void adaptImprData(); | 
|---|
|  | 67 | //  void adaptTorsion(); | 
|---|
|  | 68 | //  std::string adaptIdDependentDataString(std::string data); | 
|---|
| [3ae731] | 69 | bool isUsedField(std::string fieldName); | 
|---|
|  | 70 | void writeNeighbors(std::ostream* file, int numberOfNeighbors, atom* currentAtom); | 
|---|
| [16462f] | 71 | void saveLine(ostream* file, const PdbAtomInfoContainer &atomInfo); | 
|---|
| [4fbca9c] | 72 |  | 
|---|
|  | 73 | // internal getter and setter | 
|---|
| [8bf9c6] | 74 | bool isPresentadditionalAtomData(const atomId_t _id) const; | 
|---|
| [93fd43e] | 75 | PdbAtomInfoContainer& getadditionalAtomData(atom *_atom); | 
|---|
| [16462f] | 76 |  | 
|---|
| [9dba5f] | 77 | // internal helper functions | 
|---|
| [c0e28c] | 78 | atom* getAtomToParse(std::string id_string); | 
|---|
| [9dba5f] | 79 | void readPdbAtomInfoContainer(PdbAtomInfoContainer &atomInfo, std::string &line) const; | 
|---|
|  | 80 |  | 
|---|
| [16462f] | 81 | /** | 
|---|
|  | 82 | * argh, why can't just PdbKey::X+(size_t)i | 
|---|
|  | 83 | */ | 
|---|
|  | 84 | std::map<size_t, PdbKey::PdbDataKey> PositionEnumMap; | 
|---|
| [3ae731] | 85 |  | 
|---|
|  | 86 | /** | 
|---|
|  | 87 | * Map to associate the known keys with numbers. | 
|---|
|  | 88 | */ | 
|---|
| [4fbca9c] | 89 | std::map<std::string, PdbKey::KnownTokens> knownTokens; | 
|---|
| [3ae731] | 90 |  | 
|---|
|  | 91 | /** | 
|---|
|  | 92 | * Data which is currently not stored in atoms but was provided by the input | 
|---|
|  | 93 | * file. | 
|---|
|  | 94 | */ | 
|---|
| [8bf9c6] | 95 | std::map<const atomId_t, PdbAtomInfoContainer> additionalAtomData; | 
|---|
| [3ae731] | 96 |  | 
|---|
|  | 97 | /** | 
|---|
|  | 98 | * Default additional atom data. | 
|---|
|  | 99 | */ | 
|---|
| [bb6193] | 100 | PdbAtomInfoContainer defaultAdditionalData; | 
|---|
| [3ae731] | 101 | }; | 
|---|
|  | 102 |  | 
|---|
|  | 103 | #endif /* PDBPARSER_HPP_ */ | 
|---|