| 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 |  | 
|---|
| 11 | // include config.h | 
|---|
| 12 | #ifdef HAVE_CONFIG_H | 
|---|
| 13 | #include <config.h> | 
|---|
| 14 | #endif | 
|---|
| 15 |  | 
|---|
| 16 |  | 
|---|
| 17 | #include <string> | 
|---|
| 18 | #include "FormatParser.hpp" | 
|---|
| 19 | #include "PdbAtomInfoContainer.hpp" | 
|---|
| 20 | #include "PdbKey.hpp" | 
|---|
| 21 |  | 
|---|
| 22 | /** | 
|---|
| 23 | * Loads a PDB format 3.2 file into the World and saves the World as a PDB file. | 
|---|
| 24 | */ | 
|---|
| 25 | class PdbParser : public FormatParser | 
|---|
| 26 | { | 
|---|
| 27 | public: | 
|---|
| 28 | PdbParser(); | 
|---|
| 29 | virtual ~PdbParser(); | 
|---|
| 30 | void load(std::istream* file); | 
|---|
| 31 | void save(std::ostream* file, const std::vector<atom *> &atoms); | 
|---|
| 32 |  | 
|---|
| 33 | bool operator==(const PdbParser& b) const; | 
|---|
| 34 | void printAtomInfo(const atom *newAtom) const; | 
|---|
| 35 |  | 
|---|
| 36 | protected: | 
|---|
| 37 | void AtomInserted(atomId_t); | 
|---|
| 38 | void AtomRemoved(atomId_t); | 
|---|
| 39 |  | 
|---|
| 40 | private: | 
|---|
| 41 | enum PdbKey::KnownTokens getToken(string &line); | 
|---|
| 42 | void readAtomDataLine(const unsigned int _step, string &line, molecule *newmol); | 
|---|
| 43 | void parseAtomDataKeysLine(string line, int offset); | 
|---|
| 44 | void readNeighbors(const unsigned int _step, std::string &line); | 
|---|
| 45 | //  void adaptImprData(); | 
|---|
| 46 | //  void adaptTorsion(); | 
|---|
| 47 | //  std::string adaptIdDependentDataString(std::string data); | 
|---|
| 48 | bool isUsedField(std::string fieldName); | 
|---|
| 49 | void writeNeighbors(std::ostream* file, int numberOfNeighbors, atom* currentAtom); | 
|---|
| 50 | void saveLine(ostream* file, const PdbAtomInfoContainer &atomInfo); | 
|---|
| 51 |  | 
|---|
| 52 | // internal getter and setter | 
|---|
| 53 | bool isPresentadditionalAtomData(unsigned int _id); | 
|---|
| 54 | PdbAtomInfoContainer& getadditionalAtomData(atom *_atom); | 
|---|
| 55 | size_t getSerial(const size_t atomid) const; | 
|---|
| 56 | void setSerial(const size_t localatomid, const size_t atomid); | 
|---|
| 57 |  | 
|---|
| 58 | // internal helper functions | 
|---|
| 59 | atom* getAtomToParse(std::string id_string) const; | 
|---|
| 60 | void readPdbAtomInfoContainer(PdbAtomInfoContainer &atomInfo, std::string &line) const; | 
|---|
| 61 |  | 
|---|
| 62 | /** | 
|---|
| 63 | * argh, why can't just PdbKey::X+(size_t)i | 
|---|
| 64 | */ | 
|---|
| 65 | std::map<size_t, PdbKey::PdbDataKey> PositionEnumMap; | 
|---|
| 66 |  | 
|---|
| 67 | /** | 
|---|
| 68 | * Map to associate the known keys with numbers. | 
|---|
| 69 | */ | 
|---|
| 70 | std::map<std::string, PdbKey::KnownTokens> knownTokens; | 
|---|
| 71 |  | 
|---|
| 72 | /** | 
|---|
| 73 | * Data which is currently not stored in atoms but was provided by the input | 
|---|
| 74 | * file. | 
|---|
| 75 | */ | 
|---|
| 76 | std::map<size_t, PdbAtomInfoContainer> additionalAtomData; | 
|---|
| 77 |  | 
|---|
| 78 | /** | 
|---|
| 79 | * Default additional atom data. | 
|---|
| 80 | */ | 
|---|
| 81 | PdbAtomInfoContainer defaultAdditionalData; | 
|---|
| 82 |  | 
|---|
| 83 | /** | 
|---|
| 84 | * Maps original atom IDs received from the parsed file to atom IDs in the | 
|---|
| 85 | * world. | 
|---|
| 86 | */ | 
|---|
| 87 | std::map<size_t, size_t> atomIdMap; | 
|---|
| 88 |  | 
|---|
| 89 | /** | 
|---|
| 90 | * Ascertaining uniqueness of Ids. | 
|---|
| 91 | */ | 
|---|
| 92 | std::set<size_t> SerialSet; | 
|---|
| 93 |  | 
|---|
| 94 | }; | 
|---|
| 95 |  | 
|---|
| 96 | #endif /* PDBPARSER_HPP_ */ | 
|---|