Changeset 4415da for src/Parser


Ignore:
Timestamp:
Apr 1, 2010, 12:16:29 PM (15 years ago)
Author:
Saskia Metzler <metzler@…>
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:
b8d4a3
Parents:
9131f3 (diff), f9352d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge Till's structure refactoring

Merge commit 'till/StructureRefactoring' into StateAndFormatParser

Conflicts:

molecuilder/src/Makefile.am
molecuilder/src/unittests/Makefile.am

Location:
src/Parser
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ChangeTracker.cpp

    r9131f3 r4415da  
    1515ChangeTracker::ChangeTracker() {
    1616  isConsistent = true;
    17   World::get()->signOn(this);
     17  World::getInstance().signOn(this);
    1818}
    1919
     
    2222 */
    2323ChangeTracker::~ChangeTracker() {
    24   World::get()->signOff(this);
     24  World::getInstance().signOff(this);
    2525}
    2626
  • src/Parser/TremoloParser.cpp

    r9131f3 r4415da  
    2020 */
    2121TremoloParser::TremoloParser() {
     22  knownKeys[" "] = noKey; // so we can detect invalid keys
    2223  knownKeys["x"] = x;
    2324  knownKeys["u"] = u;
     
    6162  while (lineStream.good()) {
    6263    lineStream >> keyword;
     64    if (knownKeys[keyword.substr(0, keyword.find("="))] == noKey) {
     65      // throw exception about unknown key
     66      cout << "Unknown key: " << keyword << " is not part of the tremolo format specification." << endl;
     67      break;
     68    }
    6369    usedFields.push_back(keyword);
    6470  }
     
    7480  vector<string>::iterator it;
    7581  stringstream lineStream;
     82  atom* newAtom = World::getInstance().createAtom();
     83  TremoloAtomInfoContainer atomInfo = *(new TremoloAtomInfoContainer());
     84  atomDataKey currentField;
    7685  string word;
    7786
     
    7988  for (it=usedFields.begin(); it < usedFields.end(); it++) {
    8089    cout << *it << " -- " << it->substr(0, it->find("=")) << " -- " << knownKeys[it->substr(0, it->find("="))] << endl;
    81     switch (knownKeys[it->substr(0, it->find("="))]) {
     90    currentField = knownKeys[it->substr(0, it->find("="))];
     91    switch (currentField) {
    8292      case x :
    83         lineStream >> word;
    84         cout<< "Found an x: word: " << word << endl;
     93        // for the moment, assume there are always three dimensions
     94        lineStream >> newAtom->x.x[0];
     95        lineStream >> newAtom->x.x[1];
     96        lineStream >> newAtom->x.x[2];
     97        break;
     98      case u :
     99        // for the moment, assume there are always three dimensions
     100        lineStream >> newAtom->v.x[0];
     101        lineStream >> newAtom->v.x[1];
     102        lineStream >> newAtom->v.x[2];
     103        break;
     104      case F :
     105        lineStream >> word;
     106        atomInfo.F = word;
     107        break;
     108      case stress :
     109        lineStream >> word;
     110        atomInfo.F = word;
     111       break;
     112      case Id :
     113        // this ID is not used
     114        break;
     115      case neighbors :
     116        // TODO neighbor information
     117        lineStream >> word;
     118        break;
     119      case imprData :
     120        lineStream >> word;
     121        atomInfo.imprData = word;
     122        break;
     123      case GroupMeasureTypeNo :
     124        lineStream >> word;
     125        atomInfo.GroupMeasureTypeNo = word;
     126        break;
     127      case Type :
     128        char type[3];
     129        lineStream >> type;
     130        newAtom->setType(World::getInstance().getPeriode()->FindElement(type));
     131        break;
     132      case extType :
     133        lineStream >> word;
     134        atomInfo.extType = word;
     135        break;
     136      case name :
     137        lineStream >> word;
     138        atomInfo.name = word;
     139        break;
     140      case resName :
     141        lineStream >> word;
     142        atomInfo.resName = word;
     143        break;
     144      case chainID :
     145        lineStream >> word;
     146        atomInfo.chainID = word;
     147        break;
     148      case resSeq :
     149        lineStream >> word;
     150        atomInfo.resSeq = word;
     151        break;
     152      case occupancy :
     153        lineStream >> word;
     154        atomInfo.occupancy = word;
     155        break;
     156      case tempFactor :
     157        lineStream >> word;
     158        atomInfo.segID = word;
     159        break;
     160      case segID :
     161        lineStream >> word;
     162        atomInfo.F = word;
     163        break;
     164      case Charge :
     165        lineStream >> word;
     166        atomInfo.Charge = word;
     167        break;
     168      case charge :
     169        lineStream >> word;
     170        atomInfo.charge = word;
     171        break;
     172      case GrpTypeNo :
     173        lineStream >> word;
     174        atomInfo.GrpTypeNo = word;
    85175        break;
    86176      default :
     
    90180    }
    91181  }
     182  moreData[newAtom->getId()] = atomInfo;
    92183}
    93184
     
    117208}
    118209
    119 /*
    120 #ATOMDATA  <record_entry_1> ... <record_entry_n>
    121 # <record_entry>: <dataname>[=<n>]
    122 # <dataname>    : x | u | F | stress | Id | neighbors | imprData
    123 #               | GroupMeasureTypeNo | Type | extType
    124 #               | name | resName | chainID | resSeq
    125 #               | occupancy | tempFactor | segID | Charge
    126 #               | charge
    127 ATOMDATA name Id x=3 mass charge epsilon sigma eps14 sig14 name type protein protno neighbors=4
    128 */
    129 
    130 //MatrixContainer* data = readData(fileName, getHeaderSize('#'), 0);
    131 
    132 
    133210/**
    134211 * Saves the World's current state into as a tremolo file.
     
    144221*/
    145222}
     223
     224TremoloAtomInfoContainer::TremoloAtomInfoContainer() {
     225  name = "none";
     226  /* Add suitable default values.
     227  std::string F;
     228  std::string stress;
     229  std::string imprData;
     230  std::string GroupMeasureTypeNo;
     231  std::string extType;
     232  std::string name;
     233  std::string resName;
     234  std::string chainID;
     235  std::string resSeq;
     236  std::string occupancy;
     237  std::string tempFactor;
     238  std::string segID;
     239  std::string Charge;
     240  std::string charge;
     241  std::string GrpTypeNo;
     242*/
     243};
  • src/Parser/TremoloParser.hpp

    r9131f3 r4415da  
    1212#include "FormatParser.hpp"
    1313
     14/**
     15 * Holds tremolo-specific information which is not store in the atom class.
     16 */
     17class TremoloAtomInfoContainer {
     18public:
     19  TremoloAtomInfoContainer();
     20  std::string F;
     21  std::string stress;
     22  std::string imprData;
     23  std::string GroupMeasureTypeNo;
     24  std::string extType;
     25  std::string name;
     26  std::string resName;
     27  std::string chainID;
     28  std::string resSeq;
     29  std::string occupancy;
     30  std::string tempFactor;
     31  std::string segID;
     32  std::string Charge;
     33  std::string charge;
     34  std::string GrpTypeNo;
     35};
     36
     37/**
     38 * Loads a tremolo file into the World and saves the World as a tremolo file.
     39 */
    1440class TremoloParser:public FormatParser
    1541{
     
    2753   * Known keys for the ATOMDATA line.
    2854   */
    29   enum StringValue {
     55  enum atomDataKey {
     56    noKey,
    3057    x,
    3158    u,
     
    5380   * Map to associate the known keys with numbers.
    5481   */
    55   std::map<std::string, StringValue> knownKeys;
     82  std::map<std::string, atomDataKey> knownKeys;
    5683
    5784  /**
     
    6491   * file.
    6592   */
    66   std::map<std::string, std::string> moreData;
     93  std::map<int, TremoloAtomInfoContainer> moreData;
    6794};
    6895
  • src/Parser/XyzParser.cpp

    r9131f3 r4415da  
    4444
    4545  for (int i = 0; i < numberOfAtoms; i++) {
    46     newAtom = World::get()->createAtom();
     46    newAtom = World::getInstance().createAtom();
    4747    *file >> type >> ws >> newAtom->x.x[0] >> ws >> newAtom->x.x[1] >> ws >> newAtom->x.x[2];
    48     newAtom->setType(World::get()->getPeriode()->FindElement(type));
     48    newAtom->setType(World::getInstance().getPeriode()->FindElement(type));
    4949  }
    5050}
     
    5656 */
    5757void XyzParser::save(ostream* file) {
    58   *file << World::get()->numAtoms() << endl << comment << endl;
     58  *file << World::getInstance().numAtoms() << endl << comment << endl;
    5959
    60   vector<atom*> atoms = World::get()->getAllAtoms();
     60  vector<atom*> atoms = World::getInstance().getAllAtoms();
    6161  for(vector<atom*>::iterator it = atoms.begin(); it < atoms.end(); it++) {
    6262    *file << fixed << (*it)->getType()->symbol << "\t" << (*it)->x.x[0] << "\t" << (*it)->x.x[1] << "\t" << (*it)->x.x[2] << endl;
Note: See TracChangeset for help on using the changeset viewer.