Commit 7ffda74e by Maarten L. Hekkelman

pdb2cif, avoid duplicate key violation on REMARK 350

parent 560f6deb
......@@ -44,6 +44,15 @@ namespace cif
{
// --------------------------------------------------------------------
// special exception
class duplicate_key_error : public std::runtime_error
{
public:
duplicate_key_error(const std::string &msg)
: std::runtime_error(msg) {}
};
// --------------------------------------------------------------------
class category
{
......
......@@ -416,7 +416,7 @@ category_index::entry *category_index::insert(entry *h, row *v)
os << col << ": " << std::quoted(rh[col].text()) << "; ";
}
throw std::runtime_error("Duplicate Key violation, cat: " + m_category.name() + " values: " + os.str());
throw duplicate_key_error("Duplicate Key violation, cat: " + m_category.name() + " values: " + os.str());
}
if (is_red(h->m_right) and not is_red(h->m_left))
......
......@@ -3248,9 +3248,18 @@ void PDBFileParser::ParseRemark350()
values.clear();
}
std::string type = mat == std::vector<double>{ 1, 0, 0, 0, 1, 0, 0, 0, 1 } and vec == std::vector<double>{ 0, 0, 0 } ? "identity operation" : "crystal symmetry operation";
// if (type == "identity operation")
// {
// }
// else
try
{
getCategory("pdbx_struct_oper_list")->emplace({
{ "id", operID },
{ "type", mat == std::vector<double>{ 1, 0, 0, 0, 1, 0, 0, 0, 1 } and vec == std::vector<double>{ 0, 0, 0 } ? "identity operation" : "crystal symmetry operation" },
{ "type", type },
// { "name", "" },
// { "symmetryOperation", "" },
{ "matrix[1][1]", format("%12.10f", mat[0]).str() },
......@@ -3265,6 +3274,11 @@ void PDBFileParser::ParseRemark350()
{ "matrix[3][2]", format("%12.10f", mat[7]).str() },
{ "matrix[3][3]", format("%12.10f", mat[8]).str() },
{ "vector[3]", format("%12.10f", vec[2]).str() } });
}
catch (duplicate_key_error &ex)
{
// so what?
}
mat.clear();
vec.clear();
......
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