Changeset 5a667d
- Timestamp:
- Jun 14, 2012, 9:02:58 AM (13 years ago)
- Branches:
- 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
- Children:
- 27cfde
- Parents:
- 2169e0
- git-author:
- Michael Ankele <ankele@…> (05/14/12 11:54:32)
- git-committer:
- Frederik Heber <heber@…> (06/14/12 09:02:58)
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parameters/Validators/Specific/AtomDataValidator.cpp
r2169e0 r5a667d 23 23 #include "AtomDataValidator.hpp" 24 24 25 #include "Parser/TremoloParser.hpp" 26 25 27 bool AtomDataValidator::isValid(const std::string & _value) const 26 28 { 27 return true; // TODO29 return FormatParser< tremolo >::testParseAtomDataKeysLine(_value); 28 30 } 29 31 -
src/Parser/TremoloParser.cpp
r2169e0 r5a667d 49 49 #include <vector> 50 50 51 #include <boost/assign/list_of.hpp> // for 'map_list_of()' 52 #include <boost/assert.hpp> 53 51 54 // declare specialized static variables 52 55 const std::string FormatParserTrait<tremolo>::name = "tremolo"; … … 54 57 const ParserTypes FormatParserTrait<tremolo>::type = tremolo; 55 58 59 // static instances 60 std::map<std::string, TremoloKey::atomDataKey> FormatParser<tremolo>::knownKeys = 61 boost::assign::map_list_of("x",TremoloKey::x) 62 ("u",TremoloKey::u) 63 ("F",TremoloKey::F) 64 ("stress",TremoloKey::stress) 65 ("Id",TremoloKey::Id) 66 ("neighbors",TremoloKey::neighbors) 67 ("imprData",TremoloKey::imprData) 68 ("GroupMeasureTypeNo",TremoloKey::GroupMeasureTypeNo) 69 ("type",TremoloKey::type) 70 ("extType",TremoloKey::extType) 71 ("name",TremoloKey::name) 72 ("resName",TremoloKey::resName) 73 ("chainID",TremoloKey::chainID) 74 ("resSeq",TremoloKey::resSeq) 75 ("occupancy",TremoloKey::occupancy) 76 ("tempFactor",TremoloKey::tempFactor) 77 ("segID",TremoloKey::segID) 78 ("Charge",TremoloKey::Charge) 79 ("charge",TremoloKey::charge) 80 ("GrpTypeNo",TremoloKey::GrpTypeNo) 81 ("torsion",TremoloKey::torsion) 82 (" ",TremoloKey::noKey); // with this we can detect invalid keys 83 56 84 /** 57 85 * Constructor. … … 60 88 FormatParser_common(NULL) 61 89 { 62 knownKeys["x"] = TremoloKey::x;63 knownKeys["u"] = TremoloKey::u;64 knownKeys["F"] = TremoloKey::F;65 knownKeys["stress"] = TremoloKey::stress;66 knownKeys["Id"] = TremoloKey::Id;67 knownKeys["neighbors"] = TremoloKey::neighbors;68 knownKeys["imprData"] = TremoloKey::imprData;69 knownKeys["GroupMeasureTypeNo"] = TremoloKey::GroupMeasureTypeNo;70 knownKeys["type"] = TremoloKey::type;71 knownKeys["extType"] = TremoloKey::extType;72 knownKeys["name"] = TremoloKey::name;73 knownKeys["resName"] = TremoloKey::resName;74 knownKeys["chainID"] = TremoloKey::chainID;75 knownKeys["resSeq"] = TremoloKey::resSeq;76 knownKeys["occupancy"] = TremoloKey::occupancy;77 knownKeys["tempFactor"] = TremoloKey::tempFactor;78 knownKeys["segID"] = TremoloKey::segID;79 knownKeys["Charge"] = TremoloKey::Charge;80 knownKeys["charge"] = TremoloKey::charge;81 knownKeys["GrpTypeNo"] = TremoloKey::GrpTypeNo;82 knownKeys["torsion"] = TremoloKey::torsion;83 knownKeys[" "] = TremoloKey::noKey; // with this we can detect invalid keys84 85 90 createKnownTypesByIdentity(); 86 91 … … 92 97 } 93 98 99 94 100 /** 95 101 * Destructor. … … 99 105 usedFields_save.clear(); 100 106 additionalAtomData.clear(); 101 knownKeys.clear();102 107 } 103 108 … … 441 446 if (knownKeys[keyword.substr(0, keyword.find("="))] == TremoloKey::noKey) { 442 447 // TODO: throw exception about unknown key 443 cout << "Unknown key: " << keyword << " is not part of the tremolo format specification." << endl; 448 cout << "Unknown key: " << keyword.substr(0, keyword.find("=")) << " is not part of the tremolo format specification." << endl; 449 throw IllegalParserKeyException(); 444 450 break; 445 451 } … … 447 453 } 448 454 //LOG(1, "INFO: " << fields); 455 } 456 457 /** 458 * Tests whether the keys from the ATOMDATA line can be read correctly. 459 * 460 * \param line to parse the keys from 461 */ 462 bool FormatParser< tremolo >::testParseAtomDataKeysLine( 463 const std::string &line) { 464 std::string keyword; 465 std::stringstream lineStream; 466 467 // check string after ATOMDATA 468 const std::string AtomData("ATOMDATA"); 469 const size_t AtomDataOffset = line.find(AtomData, 0); 470 if (AtomDataOffset == std::string::npos) 471 lineStream << line; 472 else 473 lineStream << line.substr(AtomDataOffset + AtomData.length()); 474 while (lineStream.good()) { 475 lineStream >> keyword; 476 //LOG(2, "DEBUG: Checking key " << keyword.substr(0, keyword.find("=")) << "."); 477 if (knownKeys[keyword.substr(0, keyword.find("="))] == TremoloKey::noKey) 478 return false; 479 } 480 //LOG(1, "INFO: " << fields); 481 return true; 449 482 } 450 483 -
src/Parser/TremoloParser.hpp
r2169e0 r5a667d 27 27 28 28 class molecule; 29 class AtomDataValidator; 29 30 30 31 // declaration of specialized FormatParserTrait … … 46 47 class FormatParser< tremolo > : virtual public FormatParserInterface, public FormatParser_common 47 48 { 49 friend class AtomDataValidator; 48 50 public: 49 51 FormatParser(); … … 92 94 void readAtomDataLine(const std::string &line, molecule *newmol); 93 95 void parseAtomDataKeysLine(const std::string &line, const int offset, usedFields_t &fields); 96 static bool testParseAtomDataKeysLine(const std::string &line); 94 97 void readNeighbors(std::stringstream* line, const int numberOfNeighbors, const int atomId); 95 98 void processNeighborInformation(const std::vector<atomId_t> &atoms); … … 108 111 * Map to associate the known keys with numbers. 109 112 */ 110 st d::map<std::string, TremoloKey::atomDataKey> knownKeys;113 static std::map<std::string, TremoloKey::atomDataKey> knownKeys; 111 114 112 115 /** -
src/Parser/unittests/ParserTremoloUnitTest.cpp
r2169e0 r5a667d 23 23 #include <cppunit/extensions/TestFactoryRegistry.h> 24 24 #include <cppunit/ui/text/TestRunner.h> 25 26 #include "CodePatterns/Log.hpp" 25 27 26 28 #include "Atom/atom.hpp" … … 91 93 World::getInstance(); 92 94 95 setVerbosity(5); 96 93 97 parser = new FormatParser<tremolo>(); 94 98 … … 139 143 // Invalid key in Atomdata line 140 144 input << Tremolo_invalidkey; 141 parser->load(&input);145 CPPUNIT_ASSERT_THROW( parser->load(&input), IllegalParserKeyException); 142 146 //TODO: prove invalidity 143 147 input.clear();
Note:
See TracChangeset
for help on using the changeset viewer.