Skip to content

Commit

Permalink
Fix bcif datablock generation
Browse files Browse the repository at this point in the history
Fixes #371
  • Loading branch information
JarrettSJohnson committed Jun 11, 2024
1 parent 5c0bfd9 commit fc8e47d
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions layer2/CifFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,18 +742,11 @@ bool cif_file::parse_bcif(const char* bytes, std::size_t size)
auto dict = msgobj.as<std::map<std::string, msgpack::object>>();

auto dataBlocksRaw = dict["dataBlocks"].as<std::vector<msgpack::object>>();
pymol::cif_detail::bcif_data* currentFrame{};
auto& dataDict = m_datablocks;
for (const auto& block : dataBlocksRaw) {
auto blockMap = block.as<std::map<std::string, msgpack::object>>();
auto header = blockMap["header"].as<std::string>();
auto categoriesRaw = blockMap["categories"].as<std::vector<msgpack::object>>();
auto& new_block = m_datablocks[header];
new_block.m_data = pymol::cif_detail::bcif_data{};
currentFrame = &std::get<pymol::cif_detail::bcif_data>(new_block.m_data);
pymol::cif_data& categories = dataDict[header];
categories.m_data = pymol::cif_detail::bcif_data{};
auto& categoriesData = std::get<pymol::cif_detail::bcif_data>(categories.m_data);
auto& categoriesData = m_datablocks[header].m_data.emplace<pymol::cif_detail::bcif_data>();
for (const auto& category : categoriesRaw) {
auto categoryMap = category.as<std::map<std::string, msgpack::object>>();
auto categoryName = categoryMap["name"].as<std::string>();
Expand All @@ -769,11 +762,9 @@ bool cif_file::parse_bcif(const char* bytes, std::size_t size)
auto dataRaw = columnMap["data"].as<std::map<std::string, msgpack::object>>();
auto dataData = dataRaw["data"].as<std::vector<unsigned char>>();
auto dataEncoding = dataRaw["encoding"].as<std::vector<std::map<std::string, msgpack::object>>>();
auto vec = parse_bcif_decode(dataData, dataEncoding);
columns[columnName] = std::move(vec);
columns[columnName] = parse_bcif_decode(dataData, dataEncoding);
}
}
dataDict[header] = std::move(categories);
}
return true;
}
Expand Down

0 comments on commit fc8e47d

Please sign in to comment.