| [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(); | 
|---|
|  | 29 | ~PdbParser(); | 
|---|
|  | 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 |  | 
|---|
|  | 36 | private: | 
|---|
| [4fbca9c] | 37 | enum PdbKey::KnownTokens getToken(string &line); | 
|---|
|  | 38 | void readAtomDataLine(string &line, molecule *newmol); | 
|---|
| [3ae731] | 39 | void parseAtomDataKeysLine(string line, int offset); | 
|---|
| [4fbca9c] | 40 | void readNeighbors(std::string &line); | 
|---|
|  | 41 | //  void adaptImprData(); | 
|---|
|  | 42 | //  void adaptTorsion(); | 
|---|
|  | 43 | //  std::string adaptIdDependentDataString(std::string data); | 
|---|
| [3ae731] | 44 | bool isUsedField(std::string fieldName); | 
|---|
|  | 45 | void writeNeighbors(std::ostream* file, int numberOfNeighbors, atom* currentAtom); | 
|---|
| [16462f] | 46 | void saveLine(ostream* file, const PdbAtomInfoContainer &atomInfo); | 
|---|
| [4fbca9c] | 47 |  | 
|---|
|  | 48 | // internal getter and setter | 
|---|
| [93fd43e] | 49 | PdbAtomInfoContainer& getadditionalAtomData(atom *_atom); | 
|---|
| [4fbca9c] | 50 | size_t getSerial(const size_t atomid) const; | 
|---|
| [16462f] | 51 | void setSerial(const size_t localatomid, const size_t atomid); | 
|---|
|  | 52 |  | 
|---|
|  | 53 | /** | 
|---|
|  | 54 | * argh, why can't just PdbKey::X+(size_t)i | 
|---|
|  | 55 | */ | 
|---|
|  | 56 | std::map<size_t, PdbKey::PdbDataKey> PositionEnumMap; | 
|---|
| [3ae731] | 57 |  | 
|---|
|  | 58 | /** | 
|---|
|  | 59 | * Map to associate the known keys with numbers. | 
|---|
|  | 60 | */ | 
|---|
| [4fbca9c] | 61 | std::map<std::string, PdbKey::KnownTokens> knownTokens; | 
|---|
| [3ae731] | 62 |  | 
|---|
|  | 63 | /** | 
|---|
|  | 64 | * Data which is currently not stored in atoms but was provided by the input | 
|---|
|  | 65 | * file. | 
|---|
|  | 66 | */ | 
|---|
| [4fbca9c] | 67 | std::map<size_t, PdbAtomInfoContainer> additionalAtomData; | 
|---|
| [3ae731] | 68 |  | 
|---|
|  | 69 | /** | 
|---|
|  | 70 | * Default additional atom data. | 
|---|
|  | 71 | */ | 
|---|
| [bb6193] | 72 | PdbAtomInfoContainer defaultAdditionalData; | 
|---|
| [3ae731] | 73 |  | 
|---|
|  | 74 | /** | 
|---|
|  | 75 | * Maps original atom IDs received from the parsed file to atom IDs in the | 
|---|
|  | 76 | * world. | 
|---|
|  | 77 | */ | 
|---|
| [4fbca9c] | 78 | std::map<size_t, size_t> atomIdMap; | 
|---|
|  | 79 |  | 
|---|
|  | 80 | /** | 
|---|
|  | 81 | * Maps original atom IDs received from the parsed file to atom IDs in the | 
|---|
|  | 82 | * world. | 
|---|
|  | 83 | */ | 
|---|
|  | 84 | std::set<size_t> SerialSet; | 
|---|
|  | 85 |  | 
|---|
| [3ae731] | 86 | }; | 
|---|
|  | 87 |  | 
|---|
|  | 88 | #endif /* PDBPARSER_HPP_ */ | 
|---|