[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 |
|
---|
| 16 |
|
---|
[3ae731] | 17 | #include <string>
|
---|
[4fbca9c] | 18 | #include "FormatParser.hpp"
|
---|
| 19 | #include "PdbAtomInfoContainer.hpp"
|
---|
| 20 | #include "PdbKey.hpp"
|
---|
[3ae731] | 21 |
|
---|
| 22 | /**
|
---|
[4fbca9c] | 23 | * Loads a PDB format 3.2 file into the World and saves the World as a PDB file.
|
---|
[3ae731] | 24 | */
|
---|
| 25 | class PdbParser : public FormatParser
|
---|
| 26 | {
|
---|
| 27 | public:
|
---|
| 28 | PdbParser();
|
---|
| 29 | ~PdbParser();
|
---|
| 30 | void load(std::istream* file);
|
---|
[73916f] | 31 | void save(std::ostream* file, const std::vector<atom *> &atoms);
|
---|
[3ae731] | 32 |
|
---|
[4fbca9c] | 33 | bool operator==(const PdbParser& b) const;
|
---|
| 34 | void printAtomInfo(const atom *newAtom) const;
|
---|
[3ae731] | 35 |
|
---|
| 36 | private:
|
---|
[4fbca9c] | 37 | enum PdbKey::KnownTokens getToken(string &line);
|
---|
[b0a2e3] | 38 | void readAtomDataLine(const unsigned int _step, string &line, molecule *newmol);
|
---|
[3ae731] | 39 | void parseAtomDataKeysLine(string line, int offset);
|
---|
[b0a2e3] | 40 | void readNeighbors(const unsigned int _step, std::string &line);
|
---|
[4fbca9c] | 41 | // void adaptImprData();
|
---|
| 42 | // void adaptTorsion();
|
---|
| 43 | // std::string adaptIdDependentDataString(std::string data);
|
---|
[3ae731] | 44 | bool isUsedField(std::string fieldName);
|
---|
| 45 | void writeNeighbors(std::ostream* file, int numberOfNeighbors, atom* currentAtom);
|
---|
[16462f] | 46 | void saveLine(ostream* file, const PdbAtomInfoContainer &atomInfo);
|
---|
[4fbca9c] | 47 |
|
---|
| 48 | // internal getter and setter
|
---|
[9dba5f] | 49 | bool isPresentadditionalAtomData(unsigned int _id);
|
---|
[93fd43e] | 50 | PdbAtomInfoContainer& getadditionalAtomData(atom *_atom);
|
---|
[4fbca9c] | 51 | size_t getSerial(const size_t atomid) const;
|
---|
[16462f] | 52 | void setSerial(const size_t localatomid, const size_t atomid);
|
---|
| 53 |
|
---|
[9dba5f] | 54 | // internal helper functions
|
---|
| 55 | atom* getAtomToParse(std::string id_string) const;
|
---|
| 56 | void readPdbAtomInfoContainer(PdbAtomInfoContainer &atomInfo, std::string &line) const;
|
---|
| 57 |
|
---|
[16462f] | 58 | /**
|
---|
| 59 | * argh, why can't just PdbKey::X+(size_t)i
|
---|
| 60 | */
|
---|
| 61 | std::map<size_t, PdbKey::PdbDataKey> PositionEnumMap;
|
---|
[3ae731] | 62 |
|
---|
| 63 | /**
|
---|
| 64 | * Map to associate the known keys with numbers.
|
---|
| 65 | */
|
---|
[4fbca9c] | 66 | std::map<std::string, PdbKey::KnownTokens> knownTokens;
|
---|
[3ae731] | 67 |
|
---|
| 68 | /**
|
---|
| 69 | * Data which is currently not stored in atoms but was provided by the input
|
---|
| 70 | * file.
|
---|
| 71 | */
|
---|
[4fbca9c] | 72 | std::map<size_t, PdbAtomInfoContainer> additionalAtomData;
|
---|
[3ae731] | 73 |
|
---|
| 74 | /**
|
---|
| 75 | * Default additional atom data.
|
---|
| 76 | */
|
---|
[bb6193] | 77 | PdbAtomInfoContainer defaultAdditionalData;
|
---|
[3ae731] | 78 |
|
---|
| 79 | /**
|
---|
| 80 | * Maps original atom IDs received from the parsed file to atom IDs in the
|
---|
| 81 | * world.
|
---|
| 82 | */
|
---|
[4fbca9c] | 83 | std::map<size_t, size_t> atomIdMap;
|
---|
| 84 |
|
---|
| 85 | /**
|
---|
[9dba5f] | 86 | * Ascertaining uniqueness of Ids.
|
---|
[4fbca9c] | 87 | */
|
---|
| 88 | std::set<size_t> SerialSet;
|
---|
| 89 |
|
---|
[3ae731] | 90 | };
|
---|
| 91 |
|
---|
| 92 | #endif /* PDBPARSER_HPP_ */
|
---|