Commit ac497932 by Maarten L. Hekkelman

Fix loading embedded restraint data

parent 9927b506
...@@ -550,12 +550,6 @@ class local_compound_factory_impl : public compound_factory_impl ...@@ -550,12 +550,6 @@ class local_compound_factory_impl : public compound_factory_impl
for (const auto &[id, name, threeLetterCode, group] : for (const auto &[id, name, threeLetterCode, group] :
file["comp_list"]["chem_comp"].rows<std::string, std::string, std::string, std::string>("id", "name", "three_letter_code", "group")) file["comp_list"]["chem_comp"].rows<std::string, std::string, std::string, std::string>("id", "name", "three_letter_code", "group"))
{ {
// if (std::regex_match(group, peptideRx))
// mKnownPeptides.insert(threeLetterCode);
// else if (cif::iequals(group, "DNA") or cif::iequals(group, "RNA"))
// mKnownBases.insert(threeLetterCode);
// Test if this compound is known in CCD
auto &rdb = m_local_file["comp_" + id]; auto &rdb = m_local_file["comp_" + id];
if (rdb.empty()) if (rdb.empty())
{ {
...@@ -563,6 +557,53 @@ class local_compound_factory_impl : public compound_factory_impl ...@@ -563,6 +557,53 @@ class local_compound_factory_impl : public compound_factory_impl
continue; continue;
} }
construct_compound(rdb, id, name, threeLetterCode, group);
}
}
compound *create(const std::string &id) override;
private:
compound *construct_compound(const datablock &db, const std::string &id, const std::string &name, const std::string &three_letter_code, const std::string &group);
cif::file m_local_file;
};
compound *local_compound_factory_impl::create(const std::string &id)
{
compound *result = nullptr;
for (auto &db : m_local_file)
{
if (db.name() == "comp_" + id)
{
auto chem_comp = db.get("chem_comp");
if (not chem_comp)
break;
try
{
const auto &[id, name, threeLetterCode, group] =
chem_comp->front().get<std::string, std::string, std::string, std::string>("id", "name", "three_letter_code", "group");
result = construct_compound(db, id, name, threeLetterCode, group);
}
catch (const std::exception &ex)
{
std::throw_with_nested(std::runtime_error("Error loading compound " + id));
}
break;
}
}
return result;
}
compound *local_compound_factory_impl::construct_compound(const datablock &rdb, const std::string &id,
const std::string &name, const std::string &three_letter_code, const std::string &group)
{
cif::datablock db(id); cif::datablock db(id);
float formula_weight = 0; float formula_weight = 0;
...@@ -644,48 +685,15 @@ class local_compound_factory_impl : public compound_factory_impl ...@@ -644,48 +685,15 @@ class local_compound_factory_impl : public compound_factory_impl
{ "formula", formula }, { "formula", formula },
{ "pdbx_formal_charge", formal_charge }, { "pdbx_formal_charge", formal_charge },
{ "formula_weight", formula_weight }, { "formula_weight", formula_weight },
{ "three_letter_code", threeLetterCode } { "three_letter_code", three_letter_code }
}); });
m_compounds.push_back(new compound(db)); std::shared_lock lock(mMutex);
}
}
// compound *create(const std::string &id) override;
private:
cif::file m_local_file;
};
// compound *local_compound_factory_impl::create(const std::string &id)
// {
// compound *result = nullptr;
// for (auto &db : m_local_file)
// {
// if (db.name() == id)
// {
// cif::datablock db_copy(db);
// try
// {
// result = new compound(db_copy, 1);
// }
// catch (const std::exception &ex)
// {
// std::throw_with_nested(std::runtime_error("Error loading compound " + id));
// }
// std::shared_lock lock(mMutex);
// m_compounds.push_back(result);
// break;
// }
// }
// return result; auto result = new compound(db);
// } m_compounds.push_back(result);
return result;
}
// -------------------------------------------------------------------- // --------------------------------------------------------------------
......
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