| 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 | 
 | 
|---|
| 11 | #include <string>
 | 
|---|
| 12 | #include "Parser/FormatParser.hpp"
 | 
|---|
| 13 | 
 | 
|---|
| 14 | class molecule;
 | 
|---|
| 15 | 
 | 
|---|
| 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 | 
 | 
|---|
| 47 | /**
 | 
|---|
| 48 |  * Holds tremolo-specific information which is not store in the atom class.
 | 
|---|
| 49 |  */
 | 
|---|
| 50 | class TremoloAtomInfoContainer {
 | 
|---|
| 51 | public:
 | 
|---|
| 52 |   TremoloAtomInfoContainer();
 | 
|---|
| 53 |   void set(TremoloKey::atomDataKey key, std::string value);
 | 
|---|
| 54 |   std::string get(TremoloKey::atomDataKey key);
 | 
|---|
| 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;
 | 
|---|
| 70 |   std::string torsion;
 | 
|---|
| 71 |   std::vector<int> neighbors;
 | 
|---|
| 72 | };
 | 
|---|
| 73 | 
 | 
|---|
| 74 | /**
 | 
|---|
| 75 |  * Loads a tremolo file into the World and saves the World as a tremolo file.
 | 
|---|
| 76 |  */
 | 
|---|
| 77 | class TremoloParser : public FormatParser
 | 
|---|
| 78 | {
 | 
|---|
| 79 | public:
 | 
|---|
| 80 |   TremoloParser();
 | 
|---|
| 81 |   ~TremoloParser();
 | 
|---|
| 82 |   void load(std::istream* file);
 | 
|---|
| 83 |   void save(std::ostream* file);
 | 
|---|
| 84 |   void setFieldsForSave(std::string atomDataLine);
 | 
|---|
| 85 | 
 | 
|---|
| 86 | 
 | 
|---|
| 87 | private:
 | 
|---|
| 88 |   void readAtomDataLine(string line);
 | 
|---|
| 89 |   void readAtomDataLine(string line, molecule *newmol);
 | 
|---|
| 90 |   void parseAtomDataKeysLine(string line, int offset);
 | 
|---|
| 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);
 | 
|---|
| 99 | 
 | 
|---|
| 100 |   /**
 | 
|---|
| 101 |    * Map to associate the known keys with numbers.
 | 
|---|
| 102 |    */
 | 
|---|
| 103 |   std::map<std::string, TremoloKey::atomDataKey> knownKeys;
 | 
|---|
| 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 |    */
 | 
|---|
| 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;
 | 
|---|
| 126 | };
 | 
|---|
| 127 | 
 | 
|---|
| 128 | #endif /* TREMOLOPARSER_HPP_ */
 | 
|---|