source: src/Parser/PdbParser.hpp@ ff4fff9

CombiningParticlePotentialParsing
Last change on this file since ff4fff9 was fac58f, checked in by Frederik Heber <heber@…>, 9 years ago

Converted FormatParser::save() to using vector of const atom ptrs.

  • required to change all save() functions in all parsers.
  • Property mode set to 100644
File size: 2.9 KB
Line 
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
28class molecule;
29class ParserPdbUnitTest;
30
31// declaration of specialized FormatParserTrait
32template<>
33struct 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 */
46template <>
47class FormatParser< pdb > : virtual public FormatParserInterface, public FormatParser_common
48{
49 //!> grant pdb test access to private parts
50 friend class ParserPdbUnitTest;
51public:
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
60protected:
61 void AtomInserted(atomId_t);
62 void AtomRemoved(atomId_t);
63
64private:
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_ */
Note: See TracBrowser for help on using the repository browser.