Commit 50693163 by Maarten L. Hekkelman

When converting pdb to cif, calculate distance for LINKR records

parent 143f17fb
...@@ -1195,6 +1195,19 @@ inline Condition Not(Condition&& cond) ...@@ -1195,6 +1195,19 @@ inline Condition Not(Condition&& cond)
return Condition(new detail::NotConditionImpl(std::move(cond))); return Condition(new detail::NotConditionImpl(std::move(cond)));
} }
namespace literals
{
inline Key operator""_key(const char* text, size_t length)
{
return Key(std::string(text, length));
}
inline constexpr Empty Null = Empty();
}
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// iterators // iterators
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "cif++/PDB2CifRemark3.hpp" #include "cif++/PDB2CifRemark3.hpp"
#include "cif++/CifUtils.hpp" #include "cif++/CifUtils.hpp"
#include "cif++/Symmetry.hpp" #include "cif++/Symmetry.hpp"
#include "cif++/Point.hpp"
namespace ba = boost::algorithm; namespace ba = boost::algorithm;
...@@ -5772,6 +5773,50 @@ void PDBFileParser::Parse(std::istream& is, cif::File& result) ...@@ -5772,6 +5773,50 @@ void PDBFileParser::Parse(std::istream& is, cif::File& result)
// continue; // continue;
// } // }
// } // }
using namespace cif::literals;
auto& atom_site = *getCategory("atom_site");
// for (const auto& [asym1, seq1, atom1, asym2, seq2, atom2]: getCategory("struct_conn")
// ->find<std::string,std::string,std::string,std::string,std::string,std::string>(
// "pdbx_dist_value"_key == 0 or "pdbx_dist_value"_key == Null,
// { "ptnr1_label_asym_id", "ptnr1_label_seq_id", "ptnr1_label_atom_id",
// "ptnr2_label_asym_id", "ptnr2_label_seq_id", "ptnr2_label_atom_id" }))
// {
// auto a1 = atom_site.find1("label_asym_id"_key == asym1 and "label_seq_id"_key == seq1 and "label_atom_id"_key == atom1);
// auto a2 = atom_site.find1("label_asym_id"_key == asym2 and "label_seq_id"_key == seq2 and "label_atom_id"_key == atom2);
// const auto& [x1, y1, z1] = a1.get<float,float,float>({"cartn_x", "cartn_y", "cartn_z"});
// const auto& [x2, y2, z2] = a2.get<float,float,float>({"cartn_x", "cartn_y", "cartn_z"});
// float distance = mmcif::Distance(mmcif::Point{x1, y1, z1}, mmcif::Point{x2, y2, z2});
// std::cerr << "Distance for link: " << distance << std::endl;
// }
for (auto r: getCategory("struct_conn")->find("pdbx_dist_value"_key == 0 or "pdbx_dist_value"_key == Null))
{
const auto& [asym1, seq1, atom1, symm1, asym2, seq2, atom2, symm2] = r.get<std::string,std::string,std::string,std::string,std::string,std::string,std::string,std::string>(
{ "ptnr1_label_asym_id", "ptnr1_label_seq_id", "ptnr1_label_atom_id", "ptnr1_symmetry",
"ptnr2_label_asym_id", "ptnr2_label_seq_id", "ptnr2_label_atom_id", "ptnr2_symmetry" });
auto a1 = atom_site.find1("label_asym_id"_key == asym1 and "label_seq_id"_key == seq1 and "label_atom_id"_key == atom1);
auto a2 = atom_site.find1("label_asym_id"_key == asym2 and "label_seq_id"_key == seq2 and "label_atom_id"_key == atom2);
const auto& [x1, y1, z1] = a1.get<float,float,float>({"cartn_x", "cartn_y", "cartn_z"});
const auto& [x2, y2, z2] = a2.get<float,float,float>({"cartn_x", "cartn_y", "cartn_z"});
float distance = 1.0f;
if (symm1 == "1_555" and symm2 == "1_555")
distance = mmcif::Distance(mmcif::Point{x1, y1, z1}, mmcif::Point{x2, y2, z2});
else if (cif::VERBOSE)
std::cerr << "Cannot calculate distance for link since one of the atoms is in another dimension" << std::endl;
r["pdbx_dist_value"] = distance;
}
} }
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