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