Ignore:
Timestamp:
Mar 30, 2010, 1:22:20 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:
4415da
Parents:
cb2146
Message:

WIP tremolo parser

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TremoloParser.cpp

    rcb2146 r9131f3  
    66 */
    77
    8 void TremoloParser::load(char* fileName) {
    9 MatrixContainer* data = readData(fileName, getHeaderSize('#'), 0);
    10 store additional data
    11 for (each line in matrix) {
    12   add atom to the world
    13 }
     8#include "TremoloParser.hpp"
     9#include "World.hpp"
     10#include "atom.hpp"
     11#include "element.hpp"
     12#include "periodentafel.hpp"
     13#include <map>
     14#include <vector>
     15
     16using namespace std;
     17
     18/**
     19 * Constructor.
     20 */
     21TremoloParser::TremoloParser() {
     22  knownKeys["x"] = x;
     23  knownKeys["u"] = u;
     24  knownKeys["F"] = F;
     25  knownKeys["stress"] = stress;
     26  knownKeys["Id"] = Id;
     27  knownKeys["neighbors"] = neighbors;
     28  knownKeys["imprData"] = imprData;
     29  knownKeys["GroupMeasureTypeNo"] = GroupMeasureTypeNo;
     30  knownKeys["Type"] = Type;
     31  knownKeys["extType"] = extType;
     32  knownKeys["name"] = name;
     33  knownKeys["resName"] = resName;
     34  knownKeys["chainID"] = chainID;
     35  knownKeys["resSeq"] = resSeq;
     36  knownKeys["occupancy"] = occupancy;
     37  knownKeys["tempFactor"] = tempFactor;
     38  knownKeys["segID"] = segID;
     39  knownKeys["Charge"] = Charge;
     40  knownKeys["charge"] = charge;
     41  knownKeys["GrpTypeNo"] = GrpTypeNo;
    1442}
    1543
    16 void TremoloParser::save(char* fileName) {
     44/**
     45 * Destructor.
     46 */
     47TremoloParser::~TremoloParser() {
     48}
     49
     50/**
     51 * Stores keys from the ATOMDATA line.
     52 *
     53 * \param line to parse the keys from
     54 * \param with which offset the keys begin within the line
     55 */
     56void TremoloParser::parseAtomDataKeysLine(string line, int offset) {
     57  string keyword;
     58  stringstream lineStream;
     59
     60  lineStream << line.substr(offset);
     61  while (lineStream.good()) {
     62    lineStream >> keyword;
     63    usedFields.push_back(keyword);
     64  }
     65}
     66
     67/**
     68 * Reads one data line of a tremolo file and interprets it according to the keys
     69 * obtained from the ATOMDATA line.
     70 *
     71 * \param line to parse as an atom
     72 */
     73void TremoloParser::readAtomDataLine(string line) {
     74  vector<string>::iterator it;
     75  stringstream lineStream;
     76  string word;
     77
     78  lineStream << line;
     79  for (it=usedFields.begin(); it < usedFields.end(); it++) {
     80    cout << *it << " -- " << it->substr(0, it->find("=")) << " -- " << knownKeys[it->substr(0, it->find("="))] << endl;
     81    switch (knownKeys[it->substr(0, it->find("="))]) {
     82      case x :
     83        lineStream >> word;
     84        cout<< "Found an x: word: " << word << endl;
     85        break;
     86      default :
     87        lineStream >> word;
     88        cout << "Unknown key: " << *it << ", word: " << word << endl;
     89        break;
     90    }
     91  }
     92}
     93
     94
     95/**
     96 * Loads atoms from a tremolo-formatted file.
     97 *
     98 * \param tremolo file
     99 */
     100void TremoloParser::load(istream* file) {
     101  string line;
     102  string::size_type location;
     103
     104  usedFields.clear();
     105  while (file->good()) {
     106    std::getline(*file, line, '\n');
     107    if (usedFields.empty()) {
     108      location = line.find("ATOMDATA", 0);
     109      if (location != string::npos) {
     110       parseAtomDataKeysLine(line, location + 8);
     111      }
     112    }
     113    if (line.length() > 0 && line.at(0) != '#') {
     114      readAtomDataLine(line);
     115    }
     116  }
     117}
     118
     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
     127ATOMDATA 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
     133/**
     134 * Saves the World's current state into as a tremolo file.
     135 *
     136 * \param file where to save the state
     137 */
     138void TremoloParser::save(ostream* file) {
     139/*
    17140write header
    18141for (each atom in world) {
    19142  write coordinates and additional data
    20143}
     144*/
    21145}
Note: See TracChangeset for help on using the changeset viewer.