Changeset 5fa2ba for src


Ignore:
Timestamp:
Oct 6, 2011, 3:06:17 PM (13 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:
e638f9
Parents:
029bb4
git-author:
Frederik Heber <heber@…> (08/29/11 09:53:53)
git-committer:
Frederik Heber <heber@…> (10/06/11 15:06:17)
Message:

Enhanced PdbParser to read ill-formed pdbs.

  • conect entries may now contain 0 as filler (and serial 0 presence is checked).
  • ATOM info lines may contain less than 80 chars, then name is parsed for element.
  • added new regression test Parser/Pdb/load-various for this.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/PdbParser.cpp

    r029bb4 r5fa2ba  
    475475}
    476476
     477/** read a line starting with key ATOM.
     478 *
     479 * We check for line's length and parse only up to this value.
     480 *
     481 * @param atomInfo container to put information in
     482 * @param line line containing key ATOM
     483 */
    477484void PdbParser::readPdbAtomInfoContainer(PdbAtomInfoContainer &atomInfo, std::string &line) const
    478485{
    479   LOG(4,"INFO: Parsing token from "+line.substr(0,6)+".");
    480   atomInfo.set(PdbKey::token, line.substr(0,6));
    481   LOG(4,"INFO: Parsing serial from "+line.substr(6,5)+".");
    482   atomInfo.set(PdbKey::serial, line.substr(6,5));
    483 
    484   LOG(4,"INFO: Parsing name from "+line.substr(12,4)+".");
    485   atomInfo.set(PdbKey::name, line.substr(12,4));
    486   LOG(4,"INFO: Parsing altLoc from "+line.substr(16,1)+".");
    487   atomInfo.set(PdbKey::altLoc, line.substr(16,1));
    488   LOG(4,"INFO: Parsing resName from "+line.substr(17,3)+".");
    489   atomInfo.set(PdbKey::resName, line.substr(17,3));
    490   LOG(4,"INFO: Parsing chainID from "+line.substr(21,1)+".");
    491   atomInfo.set(PdbKey::chainID, line.substr(21,1));
    492   LOG(4,"INFO: Parsing resSeq from "+line.substr(22,4)+".");
    493   atomInfo.set(PdbKey::resSeq, line.substr(22,4));
    494   LOG(4,"INFO: Parsing iCode from "+line.substr(26,1)+".");
    495   atomInfo.set(PdbKey::iCode, line.substr(26,1));
    496 
    497   LOG(4,"INFO: Parsing occupancy from "+line.substr(54,6)+".");
    498   atomInfo.set(PdbKey::occupancy, line.substr(54,6));
    499   LOG(4,"INFO: Parsing tempFactor from "+line.substr(60,6)+".");
    500   atomInfo.set(PdbKey::tempFactor, line.substr(60,6));
    501   LOG(4,"INFO: Parsing charge from "+line.substr(78,2)+".");
    502   atomInfo.set(PdbKey::charge, line.substr(78,2));
    503   LOG(4,"INFO: Parsing element from "+line.substr(76,2)+".");
    504   atomInfo.set(PdbKey::element, line.substr(76,2));
     486  const size_t length = line.length();
     487  if (length < 80)
     488    ELOG(2, "PdbParser::readPdbAtomInfoContainer() - pdb is mal-formed, containing less than 80 chars!");
     489  if (length >= 6) {
     490    LOG(4,"INFO: Parsing token from "+line.substr(0,6)+".");
     491    atomInfo.set(PdbKey::token, line.substr(0,6));
     492  }
     493  if (length >= 11) {
     494    LOG(4,"INFO: Parsing serial from "+line.substr(6,5)+".");
     495    atomInfo.set(PdbKey::serial, line.substr(6,5));
     496    ASSERT(atomInfo.get<int>(PdbKey::serial) != 0,
     497        "PdbParser::readPdbAtomInfoContainer() - serial 0 is invalid (filler id for conect entries).");
     498  }
     499
     500  if (length >= 16) {
     501    LOG(4,"INFO: Parsing name from "+line.substr(12,4)+".");
     502    atomInfo.set(PdbKey::name, line.substr(12,4));
     503  }
     504  if (length >= 17) {
     505    LOG(4,"INFO: Parsing altLoc from "+line.substr(16,1)+".");
     506    atomInfo.set(PdbKey::altLoc, line.substr(16,1));
     507  }
     508  if (length >= 20) {
     509    LOG(4,"INFO: Parsing resName from "+line.substr(17,3)+".");
     510    atomInfo.set(PdbKey::resName, line.substr(17,3));
     511  }
     512  if (length >= 22) {
     513    LOG(4,"INFO: Parsing chainID from "+line.substr(21,1)+".");
     514    atomInfo.set(PdbKey::chainID, line.substr(21,1));
     515  }
     516  if (length >= 26) {
     517    LOG(4,"INFO: Parsing resSeq from "+line.substr(22,4)+".");
     518    atomInfo.set(PdbKey::resSeq, line.substr(22,4));
     519  }
     520  if (length >= 27) {
     521    LOG(4,"INFO: Parsing iCode from "+line.substr(26,1)+".");
     522    atomInfo.set(PdbKey::iCode, line.substr(26,1));
     523  }
     524
     525  if (length >= 60) {
     526    LOG(4,"INFO: Parsing occupancy from "+line.substr(54,6)+".");
     527    atomInfo.set(PdbKey::occupancy, line.substr(54,6));
     528  }
     529  if (length >= 66) {
     530    LOG(4,"INFO: Parsing tempFactor from "+line.substr(60,6)+".");
     531    atomInfo.set(PdbKey::tempFactor, line.substr(60,6));
     532  }
     533  if (length >= 80) {
     534    LOG(4,"INFO: Parsing charge from "+line.substr(78,2)+".");
     535    atomInfo.set(PdbKey::charge, line.substr(78,2));
     536  }
     537  if (length >= 78) {
     538    LOG(4,"INFO: Parsing element from "+line.substr(76,2)+".");
     539    atomInfo.set(PdbKey::element, line.substr(76,2));
     540  } else {
     541    LOG(4,"INFO: Trying to parse alternative element from name "+line.substr(12,4)+".");
     542    atomInfo.set(PdbKey::element, line.substr(12,4));
     543  }
    505544}
    506545
     
    708747      int otherid = -1;
    709748      PdbAtomInfoContainer::ScanKey(otherid, line.substr(index,5));
    710       if (otherid >= 0)
    711         ListOfNeighbors.push_back((size_t)otherid);
     749      if (otherid > 0)
     750        ListOfNeighbors.push_back(otherid);
     751      else
     752        ELOG(2, "PdbParser::readNeighbors() - discarding conect entry with id 0.");
    712753    } else  {
    713754      break;
Note: See TracChangeset for help on using the changeset viewer.