Commit f69c8c2b by Maarten L. Hekkelman

Avoid writing duplicate sheets

parent c37975ce
...@@ -359,7 +359,7 @@ void writeSheets(cif::datablock &db, const dssp &dssp) ...@@ -359,7 +359,7 @@ void writeSheets(cif::datablock &db, const dssp &dssp)
if (not sheetMap.count(sheetID)) if (not sheetMap.count(sheetID))
sheetMap[sheetID] = static_cast<int>(sheetMap.size()); sheetMap[sheetID] = static_cast<int>(sheetMap.size());
strands.emplace_back(std::make_tuple(sheetMap[sheetID], res_list{ res })); strands.emplace_back(sheetMap[sheetID], res_list{ res });
} }
// sort the strands vector // sort the strands vector
...@@ -379,10 +379,15 @@ void writeSheets(cif::datablock &db, const dssp &dssp) ...@@ -379,10 +379,15 @@ void writeSheets(cif::datablock &db, const dssp &dssp)
int lastSheet = -1; int lastSheet = -1;
for (const auto &[sheetNr, strand] : strands) for (const auto &[sheetNr, strand] : strands)
{ {
if (sheetNr != lastSheet) if (sheetNr == lastSheet)
continue;
auto id = cif::cif_id_for_number(sheetNr);
if (not struct_sheet.exists(cif::key("id") == id))
{ {
struct_sheet.emplace({ struct_sheet.emplace({
{ "id", cif::cif_id_for_number(sheetNr) }, { "id", id },
{ "number_strands", { "number_strands",
std::count_if(strands.begin(), strands.end(), [nr = sheetNr](std::tuple<int, res_list> const &s) std::count_if(strands.begin(), strands.end(), [nr = sheetNr](std::tuple<int, res_list> const &s)
{ return std::get<0>(s) == nr; }) { return std::get<0>(s) == nr; })
......
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