Commit 25512340 by Maarten L. Hekkelman

Revert "Work around dropped categories _pdbx_item_linked_group_list and _pdbx_item_linked_group"

This reverts commit 71a46cd1.
parent d2d322ba
......@@ -13,5 +13,3 @@ libcif++.la
config.status
config.log
libtool
version-info*.txt
rsrc/lib-version.txt
......@@ -143,6 +143,7 @@ struct ValidateLink
std::vector<std::string> mParentKeys;
std::string mChildCategory;
std::vector<std::string> mChildKeys;
std::string mLinkGroupLabel;
};
// --------------------------------------------------------------------
......
......@@ -1676,8 +1676,6 @@ auto Category::erase(iterator pos) -> iterator
// a std::set of keys from one category is mapped to another.
// If all values in a child are the same as the specified parent ones
// the child is removed as well, recursively of course.
// --------------------------------------------------------------------
// update: the category is gone, so use the stored relations instead
if (mValidator != nullptr)
{
......@@ -1956,7 +1954,7 @@ void Category::validateLinks() const
if (missing)
{
std::cerr << "Links for " << linkValidator->mParentCategory << "->" << linkValidator->mChildCategory << " are incomplete" << std::endl
std::cerr << "Links for " << linkValidator->mLinkGroupLabel << " are incomplete" << std::endl
<< " There are " << missing << " items in " << mName << " that don't have matching parent items in " << parent->mName << std::endl;
}
}
......
......@@ -892,10 +892,11 @@ void DictParser::linkItems()
std::map<std::tuple<std::string,std::string,int>,size_t> linkIndex;
std::vector<std::tuple<std::vector<std::string>,std::vector<std::string>>> linkKeys;
for (auto li: mImpl->mLinkedItems)
for (auto gl: dict["pdbx_item_linked_group_list"])
{
std::string child, parent;
std::tie(child, parent) = li;
int link_group_id;
cif::tie(child, parent, link_group_id) = gl.get("child_name", "parent_name", "link_group_id");
auto civ = mValidator.getValidatorForItem(child);
if (civ == nullptr)
......@@ -905,7 +906,7 @@ void DictParser::linkItems()
if (piv == nullptr)
error("in pdbx_item_linked_group_list, item '" + parent + "' is not specified");
auto key = std::make_tuple(piv->mCategory->mName, civ->mCategory->mName, 0);
auto key = make_tuple(piv->mCategory->mName, civ->mCategory->mName, link_group_id);
if (not linkIndex.count(key))
{
linkIndex[key] = linkKeys.size();
......@@ -917,7 +918,35 @@ void DictParser::linkItems()
std::get<0>(linkKeys.at(ix)).push_back(piv->mTag);
std::get<1>(linkKeys.at(ix)).push_back(civ->mTag);
}
// for (auto li: mImpl->mLinkedItems)
// {
// std::string child, parent;
// std::tie(child, parent) = li;
//
// auto civ = mValidator.getValidatorForItem(child);
// if (civ == nullptr)
// error("in pdbx_item_linked_group_list, item '" + child + "' is not specified");
//
// auto piv = mValidator.getValidatorForItem(parent);
// if (piv == nullptr)
// error("in pdbx_item_linked_group_list, item '" + parent + "' is not specified");
//
// auto key = make_tuple(piv->mCategory->mName, civ->mCategory->mName, piv->mTag);
// if (not linkIndex.count(key))
// {
// linkIndex[key] = linkKeys.size();
// linkKeys.push_back({});
// }
//
// size_t ix = linkIndex.at(key);
// auto& keys = linkKeys.at(ix);
//
// keys.insert(civ->mTag);
// }
auto& linkedGroup = dict["pdbx_item_linked_group"];
// now store the links in the validator
for (auto& kv: linkIndex)
{
......@@ -926,6 +955,13 @@ void DictParser::linkItems()
std::tie(link.mParentKeys, link.mChildKeys) = linkKeys[kv.second];
// look up the label
for (auto r: linkedGroup.find(cif::Key("category_id") == link.mChildCategory and cif::Key("link_group_id") == link.mLinkGroupID))
{
link.mLinkGroupLabel = r["label"].as<std::string>();
break;
}
mValidator.addLinkValidator(std::move(link));
}
......
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