Commit b3496f4e by Maarten L. Hekkelman

fixes in pdbx validation, compound one letter code

parent e866228a
...@@ -136,9 +136,14 @@ compound::compound(cif::datablock &db) ...@@ -136,9 +136,14 @@ compound::compound(cif::datablock &db)
if (chemComp.size() != 1) if (chemComp.size() != 1)
throw std::runtime_error("Invalid compound file, chem_comp should contain a single row"); throw std::runtime_error("Invalid compound file, chem_comp should contain a single row");
cif::tie(m_id, m_name, m_type, m_formula, m_formula_weight, m_formal_charge, m_one_letter_code, m_parent_id) = std::string one_letter_code;
cif::tie(m_id, m_name, m_type, m_formula, m_formula_weight, m_formal_charge, one_letter_code, m_parent_id) =
chemComp.front().get("id", "name", "type", "formula", "formula_weight", "pdbx_formal_charge", "one_letter_code", "mon_nstd_parent_comp_id"); chemComp.front().get("id", "name", "type", "formula", "formula_weight", "pdbx_formal_charge", "one_letter_code", "mon_nstd_parent_comp_id");
if (one_letter_code.length() == 1)
m_one_letter_code = one_letter_code.front();
// The name should not contain newline characters since that triggers validation errors later on // The name should not contain newline characters since that triggers validation errors later on
cif::replace_all(m_name, "\n", ""); cif::replace_all(m_name, "\n", "");
......
...@@ -188,7 +188,7 @@ bool is_valid_pdbx_file(const file &file, std::string_view dictionary) ...@@ -188,7 +188,7 @@ bool is_valid_pdbx_file(const file &file, std::string_view dictionary)
} }
} }
const auto &[seq, seq_can] = entity_poly.find1<std::optional<std::string>, std::optional<std::string>>("entity_id"_key == entity_id, auto &&[seq, seq_can] = entity_poly.find1<std::optional<std::string>, std::optional<std::string>>("entity_id"_key == entity_id,
"pdbx_seq_one_letter_code", "pdbx_seq_one_letter_code_can"); "pdbx_seq_one_letter_code", "pdbx_seq_one_letter_code_can");
std::string::const_iterator si, sci, se, sce; std::string::const_iterator si, sci, se, sce;
...@@ -245,18 +245,29 @@ bool is_valid_pdbx_file(const file &file, std::string_view dictionary) ...@@ -245,18 +245,29 @@ bool is_valid_pdbx_file(const file &file, std::string_view dictionary)
if (cif::VERBOSE > 0) if (cif::VERBOSE > 0)
std::clog << "Warning: entity_poly has no sequence for entity_id " << entity_id << '\n'; std::clog << "Warning: entity_poly has no sequence for entity_id " << entity_id << '\n';
} }
else if (not seq_match(false, seq->begin(), seq->end())) else
{
seq->erase(std::remove_if(seq->begin(), seq->end(), [](char ch) { return std::isspace(ch); }), seq->end());
if (not seq_match(false, seq->begin(), seq->end()))
throw validation_error("Sequences do not match for entity " + entity_id); throw validation_error("Sequences do not match for entity " + entity_id);
}
if (not seq_can.has_value()) if (not seq_can.has_value())
{ {
if (cif::VERBOSE > 0) if (cif::VERBOSE > 0)
std::clog << "Warning: entity_poly has no sequence for entity_id " << entity_id << '\n'; std::clog << "Warning: entity_poly has no sequence for entity_id " << entity_id << '\n';
} }
else if (not seq_match(true, seq_can->begin(), seq_can->end())) else
{
seq_can->erase(std::remove_if(seq_can->begin(), seq_can->end(), [](char ch) { return std::isspace(ch); }), seq_can->end());
if (not seq_match(true, seq_can->begin(), seq_can->end()))
throw validation_error("Canonical sequences do not match for entity " + entity_id); throw validation_error("Canonical sequences do not match for entity " + entity_id);
} }
}
result = true; result = true;
} }
catch (const std::exception &ex) catch (const std::exception &ex)
......
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