Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
robomics committed Nov 26, 2023
1 parent e2141b7 commit 3474d25
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#include <fmt/format.h>
#include <parallel_hashmap/phmap.h>
#include <parallel_hashmap/btree.h>

#include <algorithm>
#include <cassert>
Expand Down Expand Up @@ -54,7 +54,8 @@ template <typename NameMap>

template <typename It>
inline void rename_chromosomes(std::string_view uri, It first_mapping, It last_mapping) {
return rename_chromosomes(uri, {first_mapping, last_mapping});
return rename_chromosomes(
uri, phmap::btree_map<std::string, std::string>{first_mapping, last_mapping});
}

template <typename NameMap, typename>
Expand Down
6 changes: 4 additions & 2 deletions test/units/cooler/utils_rename_chromosomes_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
#include <filesystem>
#include <map>

#include "hictk/cooler/cooler.hpp"
#include "hictk/cooler/utils.hpp"
Expand All @@ -13,15 +14,16 @@
namespace hictk::cooler::test::cooler_file {

// NOLINTNEXTLINE(readability-function-cognitive-complexity)
TEST_CASE("Cooler: rename chromosomes", "[cooler][short]") {
TEST_CASE("Cooler: utils rename chromosomes", "[cooler][short]") {
const Reference ref2{{0, "1", 10}, {1, "2", 10}};
const Reference ref3{{0, "chr1", 10}, {1, "2", 10}};

const auto path = testdir() / "rename_chromosomes.cool";

const Reference ref{{0, "chr1", 10}, {1, "chr2", 10}};
std::ignore = cooler::File::create(path.string(), ref, 1, true);
cooler::utils::rename_chromosomes(path.string(), {{"chr1", "1"}});
cooler::utils::rename_chromosomes(path.string(),
std::map<std::string, std::string>{{"chr1", "1"}});

{
const auto chroms = cooler::File(path.string()).chromosomes();
Expand Down

0 comments on commit 3474d25

Please sign in to comment.