source: src/Parser/TremoloParser.hpp@ b3b31e

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since b3b31e was 05e2ed, checked in by Frederik Heber <heber@…>, 12 years ago

FIX: TremoloParser did not load/save imprData or torsion correctly.

  • this error was introduced when incorporating local-global-maps and conversions where this was not correctly done for the improper and torsion string:
    • conversion from local to global on load was present but went over all atoms, not just newly parsed ones. adapt.. now gets atom vector as param.
    • save did no global-local conversion. For this we generalized adaptIdDependentDataString() to get a function pointer converting ids.
  • TEST: We added a new regression test on this matter where a .data file with impropers is loaded and stored.
  • Property mode set to 100644
File size: 4.5 KB
Line 
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 config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <boost/function.hpp>
17#include <string>
18
19#include "FormatParser.hpp"
20#include "FormatParserTrait.hpp"
21#include "FormatParserInterface.hpp"
22#include "FormatParser_common.hpp"
23#include "ParserTypes.hpp"
24
25#include "TremoloParser_ElementKeys.hpp"
26#include "TremoloKey.hpp"
27#include "TremoloAtomInfoContainer.hpp"
28
29class molecule;
30class AtomDataValidator;
31
32// declaration of specialized FormatParserTrait
33template<>
34struct FormatParserTrait<tremolo>
35{
36 //!> Name of the parser
37 static const std::string name;
38 //!> suffix of the files the parser understands to read and write
39 static const std::string suffix;
40 //!> ParserTypes enumeration for the parser
41 static const enum ParserTypes type;
42};
43
44/**
45 * Loads a tremolo file into the World and saves the World as a tremolo file.
46 */
47template <>
48class FormatParser< tremolo > : virtual public FormatParserInterface, public FormatParser_common
49{
50 friend class AtomDataValidator;
51public:
52 FormatParser();
53 virtual ~FormatParser();
54 void load(std::istream* file);
55 void save(std::ostream* file, const std::vector<atom *> &atoms);
56 std::string getAtomData() const;
57 void setAtomData(const std::string &atomdata_string);
58 void resetAtomData(const std::string &atomdata_string);
59
60private:
61 /**
62 * Map to associate element keys with the respective elements.
63 */
64 struct ElementKeys knownTypes;
65
66public:
67
68 void parseKnownTypes(std::istream &file)
69 {
70 knownTypes.parseKnownTypes(file);
71 }
72 void createKnownTypesByIdentity()
73 {
74 knownTypes.createKnownTypesByIdentity();
75 }
76
77 /** Save given \a atoms in tremolo's exttypes file
78 *
79 * \note You should have stored the atoms beforehand to give them unique
80 * and sensible ids.
81 *
82 * @param output output stream
83 * @param atoms vector of atoms whose ids to store
84 * @param id id to given this exttypes group
85 * @return true - all atomic ids are valid, false - one id was not set (-1)
86 */
87 bool saveAtomsInExttypes(std::ostream &output, const std::vector<atom*> &atoms, const int id) const;
88
89protected:
90 void AtomInserted(atomId_t);
91 void AtomRemoved(atomId_t);
92
93private:
94 //!> typedef for usedFields' vector of strings
95 typedef std::vector<std::string> usedFields_t;
96
97 void readAtomDataLine(const std::string &line, molecule *newmol);
98 void parseAtomDataKeysLine(const std::string &line, const int offset, usedFields_t &fields);
99 static bool testParseAtomDataKeysLine(const std::string &line);
100 void readNeighbors(std::stringstream* line, const int numberOfNeighbors, const int atomId);
101 void processNeighborInformation(const std::vector<atomId_t> &atoms);
102 void adaptImprData(const std::vector<atomId_t> &atoms);
103 void adaptTorsion(const std::vector<atomId_t> &atoms);
104 std::string adaptIdDependentDataString(const std::string &data, const boost::function<int (const int)> &idgetter);
105 bool isUsedField(const usedFields_t &fields, const std::string &fieldName) const;
106 void writeNeighbors(std::ostream* file, const int numberOfNeighbors, const atom* currentAtom);
107 void saveLine(std::ostream* file, const atom* currentAtom);
108 void save_AtomDataLine(std::ostream* file) const;
109 void save_BoxLine(std::ostream* file) const;
110 void distributeContinuousIds(const std::vector<atom *> &AtomList);
111 void makeUsedFieldsUnique(usedFields_t &fields) const;
112
113 /**
114 * Map to associate the known keys with numbers.
115 */
116 static std::map<std::string, TremoloKey::atomDataKey> knownKeys;
117
118 /**
119 * Inverse Map to have a name to each known keys.
120 */
121 std::map<TremoloKey::atomDataKey, std::string> knownKeyNames;
122
123 /**
124 * Fields used globally when storing to a tremolo file.
125 */
126 usedFields_t usedFields_save;
127
128 /**
129 * Fields used locally when parsing in a tremolo file.
130 */
131 usedFields_t usedFields_load;
132
133 /**
134 * Data which is currently not stored in atoms but was provided by the input
135 * file.
136 */
137 std::map<const atomId_t, TremoloAtomInfoContainer> additionalAtomData;
138
139 /**
140 * Default additional atom data.
141 */
142 TremoloAtomInfoContainer defaultAdditionalData;
143
144 //!> bound function to convert id to global id, stored to avoid creation many times
145 const boost::function<int (const int)> idglobalizer;
146
147 //!> bound function to convert id to local id, stored to avoid creation many times
148 const boost::function<int (const int)> idlocalizer;
149};
150
151#endif /* TREMOLOPARSER_HPP_ */
Note: See TracBrowser for help on using the repository browser.