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 config.h
|
---|
12 | #ifdef HAVE_CONFIG_H
|
---|
13 | #include <config.h>
|
---|
14 | #endif
|
---|
15 |
|
---|
16 | #include <string>
|
---|
17 |
|
---|
18 | #include "FormatParser.hpp"
|
---|
19 | #include "FormatParserTrait.hpp"
|
---|
20 | #include "FormatParserInterface.hpp"
|
---|
21 | #include "FormatParser_common.hpp"
|
---|
22 | #include "ParserTypes.hpp"
|
---|
23 | #include "types.hpp"
|
---|
24 |
|
---|
25 | #include "PdbAtomInfoContainer.hpp"
|
---|
26 | #include "PdbKey.hpp"
|
---|
27 |
|
---|
28 | class molecule;
|
---|
29 | class ParserPdbUnitTest;
|
---|
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 |
|
---|
43 | /**
|
---|
44 | * Loads a PDB format 3.2 file into the World and saves the World as a PDB file.
|
---|
45 | */
|
---|
46 | template <>
|
---|
47 | class FormatParser< pdb > : virtual public FormatParserInterface, public FormatParser_common
|
---|
48 | {
|
---|
49 | //!> grant pdb test access to private parts
|
---|
50 | friend class ParserPdbUnitTest;
|
---|
51 | public:
|
---|
52 | FormatParser();
|
---|
53 | virtual ~FormatParser();
|
---|
54 | void load(std::istream* file);
|
---|
55 | void save(std::ostream* file, const std::vector<const atom *> &atoms);
|
---|
56 |
|
---|
57 | bool operator==(const FormatParser< pdb>& b) const;
|
---|
58 | void printAtomInfo(const atom * const newAtom) const;
|
---|
59 |
|
---|
60 | protected:
|
---|
61 | void AtomInserted(atomId_t);
|
---|
62 | void AtomRemoved(atomId_t);
|
---|
63 |
|
---|
64 | private:
|
---|
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);
|
---|
68 | void readNeighbors(const unsigned int _step, std::string &line);
|
---|
69 | // void adaptImprData();
|
---|
70 | // void adaptTorsion();
|
---|
71 | // std::string adaptIdDependentDataString(std::string data);
|
---|
72 | bool isUsedField(std::string fieldName);
|
---|
73 | void writeNeighbors(std::ostream* file, int numberOfNeighbors, const atom* currentAtom);
|
---|
74 | void saveLine(std::ostream* file, const PdbAtomInfoContainer &atomInfo);
|
---|
75 |
|
---|
76 | // internal getter and setter
|
---|
77 | bool isPresentadditionalAtomData(const atomId_t _id) const;
|
---|
78 | PdbAtomInfoContainer& getadditionalAtomData(const atom *_atom);
|
---|
79 |
|
---|
80 | // internal helper functions
|
---|
81 | atom* getAtomToParse(std::string id_string);
|
---|
82 | void readPdbAtomInfoContainer(PdbAtomInfoContainer &atomInfo, std::string &line) const;
|
---|
83 | static const std::string printCoordinate(const double value);
|
---|
84 |
|
---|
85 | /**
|
---|
86 | * argh, why can't just PdbKey::X+(size_t)i
|
---|
87 | */
|
---|
88 | std::map<size_t, PdbKey::PdbDataKey> PositionEnumMap;
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * Map to associate the known keys with numbers.
|
---|
92 | */
|
---|
93 | std::map<std::string, PdbKey::KnownTokens> knownTokens;
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * Data which is currently not stored in atoms but was provided by the input
|
---|
97 | * file.
|
---|
98 | */
|
---|
99 | std::map<const atomId_t, PdbAtomInfoContainer> additionalAtomData;
|
---|
100 |
|
---|
101 | /**
|
---|
102 | * Default additional atom data.
|
---|
103 | */
|
---|
104 | PdbAtomInfoContainer defaultAdditionalData;
|
---|
105 | };
|
---|
106 |
|
---|
107 | #endif /* PDBPARSER_HPP_ */
|
---|