| 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);
 | 
|---|
| 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 atom* currentAtom, const char *name, const int AtomNo, const int ResdueNo);
 | 
|---|
| 41 | 
 | 
|---|
| 42 |   // internal getter and setter
 | 
|---|
| 43 |   size_t getSerial(const size_t atomid) const;
 | 
|---|
| 44 |   size_t getAtomId(const size_t atomid) const;
 | 
|---|
| 45 |   void setAtomId(const size_t localatomid, const size_t atomid);
 | 
|---|
| 46 | 
 | 
|---|
| 47 |   /**
 | 
|---|
| 48 |    * Map to associate the known keys with numbers.
 | 
|---|
| 49 |    */
 | 
|---|
| 50 |   std::map<std::string, PdbKey::KnownTokens> knownTokens;
 | 
|---|
| 51 | 
 | 
|---|
| 52 |   /**
 | 
|---|
| 53 |    * Data which is currently not stored in atoms but was provided by the input
 | 
|---|
| 54 |    * file.
 | 
|---|
| 55 |    */
 | 
|---|
| 56 |   std::map<size_t, PdbAtomInfoContainer> additionalAtomData;
 | 
|---|
| 57 | 
 | 
|---|
| 58 |   /**
 | 
|---|
| 59 |    * Default additional atom data.
 | 
|---|
| 60 |    */
 | 
|---|
| 61 |   PdbAtomInfoContainer defaultAdditionalData;
 | 
|---|
| 62 | 
 | 
|---|
| 63 |   /**
 | 
|---|
| 64 |    * Maps original atom IDs received from the parsed file to atom IDs in the
 | 
|---|
| 65 |    * world.
 | 
|---|
| 66 |    */
 | 
|---|
| 67 |   std::map<size_t, size_t> atomIdMap;
 | 
|---|
| 68 | 
 | 
|---|
| 69 |   /**
 | 
|---|
| 70 |    * Maps original atom IDs received from the parsed file to atom IDs in the
 | 
|---|
| 71 |    * world.
 | 
|---|
| 72 |    */
 | 
|---|
| 73 |   std::set<size_t> SerialSet;
 | 
|---|
| 74 | 
 | 
|---|
| 75 | };
 | 
|---|
| 76 | 
 | 
|---|
| 77 | #endif /* PDBPARSER_HPP_ */
 | 
|---|