Commit 96a67b23 by Maarten L. Hekkelman

Fix loading dictionaries

parent f84d83b7
......@@ -25,7 +25,7 @@
cmake_minimum_required(VERSION 3.16)
# set the project name
project(cifpp VERSION 5.0.0 LANGUAGES CXX)
project(cifpp VERSION 5.0.1 LANGUAGES CXX)
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
......
Version 5.0.1
- Fix loading dictionaries
Version 5.0.0
- Total rewrite of cif part
- Removed DSSP code, moved into dssp project itself
......
......@@ -414,7 +414,7 @@ compound_factory_impl::compound_factory_impl(const fs::path &file, std::shared_p
else
{
// A CCD components file, validate it first
cifFile.load_dictionary("mmcif_pdbx");
cifFile.load_dictionary("mmcif_pdbx.dic");
if (not cifFile.is_valid())
throw std::runtime_error("Invalid compound file");
......
......@@ -97,6 +97,9 @@ void file::load_dictionary()
{
std::string name = audit_conform->front().get<std::string>("dict_name");
if (name == "mmcif_pdbx_v50")
name = "mmcif_pdbx.dic"; // we had a bug here in libcifpp...
if (not name.empty())
{
try
......@@ -113,7 +116,7 @@ void file::load_dictionary()
}
if (not m_validator)
load_dictionary("mmcif_ddl");
load_dictionary("mmcif_pdbx.dic"); // TODO: maybe incorrect? Perhaps improve?
}
void file::load_dictionary(std::string_view name)
......
......@@ -6182,7 +6182,7 @@ void ReadPDBFile(std::istream &pdbFile, cif::file &cifFile)
{
PDBFileParser p;
cifFile.load_dictionary("mmcif_pdbx");
cifFile.load_dictionary("mmcif_pdbx.dic");
p.Parse(pdbFile, cifFile);
......
......@@ -411,11 +411,25 @@ const validator &validator_factory::operator[](std::string_view dictionary_name)
return validator;
}
// not found, add it
// not found, try to see if it helps if we tweak the name a little
// too bad clang version 10 did not have a constructor for std::filesystem::path that accepts a std::string_view
std::filesystem::path dictionary(dictionary_name.data(), dictionary_name.data() + dictionary_name.length());
if (dictionary.extension() != ".dic")
{
auto dict_name = dictionary.filename().string() + ".dic";
for (auto &validator : m_validators)
{
if (iequals(validator.name(), dict_name))
return validator;
}
}
// not found, add it
auto data = load_resource(dictionary_name);
if (not data and dictionary.extension().string() != ".dic")
......
......@@ -106,7 +106,7 @@ _atom_site.pdbx_formal_charge
# that's enough to test with
)"_cf;
atoms.load_dictionary("mmcif_pdbx");
atoms.load_dictionary("mmcif_pdbx.dic");
auto &hem_data = atoms["HEM"];
auto &atom_site = hem_data["atom_site"];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment