diff --git a/modules/io/src/mol/pdb_reader.cc b/modules/io/src/mol/pdb_reader.cc index 1ea2c56b8b23e81c676fdc5ec94fb0e894b2093f..7bafa40a0db2c538dc0d6e883bde35fc90896960 100644 --- a/modules/io/src/mol/pdb_reader.cc +++ b/modules/io/src/mol/pdb_reader.cc @@ -609,15 +609,22 @@ void PDBReader::ParseAndAddAtom(const StringRef& line, int line_num, LOG_DEBUG("adding atom " << aname << " (" << s_ele << ") @" << apos); mol::AtomHandle ah; if (curr_residue_.GetName()!=res_name.str()) { - if (!profile_.fault_tolerant) { + if (!profile_.fault_tolerant && alt_loc==' ') { 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"); + if (alt_loc==' ') { + LOG_WARNING("Residue with number " << res_num << " has more than one name." + "Ignoring atoms for everything but the first"); + } else { + LOG_WARNING("Residue with number " << res_num + << " contains a microheterogeneity. Everything but atoms for " + << "the residue '" << curr_residue_.GetName() + << "' will be ignored"); + } } warned_name_mismatch_=true; return; diff --git a/modules/io/tests/test_io_pdb.cc b/modules/io/tests/test_io_pdb.cc index e890a5b6c7c197e2bf9800ab9b3179cdf4a17ea9..878a645d3b9e8c560f37ca387c4976d493e099c6 100644 --- a/modules/io/tests/test_io_pdb.cc +++ b/modules/io/tests/test_io_pdb.cc @@ -429,7 +429,7 @@ BOOST_AUTO_TEST_CASE(res_name_too_long) } -BOOST_AUTO_TEST_CASE(res_name_mismatch_tolerant) +BOOST_AUTO_TEST_CASE(res_name_mismatch_alt_loc) { String fname("testfiles/pdb/arg-glu-gln.pdb"); IOProfile profile; @@ -442,15 +442,40 @@ BOOST_AUTO_TEST_CASE(res_name_mismatch_tolerant) BOOST_CHECK_EQUAL(ent.GetAtomCount(), 11); } -BOOST_AUTO_TEST_CASE(res_name_mismatch_pedantic) +BOOST_AUTO_TEST_CASE(res_name_mismatch_alt_loc_pedantic) { String fname("testfiles/pdb/arg-glu-gln.pdb"); IOProfile profile; PDBReader reader(fname, profile); mol::EntityHandle ent=mol::CreateEntity(); + BOOST_CHECK_NO_THROW(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/more-than-one-name.pdb"); + IOProfile profile; + PDBReader reader(fname, profile); + mol::EntityHandle ent=mol::CreateEntity(); BOOST_CHECK_THROW(reader.Import(ent), IOException); } +BOOST_AUTO_TEST_CASE(res_name_mismatch_tolerant) +{ + String fname("testfiles/pdb/more-than-one-name.pdb"); + IOProfile profile; + profile.fault_tolerant=true; + PDBReader reader(fname, profile); + mol::EntityHandle ent=mol::CreateEntity(); + BOOST_CHECK_NO_THROW(reader.Import(ent)); + BOOST_CHECK_EQUAL(ent.GetChainCount(), 1); + BOOST_CHECK_EQUAL(ent.GetResidueCount(), 1); + BOOST_CHECK_EQUAL(ent.GetAtomCount(), 4); +} + BOOST_AUTO_TEST_CASE(seqres_import) { SetPrefixPath(getenv("OST_ROOT")); diff --git a/modules/io/tests/testfiles/pdb/more-than-one-name.pdb b/modules/io/tests/testfiles/pdb/more-than-one-name.pdb new file mode 100644 index 0000000000000000000000000000000000000000..905b4c766267c177d5ba2aae567da09736681ac8 --- /dev/null +++ b/modules/io/tests/testfiles/pdb/more-than-one-name.pdb @@ -0,0 +1,9 @@ +ATOM 25 N TRP A 14 6.698 -48.684 24.846 1.00 52.82 N +ATOM 26 CA TRP A 14 6.905 -49.681 23.809 1.00 51.62 C +ATOM 27 C TRP A 14 8.347 -49.671 23.315 1.00 52.83 C +ATOM 28 O TRP A 14 8.982 -50.733 23.187 1.00 52.24 O +ATOM 29 N LYS A 14 8.863 -48.472 23.046 1.00 53.47 N +ATOM 30 CA LYS A 14 10.228 -48.320 22.537 1.00 54.31 C +ATOM 31 C LYS A 14 11.280 -48.867 23.508 1.00 54.74 C +ATOM 32 O LYS A 14 12.215 -49.573 23.109 1.00 52.47 O +END \ No newline at end of file