Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/PdbParser.cpp

    r765f16 r3bdb6d  
    2828#include "atom.hpp"
    2929#include "Bond/bond.hpp"
    30 #include "element.hpp"
     30#include "Element/element.hpp"
    3131#include "molecule.hpp"
    32 #include "periodentafel.hpp"
     32#include "Element/periodentafel.hpp"
    3333#include "Descriptors/AtomIdDescriptor.hpp"
    3434#include "Parser/PdbParser.hpp"
     
    4444using namespace std;
    4545
    46 // declare specialized static variables
    47 const std::string FormatParserTrait<pdb>::name = "pdb";
    48 const std::string FormatParserTrait<pdb>::suffix = "pdb";
    49 const ParserTypes FormatParserTrait<pdb>::type = pdb;
    50 
    5146/**
    5247 * Constructor.
    5348 */
    54 FormatParser< pdb >::FormatParser() :
    55   FormatParser_common(NULL)
    56 {
     49PdbParser::PdbParser() {
    5750  knownTokens["ATOM"] = PdbKey::Atom;
    5851  knownTokens["HETATM"] = PdbKey::Atom;
     
    7265 * Destructor.
    7366 */
    74 FormatParser< pdb >::~FormatParser()
    75 {
     67PdbParser::~PdbParser() {
    7668  PdbAtomInfoContainer::clearknownDataKeys();
    7769  additionalAtomData.clear();
     
    8577 * @return token type
    8678 */
    87 enum PdbKey::KnownTokens FormatParser< pdb >::getToken(string &line)
     79enum PdbKey::KnownTokens PdbParser::getToken(string &line)
    8880{
    8981  // look for first space
     
    113105 * \param PDB file
    114106 */
    115 void FormatParser< pdb >::load(istream* file) {
     107void PdbParser::load(istream* file) {
    116108  string line;
    117109  size_t linecount  = 0;
     
    156148            // TODO: put a throw here
    157149            DoeLog(2) && (eLog() << Verbose(2) << "Unknown token: '" << line << "' for time step " << step << "." << std::endl);
    158             //ASSERT(0, "FormatParser< pdb >::load() - Unknown token in line "+toString(linecount)+": "+line+".");
     150            //ASSERT(0, "PdbParser::load() - Unknown token in line "+toString(linecount)+": "+line+".");
    159151            break;
    160152        }
     
    178170 * \param atoms atoms to store
    179171 */
    180 void FormatParser< pdb >::save(ostream* file, const std::vector<atom *> &AtomList)
     172void PdbParser::save(ostream* file, const std::vector<atom *> &AtomList)
    181173{
    182174  DoLog(0) && (Log() << Verbose(0) << "Saving changes to pdb." << std::endl);
     
    248240        } else {
    249241          ASSERT(MolIdMap.find(mol->getId()) != MolIdMap.end(),
    250               "FormatParser< pdb >::save() - Mol id "+toString(mol->getId())+" not present despite we set it?!");
     242              "PdbParser::save() - Mol id "+toString(mol->getId())+" not present despite we set it?!");
    251243          MolNo = MolIdMap[mol->getId()];
    252244          atomInfo.set(PdbKey::resSeq, toString(MolIdMap[mol->getId()]));
     
    297289 * @param id of atom
    298290 */
    299 void FormatParser< pdb >::AtomInserted(atomId_t id)
    300 {
    301   //LOG(3, "FormatParser< pdb >::AtomInserted() - notified of atom " << id << "'s insertion.");
     291void PdbParser::AtomInserted(atomId_t id)
     292{
     293  //LOG(3, "PdbParser::AtomInserted() - notified of atom " << id << "'s insertion.");
    302294  ASSERT(!isPresentadditionalAtomData(id),
    303       "FormatParser< pdb >::AtomInserted() - additionalAtomData already present for newly added atom "
     295      "PdbParser::AtomInserted() - additionalAtomData already present for newly added atom "
    304296      +toString(id)+".");
    305297  // don't insert here as this is our check whether we are in the first time step
     
    312304 * @param id of atom
    313305 */
    314 void FormatParser< pdb >::AtomRemoved(atomId_t id)
    315 {
    316   //LOG(3, "FormatParser< pdb >::AtomRemoved() - notified of atom " << id << "'s removal.");
     306void PdbParser::AtomRemoved(atomId_t id)
     307{
     308  //LOG(3, "PdbParser::AtomRemoved() - notified of atom " << id << "'s removal.");
    317309  std::map<size_t, PdbAtomInfoContainer>::iterator iter = additionalAtomData.find(id);
    318310  // as we do not insert AtomData on AtomInserted, we cannot be assured of its presence
    319311//  ASSERT(iter != additionalAtomData.end(),
    320 //      "FormatParser< pdb >::AtomRemoved() - additionalAtomData is not present for atom "
     312//      "PdbParser::AtomRemoved() - additionalAtomData is not present for atom "
    321313//      +toString(id)+" to remove.");
    322314  if (iter != additionalAtomData.end()) {
     
    333325 * @return true - entry present, false - only for atom's father or no entry
    334326 */
    335 bool FormatParser< pdb >::isPresentadditionalAtomData(unsigned int _id)
     327bool PdbParser::isPresentadditionalAtomData(unsigned int _id)
    336328{
    337329  return (additionalAtomData.find(_id) != additionalAtomData.end());
     
    344336 * @return
    345337 */
    346 PdbAtomInfoContainer& FormatParser< pdb >::getadditionalAtomData(atom *_atom)
     338PdbAtomInfoContainer& PdbParser::getadditionalAtomData(atom *_atom)
    347339{
    348340  if (additionalAtomData.find(_atom->getId()) != additionalAtomData.end()) {
     
    370362 * \param ResidueNo number of residue
    371363 */
    372 void FormatParser< pdb >::saveLine(
     364void PdbParser::saveLine(
    373365    ostream* file,
    374366    const PdbAtomInfoContainer &atomInfo)
     
    431423 * \param *currentAtom to the atom of which to take the neighbor information
    432424 */
    433 void FormatParser< pdb >::writeNeighbors(ostream* file, int MaxnumberOfNeighbors, atom* currentAtom) {
     425void PdbParser::writeNeighbors(ostream* file, int MaxnumberOfNeighbors, atom* currentAtom) {
    434426  int MaxNo = MaxnumberOfNeighbors;
    435427  int charsleft = 80;
     
    460452}
    461453
    462 /** Retrieves a value from  FormatParser< pdb >::atomIdMap.
     454/** Retrieves a value from PdbParser::atomIdMap.
    463455 * \param atomid key
    464456 * \return value
    465457 */
    466 size_t FormatParser< pdb >::getSerial(const size_t atomid) const
    467 {
    468   ASSERT(atomIdMap.find(atomid) != atomIdMap.end(), 
    469       "FormatParser< pdb >::getAtomId: atomid "+toString(atomid)+" not present in Map.");
     458size_t PdbParser::getSerial(const size_t atomid) const
     459{
     460  ASSERT(atomIdMap.find(atomid) != atomIdMap.end(),
     461      "PdbParser::getSerial() - atomid "+toString(atomid)+" not present in Map.");
    470462  return (atomIdMap.find(atomid)->second);
    471463}
    472464
    473 /** Sets an entry in  FormatParser< pdb >::atomIdMap.
     465/** Sets an entry in PdbParser::atomIdMap.
    474466 * \param localatomid key
    475467 * \param atomid value
    476468 * \return true - key not present, false - value present
    477469 */
    478 void FormatParser< pdb >::setSerial(const size_t localatomid, const size_t atomid)
     470void PdbParser::setSerial(const size_t localatomid, const size_t atomid)
    479471{
    480472  pair<std::map<size_t,size_t>::iterator, bool > inserter;
    481 //  DoLog(1) && (Log() << Verbose(1) << "FormatParser< pdb >::setAtomId() - Inserting ("
     473//  DoLog(1) && (Log() << Verbose(1) << "PdbParser::setAtomId() - Inserting ("
    482474//      << localatomid << " -> " << atomid << ")." << std::endl);
    483475  inserter = atomIdMap.insert( make_pair(localatomid, atomid) );
    484   ASSERT(inserter.second, "FormatParser< pdb >::setAtomId: atomId already present in Map.");
     476  ASSERT(inserter.second, "PdbParser::setAtomId: atomId already present in Map.");
    485477}
    486478
     
    490482 * @return
    491483 */
    492 atom* FormatParser< pdb >::getAtomToParse(std::string id_string) const
     484atom* PdbParser::getAtomToParse(std::string id_string) const
    493485{
    494486  // get the local ID
     
    525517 * @param line line containing key ATOM
    526518 */
    527 void FormatParser< pdb >::readPdbAtomInfoContainer(PdbAtomInfoContainer &atomInfo, std::string &line) const
     519void PdbParser::readPdbAtomInfoContainer(PdbAtomInfoContainer &atomInfo, std::string &line) const
    528520{
    529521  const size_t length = line.length();
    530522  if (length < 80)
    531     ELOG(2, "FormatParser< pdb >::readPdbAtomInfoContainer() - pdb is mal-formed, containing less than 80 chars!");
     523    ELOG(2, "PdbParser::readPdbAtomInfoContainer() - pdb is mal-formed, containing less than 80 chars!");
    532524  if (length >= 6) {
    533525    LOG(4,"INFO: Parsing token from "+line.substr(0,6)+".");
     
    538530    atomInfo.set(PdbKey::serial, line.substr(6,5));
    539531    ASSERT(atomInfo.get<int>(PdbKey::serial) != 0,
    540         "FormatParser< pdb >::readPdbAtomInfoContainer() - serial 0 is invalid (filler id for conect entries).");
     532        "PdbParser::readPdbAtomInfoContainer() - serial 0 is invalid (filler id for conect entries).");
    541533  }
    542534
     
    599591 * \param newmol molecule to add parsed atoms to
    600592 */
    601 void FormatParser< pdb >::readAtomDataLine(const unsigned int _step, std::string &line, molecule *newmol = NULL) {
     593void PdbParser::readAtomDataLine(const unsigned int _step, std::string &line, molecule *newmol = NULL) {
    602594  vector<string>::iterator it;
    603595
     
    606598  bool FirstTimestep = isPresentadditionalAtomData(newAtom->getId()) ? false : true;
    607599  ASSERT((FirstTimestep && (_step == 0)) || (!FirstTimestep && (_step !=0)),
    608       "FormatParser< pdb >::readAtomDataLine() - additionalAtomData present though atom is newly parsed.");
     600      "PdbParser::readAtomDataLine() - additionalAtomData present though atom is newly parsed.");
    609601  if (FirstTimestep) {
    610602    LOG(3,"INFO: Parsing new atom.");
     
    654646      SerialSet.insert(toSize_t(atomInfo.get<std::string>(PdbKey::serial)));
    655647    ASSERT(Inserter.second,
    656         "FormatParser< pdb >::readAtomDataLine() - ATOM contains entry with serial "
     648        "PdbParser::readAtomDataLine() - ATOM contains entry with serial "
    657649        +atomInfo.get<std::string>(PdbKey::serial)+" already present!");
    658650    setSerial(toSize_t(atomInfo.get<std::string>(PdbKey::serial)), newAtom->getId());
     
    675667        ->FindElement(value);
    676668    ASSERT(elem != NULL,
    677         "FormatParser< pdb >::readAtomDataLine() - element "+atomInfo.get<std::string>(PdbKey::element)+" is unknown!");
     669        "PdbParser::readAtomDataLine() - element "+atomInfo.get<std::string>(PdbKey::element)+" is unknown!");
    678670    newAtom->setType(elem);
    679671
     
    687679    // then check additional info for consistency
    688680    ASSERT(atomInfo.get<std::string>(PdbKey::token) == consistencyInfo.get<std::string>(PdbKey::token),
    689         "FormatParser< pdb >::readAtomDataLine() - difference in token on multiple time step for atom with id "
     681        "PdbParser::readAtomDataLine() - difference in token on multiple time step for atom with id "
    690682        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    691683    ASSERT(atomInfo.get<std::string>(PdbKey::name) == consistencyInfo.get<std::string>(PdbKey::name),
    692         "FormatParser< pdb >::readAtomDataLine() - difference in name on multiple time step for atom with id "
     684        "PdbParser::readAtomDataLine() - difference in name on multiple time step for atom with id "
    693685        +atomInfo.get<std::string>(PdbKey::serial)+":"
    694686        +atomInfo.get<std::string>(PdbKey::name)+"!="
    695687        +consistencyInfo.get<std::string>(PdbKey::name)+".");
    696688    ASSERT(atomInfo.get<std::string>(PdbKey::altLoc) == consistencyInfo.get<std::string>(PdbKey::altLoc),
    697         "FormatParser< pdb >::readAtomDataLine() - difference in altLoc on multiple time step for atom with id "
     689        "PdbParser::readAtomDataLine() - difference in altLoc on multiple time step for atom with id "
    698690        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    699691    ASSERT(atomInfo.get<std::string>(PdbKey::resName) == consistencyInfo.get<std::string>(PdbKey::resName),
    700         "FormatParser< pdb >::readAtomDataLine() - difference in resName on multiple time step for atom with id "
     692        "PdbParser::readAtomDataLine() - difference in resName on multiple time step for atom with id "
    701693        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    702694    ASSERT(atomInfo.get<std::string>(PdbKey::chainID) == consistencyInfo.get<std::string>(PdbKey::chainID),
    703         "FormatParser< pdb >::readAtomDataLine() - difference in chainID on multiple time step for atom with id "
     695        "PdbParser::readAtomDataLine() - difference in chainID on multiple time step for atom with id "
    704696        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    705697    ASSERT(atomInfo.get<std::string>(PdbKey::resSeq) == consistencyInfo.get<std::string>(PdbKey::resSeq),
    706         "FormatParser< pdb >::readAtomDataLine() - difference in resSeq on multiple time step for atom with id "
     698        "PdbParser::readAtomDataLine() - difference in resSeq on multiple time step for atom with id "
    707699        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    708700    ASSERT(atomInfo.get<std::string>(PdbKey::iCode) == consistencyInfo.get<std::string>(PdbKey::iCode),
    709         "FormatParser< pdb >::readAtomDataLine() - difference in iCode on multiple time step for atom with id "
     701        "PdbParser::readAtomDataLine() - difference in iCode on multiple time step for atom with id "
    710702        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    711703    ASSERT(atomInfo.get<std::string>(PdbKey::occupancy) == consistencyInfo.get<std::string>(PdbKey::occupancy),
    712         "FormatParser< pdb >::readAtomDataLine() - difference in occupancy on multiple time step for atom with id "
     704        "PdbParser::readAtomDataLine() - difference in occupancy on multiple time step for atom with id "
    713705        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    714706    ASSERT(atomInfo.get<std::string>(PdbKey::tempFactor) == consistencyInfo.get<std::string>(PdbKey::tempFactor),
    715         "FormatParser< pdb >::readAtomDataLine() - difference in tempFactor on multiple time step for atom with id "
     707        "PdbParser::readAtomDataLine() - difference in tempFactor on multiple time step for atom with id "
    716708        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    717709    ASSERT(atomInfo.get<std::string>(PdbKey::charge) == consistencyInfo.get<std::string>(PdbKey::charge),
    718         "FormatParser< pdb >::readAtomDataLine() - difference in charge on multiple time step for atom with id "
     710        "PdbParser::readAtomDataLine() - difference in charge on multiple time step for atom with id "
    719711        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    720712    ASSERT(atomInfo.get<std::string>(PdbKey::element) == consistencyInfo.get<std::string>(PdbKey::element),
    721         "FormatParser< pdb >::readAtomDataLine() - difference in element on multiple time step for atom with id "
     713        "PdbParser::readAtomDataLine() - difference in element on multiple time step for atom with id "
    722714        +atomInfo.get<std::string>(PdbKey::serial)+"!");
    723715    // and parse in trajectory
     
    742734 *
    743735 */
    744 void FormatParser< pdb >::printAtomInfo(const atom * const newAtom) const
     736void PdbParser::printAtomInfo(const atom * const newAtom) const
    745737{
    746738  const PdbAtomInfoContainer &atomInfo = additionalAtomData.at(newAtom->getId()); // operator[] const does not exist
     
    770762 * \param line to parse as an atom
    771763 */
    772 void FormatParser< pdb >::readNeighbors(const unsigned int _step, std::string &line)
     764void PdbParser::readNeighbors(const unsigned int _step, std::string &line)
    773765{
    774766  const size_t length = line.length();
     
    780772  string output;
    781773  ASSERT(length >=16,
    782       "FormatParser< pdb >::readNeighbors() - CONECT entry has not enough entries: "+line+"!");
    783 //  output = "Split line:|";
    784 //  output += line.substr(6,5) + "|";
     774      "PdbParser::readNeighbors() - CONECT entry has not enough entries: "+line+"!");
     775  output = "Split line:|";
     776  output += line.substr(6,5) + "|";
    785777  const size_t id = toSize_t(line.substr(6,5));
    786778  for (size_t index = 11; index <= 26; index+=5) {
     
    793785        ListOfNeighbors.push_back(otherid);
    794786      else
    795         ELOG(2, "FormatParser< pdb >::readNeighbors() - discarding conect entry with id 0.");
     787        ELOG(2, "PdbParser::readNeighbors() - discarding conect entry with id 0.");
    796788    } else  {
    797789      break;
     
    821813 * \return input string with modified atom IDs
    822814 */
    823 //string  FormatParser< pdb >::adaptIdDependentDataString(string data) {
     815//string PdbParser::adaptIdDependentDataString(string data) {
    824816//  // there might be no IDs
    825817//  if (data == "-") {
     
    844836
    845837
    846 bool FormatParser< pdb >::operator==(const FormatParser< pdb >& b) const
     838bool PdbParser::operator==(const PdbParser& b) const
    847839{
    848840  bool status = true;
Note: See TracChangeset for help on using the changeset viewer.