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 "Parser/FormatParser.hpp"
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * Known keys for the Pdb line.
|
---|
16 | */
|
---|
17 | class PdbKey {
|
---|
18 | public:
|
---|
19 | enum PdbDataKey {
|
---|
20 | noKey,
|
---|
21 | x,
|
---|
22 | Id,
|
---|
23 | Type,
|
---|
24 | extType,
|
---|
25 | name,
|
---|
26 | resName,
|
---|
27 | chainID,
|
---|
28 | resSeq,
|
---|
29 | occupancy,
|
---|
30 | tempFactor,
|
---|
31 | segID,
|
---|
32 | charge
|
---|
33 | };
|
---|
34 | };
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * Holds tremolo-specific information which is not store in the atom class.
|
---|
38 | */
|
---|
39 | class PdbAtomInfoContainer {
|
---|
40 | public:
|
---|
41 | PdbAtomInfoContainer();
|
---|
42 | void set(PdbKey::PdbDataKey key, std::string value);
|
---|
43 | std::string get(PdbKey::PdbDataKey key);
|
---|
44 | std::string name;
|
---|
45 | std::string extType;
|
---|
46 | std::string resName;
|
---|
47 | std::string chainID;
|
---|
48 | std::string resSeq;
|
---|
49 | std::string occupancy;
|
---|
50 | std::string tempFactor;
|
---|
51 | std::string segID;
|
---|
52 | std::string charge;
|
---|
53 | };
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * Loads a tremolo file into the World and saves the World as a tremolo file.
|
---|
57 | */
|
---|
58 | class PdbParser : public FormatParser
|
---|
59 | {
|
---|
60 | public:
|
---|
61 | PdbParser();
|
---|
62 | ~PdbParser();
|
---|
63 | void load(std::istream* file);
|
---|
64 | void save(std::ostream* file);
|
---|
65 |
|
---|
66 |
|
---|
67 | private:
|
---|
68 | void readAtomDataLine(string line);
|
---|
69 | void parseAtomDataKeysLine(string line, int offset);
|
---|
70 | void readNeighbors(std::stringstream* line, int numberOfNeighbors, int atomId);
|
---|
71 | void processNeighborInformation();
|
---|
72 | void adaptImprData();
|
---|
73 | void adaptTorsion();
|
---|
74 | std::string adaptIdDependentDataString(std::string data);
|
---|
75 | bool isUsedField(std::string fieldName);
|
---|
76 | void writeNeighbors(std::ostream* file, int numberOfNeighbors, atom* currentAtom);
|
---|
77 | void saveLine(ostream* file, const atom* currentAtom, const char *name, const int AtomNo, const int ResdueNo);
|
---|
78 | int getAtomId(int atomid) const;
|
---|
79 | void setAtomId(int localatomid, int atomid);
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * Map to associate the known keys with numbers.
|
---|
83 | */
|
---|
84 | std::map<std::string, PdbKey::PdbDataKey> knownKeys;
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * Data which is currently not stored in atoms but was provided by the input
|
---|
88 | * file.
|
---|
89 | */
|
---|
90 | std::map<int, PdbAtomInfoContainer> additionalAtomData;
|
---|
91 |
|
---|
92 | /**
|
---|
93 | * Default additional atom data.
|
---|
94 | */
|
---|
95 | PdbAtomInfoContainer defaultAdditionalData;
|
---|
96 |
|
---|
97 | /**
|
---|
98 | * Maps original atom IDs received from the parsed file to atom IDs in the
|
---|
99 | * world.
|
---|
100 | */
|
---|
101 | std::map<int, int> atomIdMap;
|
---|
102 | };
|
---|
103 |
|
---|
104 | #endif /* PDBPARSER_HPP_ */
|
---|