Skip to content

Commit

Permalink
Merge pull request #97 from paulsengroup/bug/hic-fetch
Browse files Browse the repository at this point in the history
Fix bug when fetching trans interactions from .hic files
  • Loading branch information
robomics authored Jan 8, 2024
2 parents 51f0aff + f6dd34c commit 446d174
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/libhictk/hic/include/hictk/hic/impl/index_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,25 +155,26 @@ inline auto Index::generate_block_list(std::size_t bin1, std::size_t bin2, std::
const auto row1 = bin3 / _block_bin_count;
const auto row2 = (bin4 + 1) / _block_bin_count;

std::vector<BlockIndex> buffer{};
phmap::flat_hash_set<BlockIndex> buffer{};
for (auto row = row1; row <= row2; ++row) {
for (auto col = col1; col <= col2; ++col) {
const auto block_id = (row * block_column_count()) + col;
const auto match = _buffer.find(BlockIndex{block_id, 0, 0, _block_column_count});
if (match != _buffer.end()) {
buffer.emplace_back(*match);
buffer.emplace(*match);
}
}
}

std::vector<BlockIndex> flat_buffer(buffer.begin(), buffer.end());
// Sort first by row, then by column
std::sort(buffer.begin(), buffer.end(), [](const BlockIndex &b1, const BlockIndex &b2) {
std::sort(flat_buffer.begin(), flat_buffer.end(), [](const BlockIndex &b1, const BlockIndex &b2) {
if (b1.coords().i1 != b2.coords().i1) {
return b1.coords().i1 < b2.coords().i1;
}
return b1.coords().i2 < b2.coords().i2;
});
return buffer;
return flat_buffer;
}

inline auto Index::generate_block_list_intra_v9plus(std::size_t bin1, std::size_t bin2,
Expand Down
2 changes: 1 addition & 1 deletion test/units/file/file_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace hictk::test::file {
inline const std::filesystem::path datadir{"test/data"}; // NOLINT(cert-err58-cpp)

// NOLINTNEXTLINE(readability-function-cognitive-complexity)
TEST_CASE("File", "[file][short]") {
TEST_CASE("HiC: File", "[file][short]") {
const std::uint32_t resolution = 1'000'000;
const auto path_hic = (datadir / "hic" / "4DNFIZ1ZVXC8.hic8").string();
const auto path_cooler = (datadir / "integration_tests" / "4DNFIZ1ZVXC8.mcool").string();
Expand Down

0 comments on commit 446d174

Please sign in to comment.