From 5b32ca15f73dc886b11993f333d649d60f08d38e Mon Sep 17 00:00:00 2001 From: "Maarten L. Hekkelman" Date: Wed, 9 Apr 2025 13:06:45 +0200 Subject: [PATCH] Fix cleanup_empty_categories --- CMakeLists.txt | 2 +- changelog | 3 +++ src/model.cpp | 9 ++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a0046d..aaf2dd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ cmake_minimum_required(VERSION 3.23) # set the project name project( libcifpp - VERSION 8.0.0 + VERSION 8.0.1 LANGUAGES CXX) list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") diff --git a/changelog b/changelog index b9cbab8..a96b893 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,6 @@ +Version 8.0.1 +- Fix cif::mm::structure::cleanup_empty_categories, removed too much + Version 8.0.0 - A dictionary is for a datablock and a file can have datablocks with differing dictionaries. diff --git a/src/model.cpp b/src/model.cpp index 24d6257..49f33ad 100644 --- a/src/model.cpp +++ b/src/model.cpp @@ -2717,9 +2717,12 @@ std::string structure::create_entity_for_branch(branch &branch) void structure::cleanup_empty_categories() { + using namespace literals; auto &atomSite = m_db["atom_site"]; + auto &pdbxPolySeqScheme = m_db["pdbx_poly_seq_scheme"]; + auto &entityPolySeq = m_db["entity_poly_seq"]; // Remove chem_comp's for which there are no atoms at all auto &chem_comp = m_db["chem_comp"]; @@ -2728,8 +2731,12 @@ void structure::cleanup_empty_categories() for (auto chemComp : chem_comp) { std::string compID = chemComp["id"].as(); - if (atomSite.contains("label_comp_id"_key == compID or "auth_comp_id"_key == compID)) + if (atomSite.contains("label_comp_id"_key == compID or "auth_comp_id"_key == compID) or + pdbxPolySeqScheme.contains("mon_id"_key == compID or "auth_mon_id"_key == compID or "pdb_mon_id"_key == compID) or + entityPolySeq.contains("mon_id"_key == compID)) + { continue; + } obsoleteChemComps.push_back(chemComp); }