From 05865c3d9bd2f3eb46dc7de7d69693c3c113eabe Mon Sep 17 00:00:00 2001 From: "Maarten L. Hekkelman" Date: Tue, 28 Jan 2025 15:51:40 +0100 Subject: [PATCH] Fixes for dictionary loading --- changelog | 3 +++ include/cif++/parser.hpp | 12 +++++++++++- src/compound.cpp | 9 ++++----- test/unit-v2-test.cpp | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/changelog b/changelog index 5656b3c..ea02532 100644 --- a/changelog +++ b/changelog @@ -2,6 +2,9 @@ Version 7.0.9 - Using cif::file::load_dictionary it is now possible to load a dictionary along with its extensions in one go. E.g. file.load_dictionary("mmcif_pdbx;dssp-extension") +- Fix in compound factory to avoid errors with lower case + compound id's +- Fix sac_parser's index to be case insensitive Version 7.0.8 - Fix PDB Remark 3 parser diff --git a/include/cif++/parser.hpp b/include/cif++/parser.hpp index 8244f51..594e713 100644 --- a/include/cif++/parser.hpp +++ b/include/cif++/parser.hpp @@ -73,7 +73,17 @@ class sac_parser { public: /** @cond */ - using datablock_index = std::map; + struct iless_op + { + bool operator()(std::string a, std::string b) const + { + to_upper(a); + to_upper(b); + return a < b; + } + }; + + using datablock_index = std::map; virtual ~sac_parser() = default; /** @endcond */ diff --git a/src/compound.cpp b/src/compound.cpp index f9e8c31..529aca9 100644 --- a/src/compound.cpp +++ b/src/compound.cpp @@ -296,8 +296,6 @@ class compound_factory_impl : public std::enable_shared_from_thism_next) { @@ -328,7 +327,7 @@ class compound_factory_impl : public std::enable_shared_from_this m_compounds; - std::set m_missing; + std::vector m_missing; std::shared_ptr m_next; }; diff --git a/test/unit-v2-test.cpp b/test/unit-v2-test.cpp index 8c02c32..a76bf50 100644 --- a/test/unit-v2-test.cpp +++ b/test/unit-v2-test.cpp @@ -3482,7 +3482,7 @@ TEST_CASE("compound_test_1") cif::compound_factory::instance().push_dictionary(gTestDir / "REA_v2.cif"); auto compound = cif::compound_factory::instance().create("REA_v2"); REQUIRE(compound != nullptr); - REQUIRE(compound->id() == "REA_v2"); + REQUIRE(cif::iequals(compound->id(), "REA_v2")); } // --------------------------------------------------------------------