Commit 7ffda74e by Maarten L. Hekkelman

pdb2cif, avoid duplicate key violation on REMARK 350

parent 560f6deb
...@@ -44,6 +44,15 @@ namespace cif ...@@ -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 class category
{ {
......
...@@ -416,7 +416,7 @@ category_index::entry *category_index::insert(entry *h, row *v) ...@@ -416,7 +416,7 @@ category_index::entry *category_index::insert(entry *h, row *v)
os << col << ": " << std::quoted(rh[col].text()) << "; "; 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)) if (is_red(h->m_right) and not is_red(h->m_left))
......
...@@ -3248,23 +3248,37 @@ void PDBFileParser::ParseRemark350() ...@@ -3248,23 +3248,37 @@ void PDBFileParser::ParseRemark350()
values.clear(); values.clear();
} }
getCategory("pdbx_struct_oper_list")->emplace({ 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";
{ "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" }, // if (type == "identity operation")
// { "name", "" }, // {
// { "symmetryOperation", "" },
{ "matrix[1][1]", format("%12.10f", mat[0]).str() }, // }
{ "matrix[1][2]", format("%12.10f", mat[1]).str() }, // else
{ "matrix[1][3]", format("%12.10f", mat[2]).str() }, try
{ "vector[1]", format("%12.10f", vec[0]).str() }, {
{ "matrix[2][1]", format("%12.10f", mat[3]).str() }, getCategory("pdbx_struct_oper_list")->emplace({
{ "matrix[2][2]", format("%12.10f", mat[4]).str() }, { "id", operID },
{ "matrix[2][3]", format("%12.10f", mat[5]).str() }, { "type", type },
{ "vector[2]", format("%12.10f", vec[1]).str() }, // { "name", "" },
{ "matrix[3][1]", format("%12.10f", mat[6]).str() }, // { "symmetryOperation", "" },
{ "matrix[3][2]", format("%12.10f", mat[7]).str() }, { "matrix[1][1]", format("%12.10f", mat[0]).str() },
{ "matrix[3][3]", format("%12.10f", mat[8]).str() }, { "matrix[1][2]", format("%12.10f", mat[1]).str() },
{ "vector[3]", format("%12.10f", vec[2]).str() } }); { "matrix[1][3]", format("%12.10f", mat[2]).str() },
{ "vector[1]", format("%12.10f", vec[0]).str() },
{ "matrix[2][1]", format("%12.10f", mat[3]).str() },
{ "matrix[2][2]", format("%12.10f", mat[4]).str() },
{ "matrix[2][3]", format("%12.10f", mat[5]).str() },
{ "vector[2]", format("%12.10f", vec[1]).str() },
{ "matrix[3][1]", format("%12.10f", mat[6]).str() },
{ "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(); mat.clear();
vec.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