Fix cleanup_empty_categories

This commit is contained in:
Maarten L. Hekkelman
2025-04-09 13:06:45 +02:00
parent 92402817d2
commit 5b32ca15f7
3 changed files with 12 additions and 2 deletions

View File

@@ -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")

View File

@@ -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.

View File

@@ -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<std::string>();
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);
}