Skip to content
Snippets Groups Projects
Commit eae985e2 authored by Marco Biasini's avatar Marco Biasini
Browse files

fixed BZDNG-183

parent 32e1d9fd
Branches
Tags
No related merge requests found
......@@ -82,6 +82,7 @@ PDBReader::PDBReader(const boost::filesystem::path& loc,
void PDBReader::Init(const boost::filesystem::path& loc)
{
warned_name_mismatch_=false;
charmm_style_=profile_.dialect=="CHARMM";
num_model_records_=0;
if (boost::iequals(".gz", boost::filesystem::extension(loc))) {
......@@ -531,6 +532,7 @@ void PDBReader::ParseAndAddAtom(const StringRef& line, int line_num,
if (!curr_residue_.IsValid()) {
LOG_DEBUG("new residue " << res_name << " " << res_num);
curr_residue_=editor.AppendResidue(curr_chain_, res_name.str(), res_num);
warned_name_mismatch_=false;
++residue_count_;
}
assert(curr_residue_.IsValid());
......@@ -538,6 +540,20 @@ void PDBReader::ParseAndAddAtom(const StringRef& line, int line_num,
// finally add atom
LOG_DEBUG("adding atom " << aname << " (" << s_ele << ") @" << apos);
mol::AtomHandle ah;
if (curr_residue_.GetName()!=res_name.str()) {
if (!profile_.fault_tolerant) {
std::stringstream ss;
ss << "error on line " << line_num << ": "
<< "residue with number " << res_num << " has more than one name.";
throw IOException(ss.str());
}
if (!warned_name_mismatch_) {
LOG_INFO("Residue with number " << res_num << " has more than one name."
"Ignoring atoms for everything but the first");
}
warned_name_mismatch_=true;
return;
}
if (alt_loc!=' ') {
// Check if there is already a atom with the same name.
mol::AtomHandle me=curr_residue_.FindAtom(aname);
......
......@@ -93,6 +93,7 @@ private:
bool is_pqr_;
IOProfile profile_;
bool charmm_style_;
bool warned_name_mismatch_;
};
}}
......
......@@ -423,6 +423,30 @@ BOOST_AUTO_TEST_CASE(res_name_too_long)
BOOST_CHECK_THROW(writer.Write(ent), IOException);
}
BOOST_AUTO_TEST_CASE(res_name_mismatch_tolerant)
{
String fname("testfiles/pdb/arg-glu-gln.pdb");
IOProfile profile;
profile.fault_tolerant=true;
PDBReader reader(fname, profile);
mol::EntityHandle ent=mol::CreateEntity();
reader.Import(ent);
BOOST_CHECK_EQUAL(ent.GetChainCount(), 1);
BOOST_CHECK_EQUAL(ent.GetResidueCount(), 1);
BOOST_CHECK_EQUAL(ent.GetAtomCount(), 11);
}
BOOST_AUTO_TEST_CASE(res_name_mismatch_pedantic)
{
String fname("testfiles/pdb/arg-glu-gln.pdb");
IOProfile profile;
PDBReader reader(fname, profile);
mol::EntityHandle ent=mol::CreateEntity();
BOOST_CHECK_THROW(reader.Import(ent), IOException);
}
BOOST_AUTO_TEST_CASE(chain_name_too_long)
{
std::stringstream out;
......
ATOM 134 N AARG A 15 8.286 13.769 40.774 0.50 60.53 N
ATOM 135 CA AARG A 15 8.903 14.440 41.922 0.50 64.64 C
ATOM 136 C AARG A 15 7.867 15.000 42.911 0.50 65.25 C
ATOM 137 O AARG A 15 8.174 15.244 44.080 0.50 60.65 O
ATOM 138 CB AARG A 15 9.857 15.549 41.457 0.50 65.83 C
ATOM 139 CG AARG A 15 10.863 15.121 40.391 0.50 64.71 C
ATOM 140 CD AARG A 15 11.814 16.270 40.051 0.50 69.97 C
ATOM 141 NE AARG A 15 12.505 16.084 38.775 0.50 69.52 N
ATOM 142 CZ AARG A 15 12.236 16.774 37.670 0.50 69.32 C
ATOM 143 NH1AARG A 15 11.291 17.706 37.674 0.50 55.65 N
ATOM 144 NH2AARG A 15 12.919 16.538 36.559 0.50 76.31 N
ATOM 145 N CGLU A 15 8.306 13.754 40.761 0.17 60.57 N
ATOM 146 CA CGLU A 15 8.887 14.450 41.904 0.17 64.60 C
ATOM 147 C CGLU A 15 7.813 14.816 42.928 0.17 64.89 C
ATOM 148 O CGLU A 15 8.037 14.735 44.137 0.17 61.75 O
ATOM 149 CB CGLU A 15 9.635 15.707 41.448 0.17 65.94 C
ATOM 150 CG CGLU A 15 10.877 15.425 40.613 0.17 65.71 C
ATOM 151 CD CGLU A 15 11.545 16.692 40.105 0.17 68.96 C
ATOM 152 OE1CGLU A 15 10.877 17.748 40.063 0.17 67.85 O
ATOM 153 OE2CGLU A 15 12.740 16.631 39.744 0.17 68.13 O
ATOM 154 N BGLN A 15 8.327 13.744 40.756 0.33 60.56 N
ATOM 155 CA BGLN A 15 8.877 14.452 41.907 0.33 64.61 C
ATOM 156 C BGLN A 15 7.769 14.698 42.924 0.33 64.96 C
ATOM 157 O BGLN A 15 7.924 14.416 44.116 0.33 61.27 O
ATOM 158 CB BGLN A 15 9.492 15.793 41.487 0.33 66.08 C
ATOM 159 CG BGLN A 15 10.726 15.695 40.597 0.33 65.69 C
ATOM 160 CD BGLN A 15 11.327 17.061 40.276 0.33 69.35 C
ATOM 161 OE1BGLN A 15 11.616 17.369 39.119 0.33 66.62 O
ATOM 162 NE2BGLN A 15 11.511 17.885 41.303 0.33 67.16 N
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment