[6bc51d] | 1 | /*
|
---|
| 2 | * TremoloParser.hpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: Mar 2, 2010
|
---|
| 5 | * Author: metzler
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef TREMOLOPARSER_HPP_
|
---|
| 9 | #define TREMOLOPARSER_HPP_
|
---|
| 10 |
|
---|
[9131f3] | 11 | #include <string>
|
---|
[a1e929] | 12 | #include "Parser/FormatParser.hpp"
|
---|
[6bc51d] | 13 |
|
---|
[dc1d9e] | 14 | class molecule;
|
---|
| 15 |
|
---|
[b8d4a3] | 16 | /**
|
---|
| 17 | * Known keys for the ATOMDATA line.
|
---|
| 18 | */
|
---|
| 19 | class TremoloKey {
|
---|
| 20 | public:
|
---|
| 21 | enum atomDataKey {
|
---|
| 22 | noKey,
|
---|
| 23 | x,
|
---|
| 24 | u,
|
---|
| 25 | F,
|
---|
| 26 | stress,
|
---|
| 27 | Id,
|
---|
| 28 | neighbors,
|
---|
| 29 | imprData,
|
---|
| 30 | GroupMeasureTypeNo,
|
---|
| 31 | Type,
|
---|
| 32 | extType,
|
---|
| 33 | name,
|
---|
| 34 | resName,
|
---|
| 35 | chainID,
|
---|
| 36 | resSeq,
|
---|
| 37 | occupancy,
|
---|
| 38 | tempFactor,
|
---|
| 39 | segID,
|
---|
| 40 | Charge,
|
---|
| 41 | charge,
|
---|
| 42 | GrpTypeNo,
|
---|
| 43 | torsion
|
---|
| 44 | };
|
---|
| 45 | };
|
---|
| 46 |
|
---|
[4415da] | 47 | /**
|
---|
| 48 | * Holds tremolo-specific information which is not store in the atom class.
|
---|
| 49 | */
|
---|
| 50 | class TremoloAtomInfoContainer {
|
---|
| 51 | public:
|
---|
| 52 | TremoloAtomInfoContainer();
|
---|
[b8d4a3] | 53 | void set(TremoloKey::atomDataKey key, std::string value);
|
---|
| 54 | std::string get(TremoloKey::atomDataKey key);
|
---|
[4415da] | 55 | std::string F;
|
---|
| 56 | std::string stress;
|
---|
| 57 | std::string imprData;
|
---|
| 58 | std::string GroupMeasureTypeNo;
|
---|
| 59 | std::string extType;
|
---|
| 60 | std::string name;
|
---|
| 61 | std::string resName;
|
---|
| 62 | std::string chainID;
|
---|
| 63 | std::string resSeq;
|
---|
| 64 | std::string occupancy;
|
---|
| 65 | std::string tempFactor;
|
---|
| 66 | std::string segID;
|
---|
| 67 | std::string Charge;
|
---|
| 68 | std::string charge;
|
---|
| 69 | std::string GrpTypeNo;
|
---|
[b8d4a3] | 70 | std::string torsion;
|
---|
| 71 | std::vector<int> neighbors;
|
---|
[4415da] | 72 | };
|
---|
| 73 |
|
---|
| 74 | /**
|
---|
| 75 | * Loads a tremolo file into the World and saves the World as a tremolo file.
|
---|
| 76 | */
|
---|
[b8d4a3] | 77 | class TremoloParser : public FormatParser
|
---|
[9131f3] | 78 | {
|
---|
[6bc51d] | 79 | public:
|
---|
[9131f3] | 80 | TremoloParser();
|
---|
| 81 | ~TremoloParser();
|
---|
| 82 | void load(std::istream* file);
|
---|
| 83 | void save(std::ostream* file);
|
---|
[b8d4a3] | 84 | void setFieldsForSave(std::string atomDataLine);
|
---|
| 85 |
|
---|
[6bc51d] | 86 |
|
---|
| 87 | private:
|
---|
[9131f3] | 88 | void readAtomDataLine(string line);
|
---|
[dc1d9e] | 89 | void readAtomDataLine(string line, molecule *newmol);
|
---|
[9131f3] | 90 | void parseAtomDataKeysLine(string line, int offset);
|
---|
[b8d4a3] | 91 | void readNeighbors(std::stringstream* line, int numberOfNeighbors, int atomId);
|
---|
| 92 | void processNeighborInformation();
|
---|
| 93 | void adaptImprData();
|
---|
| 94 | void adaptTorsion();
|
---|
| 95 | std::string adaptIdDependentDataString(std::string data);
|
---|
| 96 | bool isUsedField(std::string fieldName);
|
---|
| 97 | void writeNeighbors(std::ostream* file, int numberOfNeighbors, atom* currentAtom);
|
---|
| 98 | void saveLine(std::ostream* file, atom* currentAtom);
|
---|
[9131f3] | 99 |
|
---|
| 100 | /**
|
---|
| 101 | * Map to associate the known keys with numbers.
|
---|
| 102 | */
|
---|
[b8d4a3] | 103 | std::map<std::string, TremoloKey::atomDataKey> knownKeys;
|
---|
[9131f3] | 104 |
|
---|
| 105 | /**
|
---|
| 106 | * Fields used in the tremolo file.
|
---|
| 107 | */
|
---|
| 108 | std::vector<std::string> usedFields;
|
---|
| 109 |
|
---|
| 110 | /**
|
---|
| 111 | * Data which is currently not stored in atoms but was provided by the input
|
---|
| 112 | * file.
|
---|
| 113 | */
|
---|
[b8d4a3] | 114 | std::map<int, TremoloAtomInfoContainer> additionalAtomData;
|
---|
| 115 |
|
---|
| 116 | /**
|
---|
| 117 | * Default additional atom data.
|
---|
| 118 | */
|
---|
| 119 | TremoloAtomInfoContainer defaultAdditionalData;
|
---|
| 120 |
|
---|
| 121 | /**
|
---|
| 122 | * Maps original atom IDs received from the parsed file to atom IDs in the
|
---|
| 123 | * world.
|
---|
| 124 | */
|
---|
| 125 | std::map<int, int> atomIdMap;
|
---|
[6bc51d] | 126 | };
|
---|
| 127 |
|
---|
| 128 | #endif /* TREMOLOPARSER_HPP_ */
|
---|