Index: src/Parser/Makefile.am
===================================================================
--- src/Parser/Makefile.am	(revision cca9efb7bf18583f35d0380acb97e9034c42bbe7)
+++ src/Parser/Makefile.am	(revision 4fbca9c2b6785a7839394eeab5fe9c6dad6c28cd)
@@ -14,4 +14,5 @@
   MpqcParser.cpp \
   PcpParser.cpp \
+  PdbAtomInfoContainer.cpp \
   PdbParser.cpp \
   TremoloParser.cpp \
@@ -24,4 +25,6 @@
   MpqcParser.hpp \
   PcpParser.hpp \
+  PdbAtomInfoContainer.hpp \
+  PdbKey.hpp \
   PdbParser.hpp \
   TremoloParser.hpp \
Index: src/Parser/PdbAtomInfoContainer.cpp
===================================================================
--- src/Parser/PdbAtomInfoContainer.cpp	(revision 4fbca9c2b6785a7839394eeab5fe9c6dad6c28cd)
+++ src/Parser/PdbAtomInfoContainer.cpp	(revision 4fbca9c2b6785a7839394eeab5fe9c6dad6c28cd)
@@ -0,0 +1,112 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * PdbAtomInfoContainer.cpp
+ *
+ *  Created on: Dec 4, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+//#include "Helpers/Assert.hpp"
+//#include "Helpers/Log.hpp"
+#include "Helpers/toString.hpp"
+//#include "Helpers/Verbose.hpp"
+#include "PdbAtomInfoContainer.hpp"
+
+
+PdbAtomInfoContainer::PdbAtomInfoContainer() :
+  serial(0),
+  name("-"),
+  altloc('0'),
+  resName("-"),
+  chainID('0'),
+  resSeq(0),
+  iCode(' '),
+  occupancy(0.),
+  tempFactor(0.),
+  charge(0)
+{}
+
+PdbAtomInfoContainer::~PdbAtomInfoContainer()
+{}
+
+void PdbAtomInfoContainer::set(const PdbKey::PdbDataKey key, std::string value)
+{
+  switch (key) {
+    case PdbKey::serial :
+      ScanKey(serial, value);
+      break;
+    case PdbKey::name :
+      ScanKey(name, value);
+      break;
+    case PdbKey::altloc :
+      ScanKey(altloc, value);
+      break;
+    case PdbKey::resName :
+      ScanKey(resName, value);
+      break;
+    case PdbKey::chainID :
+      ScanKey(chainID, value);
+      break;
+    case PdbKey::resSeq :
+      ScanKey(resSeq, value);
+      break;
+    case PdbKey::iCode :
+      ScanKey(iCode, value);
+      break;
+    case PdbKey::occupancy :
+      ScanKey(occupancy, value);
+      break;
+    case PdbKey::tempFactor :
+      ScanKey(tempFactor, value);
+      break;
+    case PdbKey::charge :
+      ScanKey(charge, value);
+      break;
+    default :
+      std::cout << "Unknown key: " << key << ", value: " << value << std::endl;
+      break;
+  }
+}
+
+std::string PdbAtomInfoContainer::get(const PdbKey::PdbDataKey key) const
+{
+  switch (key) {
+    case PdbKey::serial :
+      return toString(serial);
+    case PdbKey::name :
+      return toString(name);
+    case PdbKey::altloc :
+      return toString(altloc);
+    case PdbKey::resName :
+      return toString(resName);
+    case PdbKey::chainID :
+      return toString(chainID);
+    case PdbKey::resSeq :
+      return toString(resSeq);
+    case PdbKey::iCode :
+      return toString(iCode);
+    case PdbKey::occupancy :
+      return toString(occupancy);
+    case PdbKey::tempFactor :
+      return toString(tempFactor);
+    case PdbKey::charge :
+      return toString(charge);
+    default :
+      std::cout << "Unknown key: " << key << std::endl;
+      return "";
+  }
+}
+
Index: src/Parser/PdbAtomInfoContainer.hpp
===================================================================
--- src/Parser/PdbAtomInfoContainer.hpp	(revision 4fbca9c2b6785a7839394eeab5fe9c6dad6c28cd)
+++ src/Parser/PdbAtomInfoContainer.hpp	(revision 4fbca9c2b6785a7839394eeab5fe9c6dad6c28cd)
@@ -0,0 +1,60 @@
+/*
+ * PdbAtomInfoContainer.hpp
+ *
+ *  Created on: Dec 4, 2010
+ *      Author: heber
+ */
+
+#ifndef PDBATOMINFOCONTAINER_HPP_
+#define PDBATOMINFOCONTAINER_HPP_
+
+#include "PdbKey.hpp"
+
+#include <string>
+
+/**
+ * Holds tremolo-specific information which is not store in the atom class.
+ */
+class PdbAtomInfoContainer {
+public:
+  PdbAtomInfoContainer();
+  ~PdbAtomInfoContainer();
+
+  // getter and setter
+  std::string get(const PdbKey::PdbDataKey key) const;
+  void set(const PdbKey::PdbDataKey key, std::string value);
+
+  /** Scans a value from a short string and checks whether its empty.
+   *
+   * @param value value to set
+   * @param _piece short string
+   */
+  template <class T> static void ScanKey(T& value, std::string _piece)
+  {
+    ConvertTo<T> toValue;
+    // scan all empty chars ' ' and skip
+    std::string::iterator iter = _piece.begin();
+    for (;iter != _piece.end();++iter)
+      if ((*iter != ' ') && (*iter != '\t'))
+        break;
+    // only set if there is something contained in the string
+    if (iter != _piece.end()) {
+      _piece.erase(_piece.begin(), iter);
+      value = toValue(_piece);
+    }
+  }
+
+private:
+  int serial;
+  std::string name;
+  char altloc;
+  std::string resName;
+  char chainID;
+  int resSeq;
+  char iCode;
+  float occupancy;
+  float tempFactor;
+  int charge;
+};
+
+#endif /* PDBATOMINFOCONTAINER_HPP_ */
Index: src/Parser/PdbKey.hpp
===================================================================
--- src/Parser/PdbKey.hpp	(revision 4fbca9c2b6785a7839394eeab5fe9c6dad6c28cd)
+++ src/Parser/PdbKey.hpp	(revision 4fbca9c2b6785a7839394eeab5fe9c6dad6c28cd)
@@ -0,0 +1,34 @@
+/*
+ * PdbKey.hpp
+ *
+ *  Created on: Dec 4, 2010
+ *      Author: heber
+ */
+
+#ifndef PDBKEY_HPP_
+#define PDBKEY_HPP_
+
+/**
+ * Known keys for the Pdb line.
+ */
+class PdbKey {
+public:
+  enum KnownTokens { Atom, Remark, Connect, Filler, EndOfFile, NoToken };
+
+  enum PdbDataKey {
+    noKey,
+    serial,
+    name,
+    altloc,
+    resName,
+    chainID,
+    resSeq,
+    iCode,
+    occupancy,
+    tempFactor,
+    charge
+  };
+};
+
+
+#endif /* PDBKEY_HPP_ */
Index: src/Parser/PdbParser.cpp
===================================================================
--- src/Parser/PdbParser.cpp	(revision cca9efb7bf18583f35d0380acb97e9034c42bbe7)
+++ src/Parser/PdbParser.cpp	(revision 4fbca9c2b6785a7839394eeab5fe9c6dad6c28cd)
@@ -22,6 +22,6 @@
 #include "Helpers/Assert.hpp"
 #include "Helpers/Log.hpp"
+#include "Helpers/toString.hpp"
 #include "Helpers/Verbose.hpp"
-#include "PdbParser.hpp"
 #include "World.hpp"
 #include "atom.hpp"
@@ -31,4 +31,5 @@
 #include "periodentafel.hpp"
 #include "Descriptors/AtomIdDescriptor.hpp"
+#include "Parser/PdbParser.hpp"
 
 #include <map>
@@ -44,17 +45,10 @@
  */
 PdbParser::PdbParser() {
-  knownKeys[" "] = PdbKey::noKey; // with this we can detect invalid keys
-  knownKeys["x"] = PdbKey::x;
-  knownKeys["Id"] = PdbKey::Id;
-  knownKeys["Type"] = PdbKey::Type;
-  knownKeys["extType"] = PdbKey::extType;
-  knownKeys["name"] = PdbKey::name;
-  knownKeys["resName"] = PdbKey::resName;
-  knownKeys["chainID"] = PdbKey::chainID;
-  knownKeys["resSeq"] = PdbKey::resSeq;
-  knownKeys["occupancy"] = PdbKey::occupancy;
-  knownKeys["tempFactor"] = PdbKey::tempFactor;
-  knownKeys["segID"] = PdbKey::segID;
-  knownKeys["charge"] = PdbKey::charge;
+  knownTokens["ATOM"] = PdbKey::Atom;
+  knownTokens["TER"] = PdbKey::Filler;
+  knownTokens["END"] = PdbKey::EndOfFile;
+  knownTokens["CONECT"] = PdbKey::Connect;
+  knownTokens["REMARK"] = PdbKey::Remark;
+  knownTokens[""] = PdbKey::EndOfFile;
 }
 
@@ -65,39 +59,82 @@
   additionalAtomData.clear();
   atomIdMap.clear();
-  knownKeys.clear();
-}
-
-/**
- * Loads atoms from a tremolo-formatted file.
- *
- * \param tremolo file
+}
+
+
+/** Parses the initial word of the given \a line and returns the token type.
+ *
+ * @param line line to scan
+ * @return token type
+ */
+enum PdbKey::KnownTokens PdbParser::getToken(string &line)
+{
+  // look for first space
+  const size_t space_location = line.find(' ');
+  const size_t tab_location = line.find('\t');
+  size_t location = space_location < tab_location ? space_location : tab_location;
+  string token;
+  if (location != string::npos) {
+    //DoLog(1) && (Log() << Verbose(1) << "Found space at position " << space_location << std::endl);
+    token = line.substr(0,space_location);
+  } else {
+    token = line;
+  }
+
+  //DoLog(1) && (Log() << Verbose(1) << "Token is " << token << std::endl);
+  if (knownTokens.count(token) == 0)
+    return PdbKey::NoToken;
+  else
+    return knownTokens[token];
+
+  return PdbKey::NoToken;
+}
+
+/**
+ * Loads atoms from a PDB-formatted file.
+ *
+ * \param PDB file
  */
 void PdbParser::load(istream* file) {
-  // TODO: PdbParser::load implementation
-  ASSERT(false, "Not implemented yet");
-//  string line;
-//  string::size_type location;
-//
-//  usedFields.clear();
-//  while (file->good()) {
-//    std::getline(*file, line, '\n');
-//    if (usedFields.empty()) {
-//      location = line.find("ATOMDATA", 0);
-//      if (location != string::npos) {
-//       parseAtomDataKeysLine(line, location + 8);
-//      }
-//    }
-//    if (line.length() > 0 && line.at(0) != '#') {
-//      readAtomDataLine(line);
-//    }
-//  }
-//
-//  processNeighborInformation();
-//  adaptImprData();
-//  adaptTorsion();
-}
-
-/**
- * Saves the World's current state into as a tremolo file.
+  string line;
+  size_t linecount  = 0;
+  enum PdbKey::KnownTokens token;
+
+  molecule *newmol = World::getInstance().createMolecule();
+  newmol->ActiveFlag = true;
+  bool NotEndOfFile = true;
+  // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include
+  World::getInstance().getMolecules()->insert(newmol);
+  while (NotEndOfFile) {
+    std::getline(*file, line, '\n');
+    // extract first token
+    token = getToken(line);
+    //DoLog(1) && (Log() << Verbose(1) << " Recognized token of type : " << token << std::endl);
+    switch (token) {
+      case PdbKey::Atom:
+        readAtomDataLine(line, newmol);
+        break;
+      case PdbKey::Remark:
+        break;
+      case PdbKey::Connect:
+        readNeighbors(line);
+        break;
+      case PdbKey::Filler:
+        break;
+      case PdbKey::EndOfFile:
+        NotEndOfFile = false;
+        break;
+      default:
+        // TODO: put a throw here
+        DoeLog(2) && (eLog() << Verbose(2) << "Unknown token: '" << line << "'" << std::endl);
+        //ASSERT(0, "PdbParser::load() - Unknown token in line "+toString(linecount)+": "+line+".");
+        break;
+    }
+    NotEndOfFile = NotEndOfFile && (file->good());
+    linecount++;
+  }
+}
+
+/**
+ * Saves the World's current state into as a PDB file.
  *
  * \param file where to save the state
@@ -120,4 +157,6 @@
   }
 
+  // we distribute new atom numbers, hence clear map beforehand
+  atomIdMap.clear();
   {
     vector<atom *> AtomList = World::getInstance().getAllAtoms();
@@ -155,5 +194,5 @@
 
 /**
- * Writes one line of tremolo-formatted data to the provided stream.
+ * Writes one line of PDB-formatted data to the provided stream.
  *
  * \param stream where to write the line to
@@ -198,9 +237,9 @@
   if (!currentAtom->ListOfBonds.empty()) {
     *file << "CONECT";
-    *file << setw(5) << getAtomId(currentAtom->getId());
+    *file << setw(5) << getSerial(currentAtom->getId());
     int MaxNo = 0;
     for(BondList::iterator currentBond = currentAtom->ListOfBonds.begin(); currentBond != currentAtom->ListOfBonds.end(); ++currentBond) {
       if (MaxNo < MaxnumberOfNeighbors) {
-        *file << setw(5) << getAtomId((*currentBond)->GetOtherAtom(currentAtom)->getId());
+        *file << setw(5) << getSerial((*currentBond)->GetOtherAtom(currentAtom)->getId());
       }
       MaxNo++;
@@ -215,5 +254,19 @@
  * \return value
  */
-int PdbParser::getAtomId(int atomid) const
+size_t PdbParser::getSerial(const size_t atomid) const
+{
+  ConvertTo<size_t> toSize_t;
+  ASSERT(additionalAtomData.find(atomid) != additionalAtomData.end(),
+      "PdbParser::getSerial: atomid "+toString(atomid)+" not present in Map.");
+  const PdbAtomInfoContainer &atomInfo = additionalAtomData.at(atomid);
+
+  return toSize_t(atomInfo.get(PdbKey::serial));
+}
+
+/** Retrieves a value from PdbParser::atomIdMap.
+ * \param atomid key
+ * \return value
+ */
+size_t PdbParser::getAtomId(const size_t atomid) const
 {
   ASSERT(atomIdMap.find(atomid) != atomIdMap.end(), "PdbParser::getAtomId: atomid not present in Map.");
@@ -226,66 +279,112 @@
  * \return true - key not present, false - value present
  */
-void PdbParser::setAtomId(int localatomid, int atomid)
-{
-  pair<std::map<int,int>::iterator, bool > inserter;
-  inserter = atomIdMap.insert( pair<int, int>(localatomid, atomid) );
+void PdbParser::setAtomId(const size_t localatomid, const size_t atomid)
+{
+  pair<std::map<size_t,size_t>::iterator, bool > inserter;
+  inserter = atomIdMap.insert( make_pair(localatomid, atomid) );
   ASSERT(inserter.second, "PdbParser::setAtomId: atomId already present in Map.");
 }
 
-/**
- * Reads one data line of a tremolo file and interprets it according to the keys
- * obtained from the ATOMDATA line.
+/** Parse an ATOM line from a PDB file.
+ *
+ * Reads one data line of a pdstatus file and interprets it according to the
+ * specifications of the PDB 3.2 format: http://www.wwpdb.org/docs.html
+ *
+ *  A new atom is created and filled with available information, non-
+ *  standard information is placed in additionalAtomData at the atom's id.
  *
  * \param line to parse as an atom
- */
-void PdbParser::readAtomDataLine(string line) {
-//  vector<string>::iterator it;
-//  stringstream lineStream;
-//  atom* newAtom = World::getInstance().createAtom();
-//  PdbAtomInfoContainer *atomInfo = NULL;
-//  additionalAtomData[newAtom->getId()] = *(new PdbAtomInfoContainer);
-//  atomInfo = &additionalAtomData[newAtom->getId()];
-//  PdbKey::atomDataKey currentField;
-//  string word;
-//  int oldId;
-//  double tmp;
-//
-//  lineStream << line;
-//  for (it = usedFields.begin(); it < usedFields.end(); it++) {
-//    currentField = knownKeys[it->substr(0, it->find("="))];
-//    switch (currentField) {
-//      case PdbKey::x :
-//        // for the moment, assume there are always three dimensions
-//        for (int i=0;i<NDIM;i++) {
-//          lineStream >> tmp;
-//          newAtom->set(i, tmp);
-//        }
-//        break;
-//      case PdbKey::u :
-//        // for the moment, assume there are always three dimensions
-//        lineStream >> newAtom->AtomicVelocity[0];
-//        lineStream >> newAtom->AtomicVelocity[1];
-//        lineStream >> newAtom->AtomicVelocity[2];
-//        break;
-//      case PdbKey::Type :
-//        char type[3];
-//        lineStream >> type;
-//        newAtom->setType(World::getInstance().getPeriode()->FindElement(type));
-//        ASSERT(newAtom->getType(), "Type was not set for this atom");
-//        break;
-//      case PdbKey::Id :
-//        lineStream >> oldId;
-//        atomIdMap[oldId] = newAtom->getId();
-//        break;
-//      case PdbKey::neighbors :
-//        readNeighbors(&lineStream,
-//            atoi(it->substr(it->find("=") + 1, 1).c_str()), newAtom->getId());
-//        break;
-//      default :
-//        lineStream >> word;
-//        atomInfo->set(currentField, word);
-//        break;
-//    }
+ * \param newmol molecule to add parsed atoms to
+ */
+void PdbParser::readAtomDataLine(std::string &line, molecule *newmol = NULL) {
+  vector<string>::iterator it;
+  stringstream lineStream;
+  atom* newAtom = World::getInstance().createAtom();
+  additionalAtomData[newAtom->getId()] = *(new PdbAtomInfoContainer);
+  PdbAtomInfoContainer &atomInfo = additionalAtomData[newAtom->getId()];
+  string word;
+  ConvertTo<size_t> toSize_t;
+  double tmp;
+
+  lineStream << line;
+  atomInfo.set(PdbKey::serial, line.substr(6,5));
+  std::pair< std::set<size_t>::const_iterator, bool> Inserter =
+    SerialSet.insert(toSize_t(atomInfo.get(PdbKey::serial)));
+  ASSERT(Inserter.second,
+      "PdbParser::readAtomDataLine() - ATOM contains entry with serial "
+      +atomInfo.get(PdbKey::serial)+" already present!");
+  // assign hightest+1 instead, but then beware of CONECT entries! Another map needed!
+//  if (!Inserter.second) {
+//    const size_t id = (*SerialSet.rbegin())+1;
+//    SerialSet.insert(id);
+//    atomInfo.set(PdbKey::serial, toString(id));
+//    DoeLog(2) && (eLog() << Verbose(2)
+//        << "Serial " << atomInfo.get(PdbKey::serial) << " already present, "
+//        << "assigning " << toString(id) << " instead." << std::endl);
 //  }
+
+  // check whether serial exists, if so, assign next available
+
+//  DoLog(2) && (Log() << Verbose(2) << "Split line:"
+//      << line.substr(6,5) << "|"
+//      << line.substr(12,4) << "|"
+//      << line.substr(16,1) << "|"
+//      << line.substr(17,3) << "|"
+//      << line.substr(21,1) << "|"
+//      << line.substr(22,4) << "|"
+//      << line.substr(26,1) << "|"
+//      << line.substr(30,8) << "|"
+//      << line.substr(38,8) << "|"
+//      << line.substr(46,8) << "|"
+//      << line.substr(54,6) << "|"
+//      << line.substr(60,6) << "|"
+//      << line.substr(76,2) << "|"
+//      << line.substr(78,2) << std::endl);
+
+  setAtomId(toSize_t(atomInfo.get(PdbKey::serial)), newAtom->getId());
+  atomInfo.set(PdbKey::name, line.substr(12,4));
+  atomInfo.set(PdbKey::altloc, line.substr(16,1));
+  atomInfo.set(PdbKey::resName, line.substr(17,3));
+  atomInfo.set(PdbKey::chainID, line.substr(21,1));
+  atomInfo.set(PdbKey::resSeq, line.substr(22,4));
+  atomInfo.set(PdbKey::iCode, line.substr(26,1));
+  PdbAtomInfoContainer::ScanKey(tmp, line.substr(30,8));
+  newAtom->set(0, tmp);
+  PdbAtomInfoContainer::ScanKey(tmp, line.substr(38,8));
+  newAtom->set(1, tmp);
+  PdbAtomInfoContainer::ScanKey(tmp, line.substr(46,8));
+  newAtom->set(2, tmp);
+  atomInfo.set(PdbKey::occupancy, line.substr(54,6));
+  atomInfo.set(PdbKey::tempFactor, line.substr(60,6));
+  atomInfo.set(PdbKey::charge, line.substr(78,2));
+  PdbAtomInfoContainer::ScanKey(word, line.substr(76,2));
+  newAtom->setType(World::getInstance().getPeriode()->FindElement(word));
+
+  if (newmol != NULL)
+    newmol->AddAtom(newAtom);
+
+//  printAtomInfo(newAtom);
+}
+
+/** Prints all PDB-specific information known about an atom.
+ *
+ */
+void PdbParser::printAtomInfo(const atom * const newAtom) const
+{
+  const PdbAtomInfoContainer &atomInfo = additionalAtomData.at(newAtom->getId()); // operator[] const does not exist
+
+  DoLog(1) && (Log() << Verbose(1) << "We know about atom " << newAtom->getId() << ":" << std::endl);
+  DoLog(1) && (Log() << Verbose(1) << "\tserial is " << atomInfo.get(PdbKey::serial) << std::endl);
+  DoLog(1) && (Log() << Verbose(1) << "\tname is " << atomInfo.get(PdbKey::name) << std::endl);
+  DoLog(1) && (Log() << Verbose(1) << "\taltloc is " << atomInfo.get(PdbKey::altloc) << std::endl);
+  DoLog(1) && (Log() << Verbose(1) << "\tresName is " << atomInfo.get(PdbKey::resName) << std::endl);
+  DoLog(1) && (Log() << Verbose(1) << "\tchainID is " << atomInfo.get(PdbKey::chainID) << std::endl);
+  DoLog(1) && (Log() << Verbose(1) << "\tresSeq is " << atomInfo.get(PdbKey::resSeq) << std::endl);
+  DoLog(1) && (Log() << Verbose(1) << "\tiCode is " << atomInfo.get(PdbKey::iCode) << std::endl);
+  DoLog(1) && (Log() << Verbose(1) << "\tx is " << newAtom->getPosition() << std::endl);
+  DoLog(1) && (Log() << Verbose(1) << "\toccupancy is " << atomInfo.get(PdbKey::occupancy) << std::endl);
+  DoLog(1) && (Log() << Verbose(1) << "\ttempFactor is " << atomInfo.get(PdbKey::tempFactor) << std::endl);
+  DoLog(1) && (Log() << Verbose(1) << "\telement is '" << *(newAtom->getType()) << "'" << std::endl);
+  DoLog(1) && (Log() << Verbose(1) << "\tcharge is " << atomInfo.get(PdbKey::charge) << std::endl);
 }
 
@@ -293,39 +392,40 @@
  * Reads neighbor information for one atom from the input.
  *
- * \param stream where to read the information from
- * \param number of neighbors to read
- * \param world id of the atom the information belongs to
- */
-void PdbParser::readNeighbors(stringstream* line, int numberOfNeighbors, int atomId) {
-//  int neighborId = 0;
-//  for (int i = 0; i < numberOfNeighbors; i++) {
-//    *line >> neighborId;
-//    // 0 is used to fill empty neighbor positions in the tremolo file.
-//    if (neighborId > 0) {
-//      additionalAtomData[atomId].neighbors.push_back(neighborId);
-//    }
-//  }
-}
-
-/**
- * Adds the collected neighbor information to the atoms in the world. The atoms
- * are found by their current ID and mapped to the corresponding atoms with the
- * Id found in the parsed file.
- */
-void PdbParser::processNeighborInformation() {
-//  if (!isUsedField("neighbors")) {
-//    return;
-//  }
-//
-//  for(map<int, PdbAtomInfoContainer>::iterator currentInfo = additionalAtomData.begin();
-//    currentInfo != additionalAtomData.end(); currentInfo++
-//  ) {
-//    for(vector<int>::iterator neighbor = currentInfo->second.neighbors.begin();
-//      neighbor != currentInfo->second.neighbors.end(); neighbor++
-//    ) {
-//      World::getInstance().getAtom(AtomById(currentInfo->first))
-//          ->addBond(World::getInstance().getAtom(AtomById(atomIdMap[*neighbor])));
-//    }
-//  }
+ * \param line to parse as an atom
+ */
+void PdbParser::readNeighbors(std::string &line)
+{
+  const size_t length = line.length();
+  std::list<size_t> ListOfNeighbors;
+  ConvertTo<size_t> toSize_t;
+
+  // obtain neighbours
+  // show split line for debugging
+  string output;
+  ASSERT(length >=16,
+      "PdbParser::readNeighbors() - CONECT entry has not enough entries: "+line+"!");
+//  output = "Split line:|";
+//  output += line.substr(6,5) + "|";
+  const size_t id = toSize_t(line.substr(6,5));
+  for (size_t index = 11; index <= 26; index+=5) {
+    if (index+5 <= length) {
+//      output += line.substr(index,5) + "|";
+      const size_t otherid = toSize_t(line.substr(index,5));
+      ListOfNeighbors.push_back(otherid);
+    } else  {
+      break;
+    }
+  }
+//  DoLog(2) && (Log() << Verbose(2) << output << std::endl);
+
+  // add neighbours
+  atom *_atom = World::getInstance().getAtom(AtomById(getAtomId(id)));
+  for (std::list<size_t>::const_iterator iter = ListOfNeighbors.begin();
+      iter != ListOfNeighbors.end();
+      ++iter) {
+//    DoLog(1) && (Log() << Verbose(1) << "Adding Bond (" << getAtomId(id) << "," << getAtomId(*iter) << ")" << std::endl);
+    atom * const _Otheratom = World::getInstance().getAtom(AtomById(getAtomId(*iter)));
+    _atom->addBond(_Otheratom);
+  }
 }
 
@@ -339,5 +439,5 @@
  * \return input string with modified atom IDs
  */
-string PdbParser::adaptIdDependentDataString(string data) {
+//string PdbParser::adaptIdDependentDataString(string data) {
 //  // there might be no IDs
 //  if (data == "-") {
@@ -358,78 +458,42 @@
 //
 //  return result.str();
-  return "";
-}
-
-
-PdbAtomInfoContainer::PdbAtomInfoContainer() :
-  name("-"),
-  resName("-"),
-  chainID("0"),
-  resSeq("0"),
-  occupancy("0"),
-  tempFactor("0"),
-  segID("0"),
-  charge("0")
-{}
-
-void PdbAtomInfoContainer::set(PdbKey::PdbDataKey key, string value) {
-  switch (key) {
-    case PdbKey::extType :
-      extType = value;
-      break;
-    case PdbKey::name :
-      name = value;
-      break;
-    case PdbKey::resName :
-      resName = value;
-      break;
-    case PdbKey::chainID :
-      chainID = value;
-      break;
-    case PdbKey::resSeq :
-      resSeq = value;
-      break;
-    case PdbKey::occupancy :
-      occupancy = value;
-      break;
-    case PdbKey::tempFactor :
-      tempFactor = value;
-      break;
-    case PdbKey::segID :
-      segID = value;
-      break;
-    case PdbKey::charge :
-      charge = value;
-      break;
-    default :
-      cout << "Unknown key: " << key << ", value: " << value << endl;
-      break;
-  }
-}
-
-string PdbAtomInfoContainer::get(PdbKey::PdbDataKey key) {
-  switch (key) {
-    case PdbKey::extType :
-      return extType;
-    case PdbKey::name :
-      return name;
-    case PdbKey::resName :
-      return resName;
-    case PdbKey::chainID :
-      return chainID;
-    case PdbKey::resSeq :
-      return resSeq;
-    case PdbKey::occupancy :
-      return occupancy;
-    case PdbKey::tempFactor :
-      return tempFactor;
-    case PdbKey::segID :
-      return segID;
-    case PdbKey::charge :
-      return charge;
-    default :
-      cout << "Unknown key: " << key << endl;
-      return "";
-  }
-}
-
+//  return "";
+//}
+
+
+bool PdbParser::operator==(const PdbParser& b) const
+{
+  bool status = true;
+  World::AtomComposite atoms = World::getInstance().getAllAtoms();
+  for (World::AtomComposite::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
+    if ((additionalAtomData.find((*iter)->getId()) != additionalAtomData.end())
+        && (b.additionalAtomData.find((*iter)->getId()) != b.additionalAtomData.end())) {
+      const PdbAtomInfoContainer &atomInfo = additionalAtomData.at((*iter)->getId());
+      const PdbAtomInfoContainer &OtheratomInfo = b.additionalAtomData.at((*iter)->getId());
+
+      status = status && (atomInfo.get(PdbKey::serial) == OtheratomInfo.get(PdbKey::serial));
+      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in serials!" << std::endl);
+      status = status && (atomInfo.get(PdbKey::name) == OtheratomInfo.get(PdbKey::name));
+      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in names!" << std::endl);
+      status = status && (atomInfo.get(PdbKey::altloc) == OtheratomInfo.get(PdbKey::altloc));
+      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in altlocs!" << std::endl);
+      status = status && (atomInfo.get(PdbKey::resName) == OtheratomInfo.get(PdbKey::resName));
+      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in resNames!" << std::endl);
+      status = status && (atomInfo.get(PdbKey::chainID) == OtheratomInfo.get(PdbKey::chainID));
+      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in chainIDs!" << std::endl);
+      status = status && (atomInfo.get(PdbKey::resSeq) == OtheratomInfo.get(PdbKey::resSeq));
+      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in resSeqs!" << std::endl);
+      status = status && (atomInfo.get(PdbKey::iCode) == OtheratomInfo.get(PdbKey::iCode));
+      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in iCodes!" << std::endl);
+      status = status && (atomInfo.get(PdbKey::occupancy) == OtheratomInfo.get(PdbKey::occupancy));
+      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in occupancies!" << std::endl);
+      status = status && (atomInfo.get(PdbKey::tempFactor) == OtheratomInfo.get(PdbKey::tempFactor));
+      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in tempFactors!" << std::endl);
+      status = status && (atomInfo.get(PdbKey::charge) == OtheratomInfo.get(PdbKey::charge));
+      if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in charges!" << std::endl);
+    }
+  }
+
+  return status;
+}
+
Index: src/Parser/PdbParser.hpp
===================================================================
--- src/Parser/PdbParser.hpp	(revision cca9efb7bf18583f35d0380acb97e9034c42bbe7)
+++ src/Parser/PdbParser.hpp	(revision 4fbca9c2b6785a7839394eeab5fe9c6dad6c28cd)
@@ -10,49 +10,10 @@
 
 #include <string>
-#include "Parser/FormatParser.hpp"
+#include "FormatParser.hpp"
+#include "PdbAtomInfoContainer.hpp"
+#include "PdbKey.hpp"
 
 /**
- * Known keys for the Pdb line.
- */
-class PdbKey {
-public:
-  enum PdbDataKey {
-    noKey,
-    x,
-    Id,
-    Type,
-    extType,
-    name,
-    resName,
-    chainID,
-    resSeq,
-    occupancy,
-    tempFactor,
-    segID,
-    charge
-  };
-};
-
-/**
- * Holds tremolo-specific information which is not store in the atom class.
- */
-class PdbAtomInfoContainer {
-public:
-  PdbAtomInfoContainer();
-  void set(PdbKey::PdbDataKey key, std::string value);
-  std::string get(PdbKey::PdbDataKey key);
-  std::string name;
-  std::string extType;
-  std::string resName;
-  std::string chainID;
-  std::string resSeq;
-  std::string occupancy;
-  std::string tempFactor;
-  std::string segID;
-  std::string charge;
-};
-
-/**
- * Loads a tremolo file into the World and saves the World as a tremolo file.
+ * Loads a PDB format 3.2 file into the World and saves the World as a PDB file.
  */
 class PdbParser : public FormatParser
@@ -64,23 +25,28 @@
   void save(std::ostream* file);
 
+  bool operator==(const PdbParser& b) const;
+  void printAtomInfo(const atom *newAtom) const;
 
 private:
-  void readAtomDataLine(string line);
+  enum PdbKey::KnownTokens getToken(string &line);
+  void readAtomDataLine(string &line, molecule *newmol);
   void parseAtomDataKeysLine(string line, int offset);
-  void readNeighbors(std::stringstream* line, int numberOfNeighbors, int atomId);
-  void processNeighborInformation();
-  void adaptImprData();
-  void adaptTorsion();
-  std::string adaptIdDependentDataString(std::string data);
+  void readNeighbors(std::string &line);
+//  void adaptImprData();
+//  void adaptTorsion();
+//  std::string adaptIdDependentDataString(std::string data);
   bool isUsedField(std::string fieldName);
   void writeNeighbors(std::ostream* file, int numberOfNeighbors, atom* currentAtom);
   void saveLine(ostream* file, const atom* currentAtom, const char *name, const int AtomNo, const int ResdueNo);
-  int getAtomId(int atomid) const;
-  void setAtomId(int localatomid, int atomid);
+
+  // internal getter and setter
+  size_t getSerial(const size_t atomid) const;
+  size_t getAtomId(const size_t atomid) const;
+  void setAtomId(const size_t localatomid, const size_t atomid);
 
   /**
    * Map to associate the known keys with numbers.
    */
-  std::map<std::string, PdbKey::PdbDataKey> knownKeys;
+  std::map<std::string, PdbKey::KnownTokens> knownTokens;
 
   /**
@@ -88,5 +54,5 @@
    * file.
    */
-  std::map<int, PdbAtomInfoContainer> additionalAtomData;
+  std::map<size_t, PdbAtomInfoContainer> additionalAtomData;
 
   /**
@@ -99,5 +65,12 @@
    * world.
    */
-  std::map<int, int> atomIdMap;
+  std::map<size_t, size_t> atomIdMap;
+
+  /**
+   * Maps original atom IDs received from the parsed file to atom IDs in the
+   * world.
+   */
+  std::set<size_t> SerialSet;
+
 };
 
