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