Changeset b0a2e3 for src/Parser


Ignore:
Timestamp:
Feb 24, 2011, 8:18:39 PM (14 years ago)
Author:
Frederik Heber <heber@…>
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:
3e383d
Parents:
09c7a9
Message:

Removed use of PdbKey::timestep, steps are parsed sequentially.

  • PdbParser::readAtomDataLine() and PdbParser::readNeighbors() have additional parameter steps.
Location:
src/Parser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/PdbParser.cpp

    r09c7a9 rb0a2e3  
    116116  molecule *newmol = World::getInstance().createMolecule();
    117117  newmol->ActiveFlag = true;
     118  unsigned int step = 0;
    118119  // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include
    119120  World::getInstance().getMolecules()->insert(newmol);
    120121  while (NotEndOfFile) {
    121122    bool NotEndOfTimestep = true;
    122     while (NotEndOfTimestep) {
     123    while (NotEndOfTimestep && NotEndOfFile) {
    123124      std::getline(*file, line, '\n');
    124       // extract first token
    125       token = getToken(line);
    126       switch (token) {
    127         case PdbKey::Atom:
    128           LOG(3,"INFO: Parsing ATOM entry.");
    129           readAtomDataLine(line, newmol);
    130           break;
    131         case PdbKey::Remark:
    132           LOG(3,"INFO: Parsing REM entry.");
    133           break;
    134         case PdbKey::Connect:
    135           LOG(3,"INFO: Parsing CONECT entry.");
    136           readNeighbors(line);
    137           break;
    138         case PdbKey::Filler:
    139           LOG(3,"INFO: Stumbled upon Filler entry.");
    140           break;
    141         case PdbKey::EndOfTimestep:
    142           LOG(3,"INFO: Parsing END entry or empty line.");
    143           NotEndOfTimestep = false;
    144           break;
    145         default:
    146           // TODO: put a throw here
    147           DoeLog(2) && (eLog() << Verbose(2) << "Unknown token: '" << line << "'" << std::endl);
    148           //ASSERT(0, "PdbParser::load() - Unknown token in line "+toString(linecount)+": "+line+".");
    149           break;
     125      if (!line.empty()) {
     126        // extract first token
     127        token = getToken(line);
     128        switch (token) {
     129          case PdbKey::Atom:
     130            LOG(3,"INFO: Parsing ATOM entry for time step " << step << ".");
     131            readAtomDataLine(step, line, newmol);
     132            break;
     133          case PdbKey::Remark:
     134            LOG(3,"INFO: Parsing REM entry for time step " << step << ".");
     135            break;
     136          case PdbKey::Connect:
     137            LOG(3,"INFO: Parsing CONECT entry for time step " << step << ".");
     138            readNeighbors(step, line);
     139            break;
     140          case PdbKey::Filler:
     141            LOG(3,"INFO: Stumbled upon Filler entry for time step " << step << ".");
     142            break;
     143          case PdbKey::EndOfTimestep:
     144            LOG(3,"INFO: Parsing END entry or empty line for time step " << step << ".");
     145            NotEndOfTimestep = false;
     146            break;
     147          default:
     148            // TODO: put a throw here
     149            DoeLog(2) && (eLog() << Verbose(2) << "Unknown token: '" << line << "' for time step " << step << "." << std::endl);
     150            //ASSERT(0, "PdbParser::load() - Unknown token in line "+toString(linecount)+": "+line+".");
     151            break;
     152        }
    150153      }
    151154      NotEndOfFile = NotEndOfFile && (file->good());
    152155      linecount++;
     156    }
     157    ++step;
     158  }
     159  BOOST_FOREACH(atom *_atom, World::getInstance().getAllAtoms()) {
     160    for (size_t i=0; i < _atom->getTrajectorySize(); ++i) {
     161      LOG(2, "INFO: Atom " << _atom->getName() << " is at "
     162          << _atom->getPositionAtStep(i) << " at time step " << i << ".");
    153163    }
    154164  }
     
    491501 *  standard information is placed in additionalAtomData at the atom's id.
    492502 *
     503 * \param _step time step to use
    493504 * \param line to parse as an atom
    494505 * \param newmol molecule to add parsed atoms to
    495506 */
    496 void PdbParser::readAtomDataLine(std::string &line, molecule *newmol = NULL) {
     507void PdbParser::readAtomDataLine(const unsigned int _step, std::string &line, molecule *newmol = NULL) {
    497508  vector<string>::iterator it;
    498509
     
    500511  LOG(3,"INFO: Parsing END entry or empty line.");
    501512  bool FirstTimestep = isPresentadditionalAtomData(newAtom->getId()) ? false : true;
     513  ASSERT((FirstTimestep && (_step == 0)) || (!FirstTimestep && (_step !=0)),
     514      "PdbParser::readAtomDataLine() - logig mismatch between FirstTimestep and step == 0.");
    502515  if (FirstTimestep) {
    503516    LOG(3,"INFO: Parsing new atom.");
     
    619632    PdbAtomInfoContainer::ScanKey(tempVector[1], line.substr(38,8));
    620633    PdbAtomInfoContainer::ScanKey(tempVector[2], line.substr(46,8));
    621     // increase time step
    622     size_t timestep = atomInfo.get<size_t>(PdbKey::timestep)+1;
    623     atomInfo.set(PdbKey::timestep, toString(timestep));
    624     LOG(4,"INFO: Adding time step "+atomInfo.get<std::string>(PdbKey::timestep)+".");
     634    LOG(4,"INFO: Adding trajectory point to time step "+toString(_step)+".");
    625635    // and set position at new time step
    626     newAtom->setPositionAtStep(timestep, tempVector);
     636    newAtom->setPositionAtStep(_step, tempVector);
    627637  }
    628638
     
    659669 * Reads neighbor information for one atom from the input.
    660670 *
     671 * \param _step time step to use
    661672 * \param line to parse as an atom
    662673 */
    663 void PdbParser::readNeighbors(std::string &line)
     674void PdbParser::readNeighbors(const unsigned int _step, std::string &line)
    664675{
    665676  const size_t length = line.length();
     
    693704//    DoLog(1) && (Log() << Verbose(1) << "Adding Bond (" << getAtomId(id) << "," << getAtomId(*iter) << ")" << std::endl);
    694705    atom * const _Otheratom = World::getInstance().getAtom(AtomById(getSerial(*iter)));
    695     _atom->addBond(WorldTime::getTime(), _Otheratom);
     706    _atom->addBond(_step, _Otheratom);
    696707  }
    697708}
  • src/Parser/PdbParser.hpp

    r09c7a9 rb0a2e3  
    3636private:
    3737  enum PdbKey::KnownTokens getToken(string &line);
    38   void readAtomDataLine(string &line, molecule *newmol);
     38  void readAtomDataLine(const unsigned int _step, string &line, molecule *newmol);
    3939  void parseAtomDataKeysLine(string line, int offset);
    40   void readNeighbors(std::string &line);
     40  void readNeighbors(const unsigned int _step, std::string &line);
    4141//  void adaptImprData();
    4242//  void adaptTorsion();
Note: See TracChangeset for help on using the changeset viewer.