| [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 | 
 | 
|---|
| [3ae731] | 16 | #include <string>
 | 
|---|
| [765f16] | 17 | 
 | 
|---|
| [4fbca9c] | 18 | #include "FormatParser.hpp"
 | 
|---|
| [765f16] | 19 | #include "FormatParserTrait.hpp"
 | 
|---|
 | 20 | #include "FormatParserInterface.hpp"
 | 
|---|
 | 21 | #include "FormatParser_common.hpp"
 | 
|---|
 | 22 | #include "ParserTypes.hpp"
 | 
|---|
| [8bf9c6] | 23 | #include "types.hpp"
 | 
|---|
| [765f16] | 24 | 
 | 
|---|
| [4fbca9c] | 25 | #include "PdbAtomInfoContainer.hpp"
 | 
|---|
 | 26 | #include "PdbKey.hpp"
 | 
|---|
| [3ae731] | 27 | 
 | 
|---|
| [765f16] | 28 | class molecule;
 | 
|---|
| [105b72] | 29 | class ParserPdbUnitTest;
 | 
|---|
| [765f16] | 30 | 
 | 
|---|
 | 31 | // declaration of specialized FormatParserTrait
 | 
|---|
 | 32 | template<>
 | 
|---|
 | 33 | struct FormatParserTrait<pdb>
 | 
|---|
 | 34 | {
 | 
|---|
 | 35 |   //!> Name of the parser
 | 
|---|
 | 36 |   static const std::string name;
 | 
|---|
 | 37 |   //!> suffix of the files the parser understands to read and write
 | 
|---|
 | 38 |   static const std::string suffix;
 | 
|---|
 | 39 |   //!> ParserTypes enumeration for the parser
 | 
|---|
 | 40 |   static const enum ParserTypes type;
 | 
|---|
 | 41 | };
 | 
|---|
 | 42 | 
 | 
|---|
| [3ae731] | 43 | /**
 | 
|---|
| [4fbca9c] | 44 |  * Loads a PDB format 3.2 file into the World and saves the World as a PDB file.
 | 
|---|
| [3ae731] | 45 |  */
 | 
|---|
| [765f16] | 46 | template <>
 | 
|---|
 | 47 | class FormatParser< pdb >  : virtual public FormatParserInterface, public FormatParser_common
 | 
|---|
| [3ae731] | 48 | {
 | 
|---|
| [105b72] | 49 |   //!> grant pdb test access to private parts
 | 
|---|
 | 50 |   friend class ParserPdbUnitTest;
 | 
|---|
| [3ae731] | 51 | public:
 | 
|---|
| [765f16] | 52 |   FormatParser();
 | 
|---|
 | 53 |   virtual ~FormatParser();
 | 
|---|
| [3ae731] | 54 |   void load(std::istream* file);
 | 
|---|
| [73916f] | 55 |   void save(std::ostream* file, const std::vector<atom *> &atoms);
 | 
|---|
| [3ae731] | 56 | 
 | 
|---|
| [765f16] | 57 |   bool operator==(const FormatParser< pdb>& b) const;
 | 
|---|
| [4fbca9c] | 58 |   void printAtomInfo(const atom *newAtom) const;
 | 
|---|
| [3ae731] | 59 | 
 | 
|---|
| [6bc86c] | 60 | protected:
 | 
|---|
 | 61 |   void AtomInserted(atomId_t);
 | 
|---|
 | 62 |   void AtomRemoved(atomId_t);
 | 
|---|
 | 63 | 
 | 
|---|
| [3ae731] | 64 | private:
 | 
|---|
| [955b91] | 65 |   enum PdbKey::KnownTokens getToken(std::string &line);
 | 
|---|
 | 66 |   void readAtomDataLine(const unsigned int _step, std::string &line, molecule *newmol);
 | 
|---|
 | 67 |   void parseAtomDataKeysLine(std::string line, int offset);
 | 
|---|
| [b0a2e3] | 68 |   void readNeighbors(const unsigned int _step, std::string &line);
 | 
|---|
| [4fbca9c] | 69 | //  void adaptImprData();
 | 
|---|
 | 70 | //  void adaptTorsion();
 | 
|---|
 | 71 | //  std::string adaptIdDependentDataString(std::string data);
 | 
|---|
| [3ae731] | 72 |   bool isUsedField(std::string fieldName);
 | 
|---|
 | 73 |   void writeNeighbors(std::ostream* file, int numberOfNeighbors, atom* currentAtom);
 | 
|---|
| [955b91] | 74 |   void saveLine(std::ostream* file, const PdbAtomInfoContainer &atomInfo);
 | 
|---|
| [4fbca9c] | 75 | 
 | 
|---|
 | 76 |   // internal getter and setter
 | 
|---|
| [8bf9c6] | 77 |   bool isPresentadditionalAtomData(const atomId_t _id) const;
 | 
|---|
| [93fd43e] | 78 |   PdbAtomInfoContainer& getadditionalAtomData(atom *_atom);
 | 
|---|
| [16462f] | 79 | 
 | 
|---|
| [9dba5f] | 80 |   // internal helper functions
 | 
|---|
| [c0e28c] | 81 |   atom* getAtomToParse(std::string id_string);
 | 
|---|
| [9dba5f] | 82 |   void readPdbAtomInfoContainer(PdbAtomInfoContainer &atomInfo, std::string &line) const;
 | 
|---|
| [105b72] | 83 |   static const std::string printCoordinate(const double value);
 | 
|---|
| [9dba5f] | 84 | 
 | 
|---|
| [16462f] | 85 |   /**
 | 
|---|
 | 86 |    * argh, why can't just PdbKey::X+(size_t)i
 | 
|---|
 | 87 |    */
 | 
|---|
 | 88 |   std::map<size_t, PdbKey::PdbDataKey> PositionEnumMap;
 | 
|---|
| [3ae731] | 89 | 
 | 
|---|
 | 90 |   /**
 | 
|---|
 | 91 |    * Map to associate the known keys with numbers.
 | 
|---|
 | 92 |    */
 | 
|---|
| [4fbca9c] | 93 |   std::map<std::string, PdbKey::KnownTokens> knownTokens;
 | 
|---|
| [3ae731] | 94 | 
 | 
|---|
 | 95 |   /**
 | 
|---|
 | 96 |    * Data which is currently not stored in atoms but was provided by the input
 | 
|---|
 | 97 |    * file.
 | 
|---|
 | 98 |    */
 | 
|---|
| [8bf9c6] | 99 |   std::map<const atomId_t, PdbAtomInfoContainer> additionalAtomData;
 | 
|---|
| [3ae731] | 100 | 
 | 
|---|
 | 101 |   /**
 | 
|---|
 | 102 |    * Default additional atom data.
 | 
|---|
 | 103 |    */
 | 
|---|
| [bb6193] | 104 |   PdbAtomInfoContainer defaultAdditionalData;
 | 
|---|
| [3ae731] | 105 | };
 | 
|---|
 | 106 | 
 | 
|---|
 | 107 | #endif /* PDBPARSER_HPP_ */
 | 
|---|