diff --git a/modules/io/src/mol/mmcif_reader.cc b/modules/io/src/mol/mmcif_reader.cc index 0fba6dc01f416b4406cf9be28f015cc3172fb99a..27a7c9bc8406308409525862a7b1d906417d2c36 100644 --- a/modules/io/src/mol/mmcif_reader.cc +++ b/modules/io/src/mol/mmcif_reader.cc @@ -795,6 +795,10 @@ void MMCifReader::ParseCitation(const std::vector<StringRef>& columns) } } if (indices_[BOOK_TITLE] != -1) { + // this is only set in few PDB entries and RCSB overrides it with + // the journal_abbrev for their citations + // -> as of August 1, 2017, 5 entries known: 5b1j, 5b1k, 5fax, 5fbz, 5ffn + // -> all those have journal_abbrev set if ((columns[indices_[BOOK_TITLE]] != StringRef(".", 1)) && (columns[indices_[BOOK_TITLE]][0]!='?')) { cit.SetPublishedIn(columns[indices_[BOOK_TITLE]].str()); @@ -802,15 +806,19 @@ void MMCifReader::ParseCitation(const std::vector<StringRef>& columns) } if (indices_[JOURNAL_ABBREV] != -1) { if (columns[indices_[JOURNAL_ABBREV]] != StringRef(".", 1)) { - if (cit.GetPublishedIn().length() > 0) { - throw IOException(this->FormatDiagnostic(STAR_DIAG_WARNING, - "citation.book_title already occupies the 'published_in' field of this citation, cannot add " + - columns[indices_[JOURNAL_ABBREV]].str() + - ".", - this->GetCurrentLinenum())); - } else { - cit.SetPublishedIn(columns[indices_[JOURNAL_ABBREV]].str()); + const String journal_abbrev = columns[indices_[JOURNAL_ABBREV]].str(); + const String published_in = cit.GetPublishedIn(); + if (published_in.length() > 0 && published_in != journal_abbrev) { + LOG_WARNING(this->FormatDiagnostic(STAR_DIAG_WARNING, + "The 'published_in' field was " + "already set by citation.book_title " + "'" + published_in + "'! " + "This will be overwritten by " + "citation.journal_abbrev '" + + journal_abbrev + "'.", + this->GetCurrentLinenum())); } + cit.SetPublishedIn(journal_abbrev); } } if (indices_[JOURNAL_VOLUME] != -1) { diff --git a/modules/io/tests/test_mmcif_reader.cc b/modules/io/tests/test_mmcif_reader.cc index fb87382d106a3742a4ca3e0eee908da57cd4f394..2cfac7fcef03a65e57d20a6658ad07f90b339ab6 100644 --- a/modules/io/tests/test_mmcif_reader.cc +++ b/modules/io/tests/test_mmcif_reader.cc @@ -587,28 +587,38 @@ BOOST_AUTO_TEST_CASE(mmcif_citation_tests) tmmcif_h.Add(StringRef("journal_abbrev", 14)); tmmcif_p.OnBeginLoop(tmmcif_h); + // ensure that we use book_title if no journal given (no RCSB use of this) columns.push_back(StringRef("Foo", 3)); columns.push_back(StringRef("1979", 4)); columns.push_back(StringRef("The Guide", 9)); columns.push_back(StringRef(".", 1)); BOOST_CHECK_NO_THROW(tmmcif_p.ParseCitation(columns)); + const MMCifInfoCitation& cit = tmmcif_p.GetInfo().GetCitations().back(); + BOOST_CHECK_EQUAL(cit.GetID(), String("Foo")); + BOOST_CHECK_EQUAL(cit.GetYear(), 1979); + BOOST_CHECK_EQUAL(cit.GetPublishedIn(), String("The Guide")); - BOOST_CHECK(tmmcif_p.GetInfo().GetCitations().back().GetYear() == 1979); - + // ensure that we override book_title if not properly given columns.pop_back(); columns.pop_back(); columns.push_back(StringRef(".", 1)); columns.push_back(StringRef("Hitch", 5)); BOOST_CHECK_NO_THROW(tmmcif_p.ParseCitation(columns)); + BOOST_CHECK_EQUAL(tmmcif_p.GetInfo().GetCitations().back().GetPublishedIn(), + String("Hitch")); + // ensure that we override book_title if journal given + // (def. behavior on RCSB webpage) columns.pop_back(); columns.pop_back(); columns.push_back(StringRef("The Guide", 9)); columns.push_back(StringRef("Hitch", 5)); - BOOST_CHECK_THROW(tmmcif_p.ParseCitation(columns), IOException); + BOOST_CHECK_NO_THROW(tmmcif_p.ParseCitation(columns)); + BOOST_CHECK_EQUAL(tmmcif_p.GetInfo().GetCitations().back().GetPublishedIn(), + String("Hitch")); BOOST_TEST_MESSAGE(" done."); }