Changeset 73916f for src/Parser
- Timestamp:
- Dec 16, 2010, 5:32:22 PM (14 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:
- fc5c3a
- Parents:
- 512f85
- git-author:
- Frederik Heber <heber@…> (12/11/10 15:57:00)
- git-committer:
- Frederik Heber <heber@…> (12/16/10 17:32:22)
- Location:
- src/Parser
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/FormatParser.cpp
r512f85 r73916f 52 52 } 53 53 54 save(saveStream); 54 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 55 save(saveStream, atoms); 55 56 } 56 57 -
src/Parser/FormatParser.hpp
r512f85 r73916f 13 13 #include "parser.hpp" 14 14 15 class atom; 16 15 17 /** 16 18 * General parser which observes the change tracker. … … 20 22 FormatParser(); 21 23 virtual ~FormatParser(); 22 virtual void save(std::ostream* file )=0;24 virtual void save(std::ostream* file, const std::vector<atom *> &atoms)=0; 23 25 virtual void load(std::istream* file)=0; 24 26 void setOstream(std::ostream* file); -
src/Parser/FormatParserStorage.cpp
r512f85 r73916f 36 36 37 37 #include "Helpers/Assert.hpp" 38 39 #include "molecule.hpp" 38 40 39 41 #include "Patterns/Singleton_impl.hpp" … … 224 226 * \return true - parsing ok, false - suffix unknown 225 227 */ 226 bool FormatParserStorage:: get(std::istream &input, std::string suffix)228 bool FormatParserStorage::load(std::istream &input, std::string suffix) 227 229 { 228 230 if (suffix == ParserSuffixes[mpqc]) { … … 243 245 } 244 246 247 /** Stores all selected atoms in an ostream depending on its suffix 248 * \param &output output stream 249 * \param suffix 250 * \return true - storing ok, false - suffix unknown 251 */ 252 bool FormatParserStorage::saveSelectedAtoms(std::ostream &output, std::string suffix) 253 { 254 std::vector<atom *> atoms = World::getInstance().getSelectedAtoms(); 255 return save(output, suffix, atoms); 256 } 257 258 /** Stores all selected atoms in an ostream depending on its suffix 259 * We store in the order of the atomic ids, not in the order they appear in the molecules. 260 * Hence, we first create a vector from all selected molecules' atoms. 261 * \param &output output stream 262 * \param suffix 263 * \return true - storing ok, false - suffix unknown 264 */ 265 bool FormatParserStorage::saveSelectedMolecules(std::ostream &output, std::string suffix) 266 { 267 std::vector<molecule *> molecules = World::getInstance().getSelectedMolecules(); 268 std::map<size_t, atom *> IdAtoms; 269 for (std::vector<molecule *>::const_iterator MolIter = molecules.begin(); 270 MolIter != molecules.end(); 271 ++MolIter) { 272 for(molecule::atomSet::const_iterator AtomIter = (*MolIter)->begin(); 273 AtomIter != (*MolIter)->end(); 274 ++AtomIter) { 275 IdAtoms.insert( make_pair((*AtomIter)->getId(), (*AtomIter)) ); 276 } 277 } 278 std::vector<atom *> atoms; 279 atoms.reserve(IdAtoms.size()); 280 for (std::map<size_t, atom *>::const_iterator iter = IdAtoms.begin(); 281 iter != IdAtoms.end(); 282 ++iter) { 283 atoms.push_back(iter->second); 284 } 285 return save(output, suffix, atoms); 286 } 245 287 246 288 /** Stores world in an ostream depending on its suffix … … 249 291 * \return true - storing ok, false - suffix unknown 250 292 */ 251 bool FormatParserStorage::put(std::ostream &output, std::string suffix) 293 bool FormatParserStorage::saveWorld(std::ostream &output, std::string suffix) 294 { 295 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 296 return save(output, suffix, atoms); 297 } 298 299 /** Stores a given vector of \a atoms in an ostream depending on its suffix 300 * \param &output output stream 301 * \param suffix 302 * \return true - storing ok, false - suffix unknown 303 */ 304 bool FormatParserStorage::save(std::ostream &output, std::string suffix, const std::vector<atom *> &atoms) 252 305 { 253 306 if (suffix == ParserSuffixes[mpqc]) { 254 getMpqc().save(&output );307 getMpqc().save(&output, atoms); 255 308 } else if (suffix == ParserSuffixes[pcp]) { 256 getPcp().save(&output );309 getPcp().save(&output, atoms); 257 310 } else if (suffix == ParserSuffixes[pdb]) { 258 getPdb().save(&output );311 getPdb().save(&output, atoms); 259 312 } else if (suffix == ParserSuffixes[tremolo]) { 260 getTremolo().save(&output );313 getTremolo().save(&output, atoms); 261 314 } else if (suffix == ParserSuffixes[xyz]) { 262 getXyz().save(&output );315 getXyz().save(&output, atoms); 263 316 } else { 264 317 DoeLog(1) && (eLog() << Verbose(1) << "Unknown suffix " << suffix << " to for FormatParserStorage::put()." << endl); -
src/Parser/FormatParserStorage.hpp
r512f85 r73916f 20 20 #include <vector> 21 21 22 class atom; 22 23 class FormatParser; 23 24 class MpqcParser; … … 45 46 bool add(ParserTypes type); 46 47 47 bool get(std::istream &input, std::string suffix); 48 bool put(std::ostream &output, std::string suffix); 48 bool load(std::istream &input, std::string suffix); 49 bool save(std::ostream &output, std::string suffix, const std::vector<atom *> &atoms); 50 bool saveSelectedAtoms(std::ostream &output, std::string suffix); 51 bool saveSelectedMolecules(std::ostream &output, std::string suffix); 52 bool saveWorld(std::ostream &output, std::string suffix); 49 53 MpqcParser &getMpqc(); 50 54 PcpParser &getPcp(); -
src/Parser/MpqcParser.cpp
r512f85 r73916f 53 53 } 54 54 55 void MpqcParser::save(ostream *file) 55 /** 56 * Saves the \a atoms into as a MPQC file. 57 * 58 * \param file where to save the state 59 * \param atoms atoms to store 60 */ 61 void MpqcParser::save(ostream *file, const std::vector<atom *> &atoms) 56 62 { 57 63 DoLog(0) && (Log() << Verbose(0) << "Saving changes to MPQC ." << std::endl); 58 64 59 65 if (HessianPresent) 60 saveHessian(file );66 saveHessian(file, atoms); 61 67 else 62 saveSimple(file );68 saveSimple(file, atoms); 63 69 } 64 70 65 71 /** Saves all atoms and data into a MPQC config file without hessian. 66 72 * \param *file output stream 73 * \param atoms atoms to store 67 74 */ 68 void MpqcParser::saveSimple(ostream *file )75 void MpqcParser::saveSimple(ostream *file, const std::vector<atom *> &atoms) 69 76 { 70 77 Vector center; … … 112 119 /** Saves all atoms and data into a MPQC config file with hessian. 113 120 * \param *file output stream 121 * \param atoms atoms to store 114 122 */ 115 void MpqcParser::saveHessian(ostream *file )123 void MpqcParser::saveHessian(ostream *file, const std::vector<atom *> &atoms) 116 124 { 117 125 Vector center; -
src/Parser/MpqcParser.hpp
r512f85 r73916f 22 22 ~MpqcParser(); 23 23 void load(std::istream* file); 24 void save(std::ostream* file );24 void save(std::ostream* file, const std::vector<atom *> &atoms); 25 25 26 26 void setHessian(bool hessian); … … 30 30 bool HessianPresent; 31 31 32 void saveSimple(std::ostream *file );33 void saveHessian(std::ostream *file );32 void saveSimple(std::ostream *file, const std::vector<atom *> &atoms); 33 void saveHessian(std::ostream *file, const std::vector<atom *> &atoms); 34 34 }; 35 35 -
src/Parser/PcpParser.cpp
r512f85 r73916f 368 368 } 369 369 370 /** Saves the World into a PCP config file. 371 * \param *file output stream to save to 372 */ 373 void PcpParser::save(std::ostream* file) 370 /** 371 * Saves the \a atoms into as a PCP file. 372 * 373 * \param file where to save the state 374 * \param atoms atoms to store 375 */ 376 void PcpParser::save(std::ostream* file, const std::vector<atom *> &atoms) 374 377 { 375 378 DoLog(0) && (Log() << Verbose(0) << "Saving changes to pcp." << std::endl); … … 379 382 if (!file->fail()) { 380 383 // calculate number of Psis 381 vector<atom *> allatoms = World::getInstance().getAllAtoms(); 382 CalculateOrbitals(allatoms); 384 CalculateOrbitals(atoms); 383 385 *file << "# ParallelCarParinello - main configuration file - created with molecuilder" << endl; 384 386 *file << endl; … … 468 470 *file << "RelativeCoord\t" << RelativeCoord << "\t# whether ion coordinates are relative (1) or absolute (0)" << endl; 469 471 map<int, int> ZtoIndexMap; 470 OutputElements(file, a llatoms, ZtoIndexMap);471 OutputAtoms(file, a llatoms, ZtoIndexMap);472 OutputElements(file, atoms, ZtoIndexMap); 473 OutputAtoms(file, atoms, ZtoIndexMap); 472 474 } else { 473 475 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open output file." << endl); … … 479 481 * \param &allatoms all atoms to store away 480 482 */ 481 void PcpParser::CalculateOrbitals( vector<atom *> &allatoms)483 void PcpParser::CalculateOrbitals(const std::vector<atom *> &allatoms) 482 484 { 483 485 PlaneWaveSpecifics.MaxPsiDouble = PlaneWaveSpecifics.PsiMaxNoDown = PlaneWaveSpecifics.PsiMaxNoUp = PlaneWaveSpecifics.PsiType = 0; 484 for (vector<atom *>:: iterator runner = allatoms.begin(); runner != allatoms.end(); ++runner) {486 for (vector<atom *>::const_iterator runner = allatoms.begin(); runner != allatoms.end(); ++runner) { 485 487 PlaneWaveSpecifics.MaxPsiDouble += (*runner)->getType()->getNoValenceOrbitals(); 486 488 } … … 512 514 * \param &ZtoIndexMap map of which atoms belong to which ion number 513 515 */ 514 void PcpParser::OutputElements(ostream *file, vector<atom *> &allatoms, map<int, int> &ZtoIndexMap)516 void PcpParser::OutputElements(ostream *file, const std::vector<atom *> &allatoms, map<int, int> &ZtoIndexMap) 515 517 { 516 518 map<int, int> PresentElements; 517 519 pair < map<int, int>::iterator, bool > Inserter; 518 520 // insert all found elements into the map 519 for (vector<atom *>:: iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) {521 for (vector<atom *>::const_iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) { 520 522 Inserter = PresentElements.insert(pair<int, int>((*AtomRunner)->getType()->getAtomicNumber(), 1)); 521 523 if (!Inserter.second) // increase if present … … 542 544 * \param &ZtoIndexMap map of which atoms belong to which ion number 543 545 */ 544 void PcpParser::OutputAtoms(ostream *file, vector<atom *> &allatoms, map<int, int> &ZtoIndexMap)546 void PcpParser::OutputAtoms(ostream *file, const std::vector<atom *> &allatoms, map<int, int> &ZtoIndexMap) 545 547 { 546 548 *file << "#Ion_TypeNr._Nr.R[0] R[1] R[2] MoveType (0 MoveIon, 1 FixedIon)" << endl; … … 548 550 pair < map<int, int>::iterator, bool > Inserter; 549 551 int nr = 0; 550 for (vector<atom *>:: iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) {552 for (vector<atom *>::const_iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) { 551 553 Inserter = ZtoCountMap.insert( pair<int, int>((*AtomRunner)->getType()->getAtomicNumber(), 1) ); 552 554 if (!Inserter.second) -
src/Parser/PcpParser.hpp
r512f85 r73916f 20 20 ~PcpParser(); 21 21 void load(std::istream* file); 22 void save(std::ostream* file );22 void save(std::ostream* file, const std::vector<atom *> &atoms); 23 23 24 24 bool operator==(const PcpParser& b) const; … … 27 27 28 28 void ParseThermostats(class ConfigFileBuffer * const fb); 29 void OutputAtoms(ostream *file, vector<atom *> &allatoms, map<int, int> &ZtoIndexMap);30 void OutputElements(ostream *file, vector<atom *> &allatoms, map<int, int> &ZtoIndexMap);31 void CalculateOrbitals( vector<atom *> &allatoms);29 void OutputAtoms(ostream *file, const std::vector<atom *> &allatoms, map<int, int> &ZtoIndexMap); 30 void OutputElements(ostream *file, const std::vector<atom *> &allatoms, map<int, int> &ZtoIndexMap); 31 void CalculateOrbitals(const std::vector<atom *> &allatoms); 32 32 33 33 class StructParallelization { -
src/Parser/PdbParser.cpp
r512f85 r73916f 145 145 146 146 /** 147 * Saves the World's current stateinto as a PDB file.147 * Saves the \a atoms into as a PDB file. 148 148 * 149 149 * \param file where to save the state 150 */ 151 void PdbParser::save(ostream* file) { 150 * \param atoms atoms to store 151 */ 152 void PdbParser::save(ostream* file, const std::vector<atom *> &AtomList) 153 { 152 154 DoLog(0) && (Log() << Verbose(0) << "Saving changes to pdb." << std::endl); 153 155 { … … 168 170 atomIdMap.clear(); 169 171 { 170 std::vector<atom *> AtomList = World::getInstance().getAllAtoms();171 std::vector<molecule *> MolList = World::getInstance().getAllMolecules();172 172 std::map<size_t,size_t> MolIdMap; 173 173 size_t MolNo = 1; // residue number starts at 1 in pdb 174 for (std::vector<molecule *>::const_iterator iter = MolList.begin(); 175 iter != MolList.end(); 176 ++iter) { 177 MolIdMap[(*iter)->getId()] = MolNo++; 174 for (vector<atom *>::const_iterator atomIt = AtomList.begin(); atomIt != AtomList.end(); atomIt++) { 175 const molecule *mol = (*atomIt)->getMolecule(); 176 if ((mol != NULL) && (MolIdMap.find(mol->getId()) == MolIdMap.end())) { 177 MolIdMap[mol->getId()] = MolNo++; 178 } 178 179 } 179 180 const size_t MaxMol = MolNo; … … 188 189 // write ATOMs 189 190 int AtomNo = 1; // serial number starts at 1 in pdb 190 for (vector<atom *>:: iterator atomIt = AtomList.begin(); atomIt != AtomList.end(); atomIt++) {191 for (vector<atom *>::const_iterator atomIt = AtomList.begin(); atomIt != AtomList.end(); atomIt++) { 191 192 PdbAtomInfoContainer &atomInfo = getadditionalAtomData(*atomIt); 192 193 // gather info about residue … … 231 232 232 233 // write CONECTs 233 for (vector<atom *>:: iterator atomIt = AtomList.begin(); atomIt != AtomList.end(); atomIt++) {234 for (vector<atom *>::const_iterator atomIt = AtomList.begin(); atomIt != AtomList.end(); atomIt++) { 234 235 writeNeighbors(file, 4, *atomIt); 235 236 } -
src/Parser/PdbParser.hpp
r512f85 r73916f 23 23 ~PdbParser(); 24 24 void load(std::istream* file); 25 void save(std::ostream* file );25 void save(std::ostream* file, const std::vector<atom *> &atoms); 26 26 27 27 bool operator==(const PdbParser& b) const; -
src/Parser/TremoloParser.cpp
r512f85 r73916f 117 117 118 118 /** 119 * Saves the World's current stateinto as a tremolo file.119 * Saves the \a atoms into as a tremolo file. 120 120 * 121 121 * \param file where to save the state 122 */ 123 void TremoloParser::save(ostream* file) { 122 * \param atoms atoms to store 123 */ 124 void TremoloParser::save(ostream* file, const std::vector<atom *> &AtomList) { 124 125 DoLog(0) && (Log() << Verbose(0) << "Saving changes to tremolo." << std::endl); 125 126 126 vector<atom*>:: iterator atomIt;127 vector<atom*>::const_iterator atomIt; 127 128 vector<string>::iterator it; 128 129 … … 132 133 } 133 134 *file << endl; 134 vector<atom *> AtomList = World::getInstance().getAllAtoms();135 135 for (atomIt = AtomList.begin(); atomIt != AtomList.end(); atomIt++) { 136 136 saveLine(file, *atomIt); -
src/Parser/TremoloParser.hpp
r512f85 r73916f 26 26 ~TremoloParser(); 27 27 void load(std::istream* file); 28 void save(std::ostream* file );28 void save(std::ostream* file, const std::vector<atom *> &atoms); 29 29 void setFieldsForSave(std::string atomDataLine); 30 30 -
src/Parser/XyzParser.cpp
r512f85 r73916f 78 78 79 79 /** 80 * Saves the current state of the World into the givenXYZ file.80 * Saves the \a atoms into as a XYZ file. 81 81 * 82 * \param XYZ file 82 * \param file where to save the state 83 * \param atoms atoms to store 83 84 */ 84 void XyzParser::save(ostream* file ) {85 void XyzParser::save(ostream* file, const std::vector<atom *> &atoms) { 85 86 DoLog(0) && (Log() << Verbose(0) << "Saving changes to xyz." << std::endl); 86 87 //if (comment == "") { … … 95 96 comment += time; 96 97 //} 97 *file << World::getInstance().numAtoms() << endl << "\t" << comment << endl;98 *file << atoms.size() << endl << "\t" << comment << endl; 98 99 99 vector<atom*> atoms = World::getInstance().getAllAtoms(); 100 for(vector<atom*>::iterator it = atoms.begin(); it != atoms.end(); it++) { 100 for(vector<atom*>::const_iterator it = atoms.begin(); it != atoms.end(); it++) { 101 101 *file << noshowpoint << (*it)->getType()->getSymbol() << "\t" << (*it)->at(0) << "\t" << (*it)->at(1) << "\t" << (*it)->at(2) << endl; 102 102 } -
src/Parser/XyzParser.hpp
r512f85 r73916f 20 20 ~XyzParser(); 21 21 void load(std::istream* file); 22 void save(std::ostream* file );22 void save(std::ostream* file, const std::vector<atom *> &atoms); 23 23 24 24 private:
Note:
See TracChangeset
for help on using the changeset viewer.