Changeset 16462f for src/Parser


Ignore:
Timestamp:
Dec 16, 2010, 5:32:18 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:
1d02fe3
Parents:
24f128
git-author:
Frederik Heber <heber@…> (12/07/10 12:54:42)
git-committer:
Frederik Heber <heber@…> (12/16/10 17:32:18)
Message:

PdbParser is now complete with respect to additionalAtomData.

  • serial, name, resName, resSeq, element, and charge are updated if changed, otherwise we use values from PdbAtomInfoContainer.
  • PdbParser::saveLine() completely uses information from PdbAtomInfoContainer.

Testchanges:

  • Simple_configuration/2/post/test.pdb updated as we are now closer to real PDB format also concerning alignment and the resName changed again.
Location:
src/Parser
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/PdbAtomInfoContainer.cpp

    r24f128 r16462f  
    2424#include "Helpers/toString.hpp"
    2525//#include "Helpers/Verbose.hpp"
     26#include "LinearAlgebra/Vector.hpp"
    2627#include "PdbAtomInfoContainer.hpp"
    2728
    2829
    2930PdbAtomInfoContainer::PdbAtomInfoContainer() :
     31  token("ATOM"),
    3032  serial(0),
    3133  name("-"),
    32   altloc('0'),
     34  altLoc('0'),
    3335  resName("-"),
    3436  chainID('0'),
     
    3739  occupancy(0.),
    3840  tempFactor(0.),
     41  element(""),
    3942  charge(0)
    4043{}
     
    4649{
    4750  switch (key) {
     51    case PdbKey::token :
     52      ScanKey(token, value);
     53      break;
    4854    case PdbKey::serial :
    4955      ScanKey(serial, value);
     
    5258      ScanKey(name, value);
    5359      break;
    54     case PdbKey::altloc :
    55       ScanKey(altloc, value);
     60    case PdbKey::altLoc :
     61      ScanKey(altLoc, value);
    5662      break;
    5763    case PdbKey::resName :
     
    6773      ScanKey(iCode, value);
    6874      break;
     75    case PdbKey::X :
     76      ScanKey(XYZ[0], value);
     77      break;
     78    case PdbKey::Y :
     79      ScanKey(XYZ[1], value);
     80      break;
     81    case PdbKey::Z :
     82      ScanKey(XYZ[2], value);
     83      break;
    6984    case PdbKey::occupancy :
    7085      ScanKey(occupancy, value);
     
    7287    case PdbKey::tempFactor :
    7388      ScanKey(tempFactor, value);
     89      break;
     90    case PdbKey::element :
     91      ScanKey(element, value);
    7492      break;
    7593    case PdbKey::charge :
     
    82100}
    83101
    84 std::string PdbAtomInfoContainer::get(const PdbKey::PdbDataKey key) const
     102template <>
     103std::string PdbAtomInfoContainer::get<std::string>(const PdbKey::PdbDataKey key) const
    85104{
    86105  switch (key) {
     106    case PdbKey::token :
     107      return toString(token);
    87108    case PdbKey::serial :
    88109      return toString(serial);
    89110    case PdbKey::name :
    90111      return toString(name);
    91     case PdbKey::altloc :
    92       return toString(altloc);
     112    case PdbKey::altLoc :
     113      return toString(altLoc);
    93114    case PdbKey::resName :
    94115      return toString(resName);
     
    99120    case PdbKey::iCode :
    100121      return toString(iCode);
     122    case PdbKey::X :
     123      return toString(XYZ[0]);
     124    case PdbKey::Y :
     125      return toString(XYZ[1]);
     126    case PdbKey::Z :
     127      return toString(XYZ[2]);
    101128    case PdbKey::occupancy :
    102129      return toString(occupancy);
    103130    case PdbKey::tempFactor :
    104131      return toString(tempFactor);
     132    case PdbKey::element :
     133      return toString(element);
    105134    case PdbKey::charge :
    106135      return toString(charge);
     
    111140}
    112141
     142template <>
     143int PdbAtomInfoContainer::get<int>(const PdbKey::PdbDataKey key) const
     144{
     145  switch (key) {
     146    case PdbKey::serial :
     147      return serial;
     148    case PdbKey::resSeq :
     149      return resSeq;
     150    case PdbKey::charge :
     151      return charge;
     152    default :
     153      std::cout << "Unknown key or not presentable as int: " << key << std::endl;
     154      return 0;
     155  }
     156}
     157
     158template <>
     159double PdbAtomInfoContainer::get<double>(const PdbKey::PdbDataKey key) const
     160{
     161  switch (key) {
     162    case PdbKey::X :
     163      return XYZ[0];
     164    case PdbKey::Y :
     165      return XYZ[1];
     166    case PdbKey::Z :
     167      return XYZ[2];
     168    case PdbKey::occupancy :
     169      return occupancy;
     170    case PdbKey::tempFactor :
     171      return tempFactor;
     172    default :
     173      std::cout << "Unknown key or not presentable as double: " << key << std::endl;
     174      return 0.;
     175  }
     176}
  • src/Parser/PdbAtomInfoContainer.hpp

    r24f128 r16462f  
    1111#include "PdbKey.hpp"
    1212
     13class Vector;
     14
    1315#include <string>
     16#include <typeinfo>
    1417
    1518/**
     
    2225
    2326  // getter and setter
    24   std::string get(const PdbKey::PdbDataKey key) const;
     27  template <class T> T get(const PdbKey::PdbDataKey key) const  {
     28    switch (key) {
     29      default :
     30        std::cout << "Unknown key or not representable as " << typeid(T).name() << ": " << key << std::endl;
     31        break;
     32    }
     33    return (T)NULL;
     34  }
    2535  void set(const PdbKey::PdbDataKey key, std::string value);
    2636
     
    4656
    4757private:
     58  std::string token;
    4859  int serial;
    4960  std::string name;
    50   char altloc;
     61  char altLoc;
    5162  std::string resName;
    5263  char chainID;
    5364  int resSeq;
    5465  char iCode;
     66  Vector XYZ;
    5567  float occupancy;
    5668  float tempFactor;
     69  std::string element;
    5770  int charge;
    5871};
    5972
     73template <>
     74std::string PdbAtomInfoContainer::get<std::string>(const PdbKey::PdbDataKey key) const;
     75template <>
     76int PdbAtomInfoContainer::get<int>(const PdbKey::PdbDataKey key) const;
     77template <>
     78double PdbAtomInfoContainer::get<double>(const PdbKey::PdbDataKey key) const;
     79
    6080#endif /* PDBATOMINFOCONTAINER_HPP_ */
  • src/Parser/PdbKey.hpp

    r24f128 r16462f  
    1818  enum PdbDataKey {
    1919    noKey,
     20    token,
    2021    serial,
    2122    name,
    22     altloc,
     23    altLoc,
    2324    resName,
    2425    chainID,
    2526    resSeq,
    2627    iCode,
     28    X,
     29    Y,
     30    Z,
    2731    occupancy,
    2832    tempFactor,
     33    element,
    2934    charge
    3035  };
  • src/Parser/PdbParser.cpp

    r24f128 r16462f  
    4646PdbParser::PdbParser() {
    4747  knownTokens["ATOM"] = PdbKey::Atom;
     48  knownTokens["HETATM"] = PdbKey::Atom;
    4849  knownTokens["TER"] = PdbKey::Filler;
    4950  knownTokens["END"] = PdbKey::EndOfFile;
     
    5152  knownTokens["REMARK"] = PdbKey::Remark;
    5253  knownTokens[""] = PdbKey::EndOfFile;
     54
     55  // argh, why can't just PdbKey::X+(size_t)i
     56  PositionEnumMap[0] = PdbKey::X;
     57  PositionEnumMap[1] = PdbKey::Y;
     58  PositionEnumMap[2] = PdbKey::Z;
    5359}
    5460
     
    99105  size_t linecount  = 0;
    100106  enum PdbKey::KnownTokens token;
     107
     108  // reset atomIdMap for this file (to correctly parse CONECT entries)
     109  atomIdMap.clear();
    101110
    102111  molecule *newmol = World::getInstance().createMolecule();
     
    157166  }
    158167
    159   // we distribute new atom numbers, hence clear map beforehand
     168  // we distribute serials, hence clear map beforehand
    160169  atomIdMap.clear();
    161170  {
    162     vector<atom *> AtomList = World::getInstance().getAllAtoms();
    163 
    164     std::vector<int> elementNo(MAX_ELEMENTS,1);
     171    std::vector<atom *> AtomList = World::getInstance().getAllAtoms();
     172    std::vector<molecule *> MolList = World::getInstance().getAllMolecules();
     173    std::map<size_t,size_t> MolIdMap;
     174    size_t MolNo = 1;  // residue number starts at 1 in pdb
     175    for (std::vector<molecule *>::const_iterator iter = MolList.begin();
     176        iter != MolList.end();
     177        ++iter) {
     178      MolIdMap[(*iter)->getId()] = MolNo++;
     179    }
     180    const size_t MaxMol = MolNo;
     181
     182    // have a count per element and per molecule (0 is for all homeless atoms)
     183    std::vector<int> **elementNo = new std::vector<int>*[MaxMol];
     184    for (size_t i = 0; i < MaxMol; ++i)
     185      elementNo[i] = new std::vector<int>(MAX_ELEMENTS,1);
    165186    char name[MAXSTRINGSIZE];
     187    std::string ResidueName;
    166188
    167189    // write ATOMs
    168190    int AtomNo = 1; // serial number starts at 1 in pdb
    169     int MolNo = 1;  // residue number starts at 1 in pdb
    170191    for (vector<atom *>::iterator atomIt = AtomList.begin(); atomIt != AtomList.end(); atomIt++) {
     192      PdbAtomInfoContainer &atomInfo = additionalAtomData[(*atomIt)->getId()];
     193      // gather info about residue
     194      const molecule *mol = (*atomIt)->getMolecule();
     195      if (mol == NULL) {
     196        MolNo = 0;
     197        atomInfo.set(PdbKey::resSeq, "0");
     198      } else {
     199        ASSERT(MolIdMap.find(mol->getId()) != MolIdMap.end(),
     200            "PdbParser::save() - Mol id "+toString(mol->getId())+" not present despite we set it?!");
     201        MolNo = MolIdMap[mol->getId()];
     202        atomInfo.set(PdbKey::resSeq, toString(MolIdMap[mol->getId()]));
     203        if (atomInfo.get<std::string>(PdbKey::resName) == "-")
     204          atomInfo.set(PdbKey::resName, mol->getName().substr(0,3));
     205      }
     206      // get info about atom
    171207      const size_t  Z = (*atomIt)->getType()->getAtomicNumber();
    172       sprintf(name, "%2s%02d",(*atomIt)->getType()->getSymbol().c_str(), elementNo[Z]);
    173       elementNo[Z] = (elementNo[Z]+1) % 100;   // confine to two digits
    174       const molecule *mol = (*atomIt)->getMolecule();
    175       if (mol == NULL) {  // for homeless atoms, MolNo = -1 is reserved
    176         MolNo = -1;
    177       } else {
    178         MolNo = mol->getId();
     208      if (atomInfo.get<std::string>(PdbKey::name) == "-") {  // if no name set, give it a new name
     209        sprintf(name, "%2s%02d",(*atomIt)->getType()->getSymbol().c_str(), (*elementNo[MolNo])[Z]);
     210        (*elementNo[MolNo])[Z] = ((*elementNo[MolNo])[Z]+1) % 100;   // confine to two digits
     211        atomInfo.set(PdbKey::name, name);
    179212      }
    180       saveLine(file, *atomIt, name, AtomNo, MolNo);
    181       setAtomId((*atomIt)->getId(), AtomNo);
     213      // set position
     214      for (size_t i=0; i<NDIM;++i) {
     215        stringstream position;
     216        position << setw(8) << fixed << setprecision(3) << (*atomIt)->getPosition().at(i);
     217        atomInfo.set(PositionEnumMap[i], position.str());
     218      }
     219      // change element and charge if changed
     220      if (atomInfo.get<std::string>(PdbKey::element) != (*atomIt)->getType()->getSymbol())
     221        atomInfo.set(PdbKey::element, (*atomIt)->getType()->getSymbol());
     222      setSerial((*atomIt)->getId(), AtomNo);
     223      atomInfo.set(PdbKey::serial, toString(AtomNo));
     224
     225      // finally save the line
     226      saveLine(file, atomInfo);
    182227      AtomNo++;
    183228    }
     229    for (size_t i = 0; i < MaxMol; ++i)
     230      delete elementNo[i];
     231    delete elementNo;
    184232
    185233    // write CONECTs
     
    198246 * \param stream where to write the line to
    199247 * \param *currentAtom the atom of which information should be written
     248 * \param AtomNo serial number of atom
    200249 * \param *name name of atom, i.e. H01
    201  * \param AtomNo serial number of atom
     250 * \param ResidueName Name of molecule
    202251 * \param ResidueNo number of residue
    203252 */
    204 void PdbParser::saveLine(ostream* file, const atom* currentAtom, const char *name, const int AtomNo, const int ResidueNo) {
    205   *file << "ATOM ";
    206   *file << setw(6) << AtomNo; /* atom serial number */
    207   *file << setw(1) << " ";
    208   *file << setfill(' ') << left << setw(4) << name << right;  /* atom name */
    209   *file << setw(1) << " ";
    210   *file << setfill(' ') << setw(3) << ((currentAtom->getMolecule() != NULL) ? currentAtom->getMolecule()->getName().substr(0,3) : "-");  /* residue name */
    211   *file << setw(1) << " ";
    212   *file << setfill(' ') << setw(1) << (char)('a'+(unsigned char)(AtomNo % 26)); /* letter for chain */
    213   *file << setw(4) << ResidueNo; /* residue sequence number */
    214   *file << setw(4) << "    ";
    215   for (int i=0;i<NDIM;i++) {
    216     *file << setw(8) << setprecision(3) << showpoint << currentAtom->at(i); /* positional coordinate in Angstroem */
    217   }
    218   *file << setw(6) << setprecision(2) << showpoint << (double)currentAtom->getType()->getValence(); /* occupancy */
    219   *file << setw(6) << setprecision(2) << showpoint << (double)currentAtom->getType()->getNoValenceOrbitals(); /* temperature factor */
    220   *file << noshowpoint;
    221   *file << setw(6) << "      ";
    222   *file << setw(4) << "0";
    223   *file << setfill(' ') << setw(2) << currentAtom->getType()->getSymbol();
    224   *file << setw(2) << "0";
     253void PdbParser::saveLine(
     254    ostream* file,
     255    const PdbAtomInfoContainer &atomInfo)
     256{
     257  *file << setfill(' ') << left << setw(6)
     258      << atomInfo.get<std::string>(PdbKey::token);
     259  *file << setfill(' ') << right << setw(5)
     260      << atomInfo.get<int>(PdbKey::serial); /* atom serial number */
     261  *file << " "; /* char 12 is empty */
     262  *file << setfill(' ') << left << setw(4)
     263      << atomInfo.get<std::string>(PdbKey::name);  /* atom name */
     264  *file << setfill(' ') << left << setw(1)
     265      << atomInfo.get<std::string>(PdbKey::altLoc); /* alternate location/conformation */
     266  *file << setfill(' ') << left << setw(3)
     267      << atomInfo.get<std::string>(PdbKey::resName);  /* residue name */
     268  *file << " "; /* char 21 is empty */
     269  *file << setfill(' ') << left << setw(1)
     270      << atomInfo.get<std::string>(PdbKey::chainID); /* chain identifier */
     271  *file << setfill(' ') << left << setw(4)
     272      << atomInfo.get<int>(PdbKey::resSeq); /* residue sequence number */
     273  *file << setfill(' ') << left << setw(1)
     274      << atomInfo.get<std::string>(PdbKey::iCode); /* iCode */
     275  *file << "   "; /* char 28-30 are empty */
     276  // have the following operate on stringstreams such that format specifiers
     277  // only act on these
     278  for (size_t i=0;i<NDIM;++i) {
     279    stringstream position;
     280    position << fixed << setprecision(3) << showpoint
     281        << atomInfo.get<double>(PositionEnumMap[i]);
     282    *file << setfill(' ') << right << setw(8) << position.str();
     283  }
     284  {
     285    stringstream occupancy;
     286    occupancy << fixed << setprecision(2) << showpoint
     287        << atomInfo.get<double>(PdbKey::occupancy); /* occupancy */
     288    *file << setfill(' ') << right << setw(6) << occupancy.str();
     289  }
     290  {
     291    stringstream tempFactor;
     292    tempFactor << fixed << setprecision(2) << showpoint
     293        << atomInfo.get<double>(PdbKey::tempFactor); /* temperature factor */
     294    *file << setfill(' ') << right << setw(6) << tempFactor.str();
     295  }
     296  *file << "          "; /* char 68-76 are empty */
     297  *file << setfill(' ') << right << setw(2) << atomInfo.get<std::string>(PdbKey::element); /* element */
     298  *file << setfill(' ') << right << setw(2) << atomInfo.get<int>(PdbKey::charge); /* charge */
    225299
    226300  *file << endl;
     
    240314      if (MaxNo >= MaxnumberOfNeighbors) {
    241315        *file << "CONECT";
    242         *file << setw(5) << getAtomId(currentAtom->getId());
     316        *file << setw(5) << getSerial(currentAtom->getId());
    243317        MaxNo = 0;
    244318      }
    245       *file << setw(5) << getAtomId((*currentBond)->GetOtherAtom(currentAtom)->getId());
     319      *file << setw(5) << getSerial((*currentBond)->GetOtherAtom(currentAtom)->getId());
    246320      MaxNo++;
    247321      if (MaxNo == MaxnumberOfNeighbors)
     
    253327}
    254328
    255 
    256329/** Retrieves a value from PdbParser::atomIdMap.
    257330 * \param atomid key
     
    259332 */
    260333size_t PdbParser::getSerial(const size_t atomid) const
    261 {
    262   ConvertTo<size_t> toSize_t;
    263   ASSERT(additionalAtomData.find(atomid) != additionalAtomData.end(),
    264       "PdbParser::getSerial: atomid "+toString(atomid)+" not present in Map.");
    265   const PdbAtomInfoContainer &atomInfo = additionalAtomData.at(atomid);
    266 
    267   return toSize_t(atomInfo.get(PdbKey::serial));
    268 }
    269 
    270 /** Retrieves a value from PdbParser::atomIdMap.
    271  * \param atomid key
    272  * \return value
    273  */
    274 size_t PdbParser::getAtomId(const size_t atomid) const
    275334{
    276335  ASSERT(atomIdMap.find(atomid) != atomIdMap.end(), "PdbParser::getAtomId: atomid not present in Map.");
     
    283342 * \return true - key not present, false - value present
    284343 */
    285 void PdbParser::setAtomId(const size_t localatomid, const size_t atomid)
     344void PdbParser::setSerial(const size_t localatomid, const size_t atomid)
    286345{
    287346  pair<std::map<size_t,size_t>::iterator, bool > inserter;
    288   DoLog(1) && (Log() << Verbose(1) << "PdbParser::setAtomId() - Inserting ("
    289       << localatomid << " -> " << atomid << ")." << std::endl);
     347//  DoLog(1) && (Log() << Verbose(1) << "PdbParser::setAtomId() - Inserting ("
     348//      << localatomid << " -> " << atomid << ")." << std::endl);
    290349  inserter = atomIdMap.insert( make_pair(localatomid, atomid) );
    291350  ASSERT(inserter.second, "PdbParser::setAtomId: atomId already present in Map.");
     
    314373
    315374  lineStream << line;
     375  atomInfo.set(PdbKey::token, line.substr(0,6));
    316376  atomInfo.set(PdbKey::serial, line.substr(6,5));
    317377  std::pair< std::set<size_t>::const_iterator, bool> Inserter =
    318     SerialSet.insert(toSize_t(atomInfo.get(PdbKey::serial)));
     378    SerialSet.insert(toSize_t(atomInfo.get<std::string>(PdbKey::serial)));
    319379  ASSERT(Inserter.second,
    320380      "PdbParser::readAtomDataLine() - ATOM contains entry with serial "
    321       +atomInfo.get(PdbKey::serial)+" already present!");
     381      +atomInfo.get<std::string>(PdbKey::serial)+" already present!");
    322382  // assign hightest+1 instead, but then beware of CONECT entries! Another map needed!
    323383//  if (!Inserter.second) {
     
    326386//    atomInfo.set(PdbKey::serial, toString(id));
    327387//    DoeLog(2) && (eLog() << Verbose(2)
    328 //        << "Serial " << atomInfo.get(PdbKey::serial) << " already present, "
     388//        << "Serial " << atomInfo.get<std::string>(PdbKey::serial) << " already present, "
    329389//        << "assigning " << toString(id) << " instead." << std::endl);
    330390//  }
     
    348408//      << line.substr(78,2) << std::endl);
    349409
    350   setAtomId(toSize_t(atomInfo.get(PdbKey::serial)), newAtom->getId());
     410  setSerial(toSize_t(atomInfo.get<std::string>(PdbKey::serial)), newAtom->getId());
    351411  atomInfo.set(PdbKey::name, line.substr(12,4));
    352   atomInfo.set(PdbKey::altloc, line.substr(16,1));
     412  atomInfo.set(PdbKey::altLoc, line.substr(16,1));
    353413  atomInfo.set(PdbKey::resName, line.substr(17,3));
    354414  atomInfo.set(PdbKey::chainID, line.substr(21,1));
     
    364424  atomInfo.set(PdbKey::tempFactor, line.substr(60,6));
    365425  atomInfo.set(PdbKey::charge, line.substr(78,2));
    366   PdbAtomInfoContainer::ScanKey(word, line.substr(76,2));
    367   newAtom->setType(World::getInstance().getPeriode()->FindElement(word));
     426  atomInfo.set(PdbKey::element, line.substr(76,2));
     427  const element *elem = World::getInstance().getPeriode()
     428      ->FindElement(atomInfo.get<std::string>(PdbKey::element));
     429  ASSERT(elem != NULL,
     430      "PdbParser::readAtomDataLine() - element "+atomInfo.get<std::string>(PdbKey::element)+" is unknown!");
     431  newAtom->setType(elem);
    368432
    369433  if (newmol != NULL)
     
    381445
    382446  DoLog(1) && (Log() << Verbose(1) << "We know about atom " << newAtom->getId() << ":" << std::endl);
    383   DoLog(1) && (Log() << Verbose(1) << "\tserial is " << atomInfo.get(PdbKey::serial) << std::endl);
    384   DoLog(1) && (Log() << Verbose(1) << "\tname is " << atomInfo.get(PdbKey::name) << std::endl);
    385   DoLog(1) && (Log() << Verbose(1) << "\taltloc is " << atomInfo.get(PdbKey::altloc) << std::endl);
    386   DoLog(1) && (Log() << Verbose(1) << "\tresName is " << atomInfo.get(PdbKey::resName) << std::endl);
    387   DoLog(1) && (Log() << Verbose(1) << "\tchainID is " << atomInfo.get(PdbKey::chainID) << std::endl);
    388   DoLog(1) && (Log() << Verbose(1) << "\tresSeq is " << atomInfo.get(PdbKey::resSeq) << std::endl);
    389   DoLog(1) && (Log() << Verbose(1) << "\tiCode is " << atomInfo.get(PdbKey::iCode) << std::endl);
    390   DoLog(1) && (Log() << Verbose(1) << "\tx is " << newAtom->getPosition() << std::endl);
    391   DoLog(1) && (Log() << Verbose(1) << "\toccupancy is " << atomInfo.get(PdbKey::occupancy) << std::endl);
    392   DoLog(1) && (Log() << Verbose(1) << "\ttempFactor is " << atomInfo.get(PdbKey::tempFactor) << std::endl);
     447  DoLog(1) && (Log() << Verbose(1) << "\ttoken is " << atomInfo.get<std::string>(PdbKey::token) << std::endl);
     448  DoLog(1) && (Log() << Verbose(1) << "\tserial is " << atomInfo.get<int>(PdbKey::serial) << std::endl);
     449  DoLog(1) && (Log() << Verbose(1) << "\tname is " << atomInfo.get<std::string>(PdbKey::name) << std::endl);
     450  DoLog(1) && (Log() << Verbose(1) << "\taltLoc is " << atomInfo.get<std::string>(PdbKey::altLoc) << std::endl);
     451  DoLog(1) && (Log() << Verbose(1) << "\tresName is " << atomInfo.get<std::string>(PdbKey::resName) << std::endl);
     452  DoLog(1) && (Log() << Verbose(1) << "\tchainID is " << atomInfo.get<std::string>(PdbKey::chainID) << std::endl);
     453  DoLog(1) && (Log() << Verbose(1) << "\tresSeq is " << atomInfo.get<int>(PdbKey::resSeq) << std::endl);
     454  DoLog(1) && (Log() << Verbose(1) << "\tiCode is " << atomInfo.get<std::string>(PdbKey::iCode) << std::endl);
     455  DoLog(1) && (Log() << Verbose(1) << "\tX is " << atomInfo.get<double>(PdbKey::X) << std::endl);
     456  DoLog(1) && (Log() << Verbose(1) << "\tY is " << atomInfo.get<double>(PdbKey::Y) << std::endl);
     457  DoLog(1) && (Log() << Verbose(1) << "\tZ is " << atomInfo.get<double>(PdbKey::Z) << std::endl);
     458  DoLog(1) && (Log() << Verbose(1) << "\toccupancy is " << atomInfo.get<double>(PdbKey::occupancy) << std::endl);
     459  DoLog(1) && (Log() << Verbose(1) << "\ttempFactor is " << atomInfo.get<double>(PdbKey::tempFactor) << std::endl);
    393460  DoLog(1) && (Log() << Verbose(1) << "\telement is '" << *(newAtom->getType()) << "'" << std::endl);
    394   DoLog(1) && (Log() << Verbose(1) << "\tcharge is " << atomInfo.get(PdbKey::charge) << std::endl);
     461  DoLog(1) && (Log() << Verbose(1) << "\tcharge is " << atomInfo.get<int>(PdbKey::charge) << std::endl);
    395462}
    396463
     
    426493
    427494  // add neighbours
    428   atom *_atom = World::getInstance().getAtom(AtomById(getAtomId(id)));
     495  atom *_atom = World::getInstance().getAtom(AtomById(getSerial(id)));
    429496  for (std::list<size_t>::const_iterator iter = ListOfNeighbors.begin();
    430497      iter != ListOfNeighbors.end();
    431498      ++iter) {
    432499//    DoLog(1) && (Log() << Verbose(1) << "Adding Bond (" << getAtomId(id) << "," << getAtomId(*iter) << ")" << std::endl);
    433     atom * const _Otheratom = World::getInstance().getAtom(AtomById(getAtomId(*iter)));
     500    atom * const _Otheratom = World::getInstance().getAtom(AtomById(getSerial(*iter)));
    434501    _atom->addBond(_Otheratom);
    435502  }
     
    478545      const PdbAtomInfoContainer &OtheratomInfo = b.additionalAtomData.at((*iter)->getId());
    479546
    480       status = status && (atomInfo.get(PdbKey::serial) == OtheratomInfo.get(PdbKey::serial));
     547      status = status && (atomInfo.get<std::string>(PdbKey::serial) == OtheratomInfo.get<std::string>(PdbKey::serial));
    481548      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in serials!" << std::endl);
    482       status = status && (atomInfo.get(PdbKey::name) == OtheratomInfo.get(PdbKey::name));
     549      status = status && (atomInfo.get<std::string>(PdbKey::name) == OtheratomInfo.get<std::string>(PdbKey::name));
    483550      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in names!" << std::endl);
    484       status = status && (atomInfo.get(PdbKey::altloc) == OtheratomInfo.get(PdbKey::altloc));
    485       if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in altlocs!" << std::endl);
    486       status = status && (atomInfo.get(PdbKey::resName) == OtheratomInfo.get(PdbKey::resName));
     551      status = status && (atomInfo.get<std::string>(PdbKey::altLoc) == OtheratomInfo.get<std::string>(PdbKey::altLoc));
     552      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in altLocs!" << std::endl);
     553      status = status && (atomInfo.get<std::string>(PdbKey::resName) == OtheratomInfo.get<std::string>(PdbKey::resName));
    487554      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in resNames!" << std::endl);
    488       status = status && (atomInfo.get(PdbKey::chainID) == OtheratomInfo.get(PdbKey::chainID));
     555      status = status && (atomInfo.get<std::string>(PdbKey::chainID) == OtheratomInfo.get<std::string>(PdbKey::chainID));
    489556      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in chainIDs!" << std::endl);
    490       status = status && (atomInfo.get(PdbKey::resSeq) == OtheratomInfo.get(PdbKey::resSeq));
     557      status = status && (atomInfo.get<std::string>(PdbKey::resSeq) == OtheratomInfo.get<std::string>(PdbKey::resSeq));
    491558      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in resSeqs!" << std::endl);
    492       status = status && (atomInfo.get(PdbKey::iCode) == OtheratomInfo.get(PdbKey::iCode));
     559      status = status && (atomInfo.get<std::string>(PdbKey::iCode) == OtheratomInfo.get<std::string>(PdbKey::iCode));
    493560      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in iCodes!" << std::endl);
    494       status = status && (atomInfo.get(PdbKey::occupancy) == OtheratomInfo.get(PdbKey::occupancy));
     561      status = status && (atomInfo.get<std::string>(PdbKey::occupancy) == OtheratomInfo.get<std::string>(PdbKey::occupancy));
    495562      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in occupancies!" << std::endl);
    496       status = status && (atomInfo.get(PdbKey::tempFactor) == OtheratomInfo.get(PdbKey::tempFactor));
     563      status = status && (atomInfo.get<std::string>(PdbKey::tempFactor) == OtheratomInfo.get<std::string>(PdbKey::tempFactor));
    497564      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in tempFactors!" << std::endl);
    498       status = status && (atomInfo.get(PdbKey::charge) == OtheratomInfo.get(PdbKey::charge));
     565      status = status && (atomInfo.get<std::string>(PdbKey::charge) == OtheratomInfo.get<std::string>(PdbKey::charge));
    499566      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in charges!" << std::endl);
    500567    }
  • src/Parser/PdbParser.hpp

    r24f128 r16462f  
    3838  bool isUsedField(std::string fieldName);
    3939  void writeNeighbors(std::ostream* file, int numberOfNeighbors, atom* currentAtom);
    40   void saveLine(ostream* file, const atom* currentAtom, const char *name, const int AtomNo, const int ResdueNo);
     40  void saveLine(ostream* file, const PdbAtomInfoContainer &atomInfo);
    4141
    4242  // internal getter and setter
    4343  size_t getSerial(const size_t atomid) const;
    44   size_t getAtomId(const size_t atomid) const;
    45   void setAtomId(const size_t localatomid, const size_t atomid);
     44  void setSerial(const size_t localatomid, const size_t atomid);
     45
     46  /**
     47   * argh, why can't just PdbKey::X+(size_t)i
     48   */
     49  std::map<size_t, PdbKey::PdbDataKey> PositionEnumMap;
    4650
    4751  /**
Note: See TracChangeset for help on using the changeset viewer.