From e0dc294e4d6891a89c5081c61a9cd3d96e15b454 Mon Sep 17 00:00:00 2001 From: Roberto Rossini <71787608+robomics@users.noreply.github.com> Date: Mon, 9 Oct 2023 18:38:49 +0200 Subject: [PATCH] Workaround inf weights --- src/hictk/convert/cool_to_hic.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hictk/convert/cool_to_hic.cpp b/src/hictk/convert/cool_to_hic.cpp index 8c53fe45..468890dc 100644 --- a/src/hictk/convert/cool_to_hic.cpp +++ b/src/hictk/convert/cool_to_hic.cpp @@ -257,8 +257,8 @@ static bool dump_weights(std::uint32_t resolution, std::string_view cooler_uri, const auto num_bins = (chrom.size() + resolution - 1) / resolution; const auto i1 = i0 + static_cast(num_bins); std::for_each(weight_vector.begin() + i0, weight_vector.begin() + i1, [&](double w) { - std::isnan(w) ? fmt::print(f.get(), FMT_COMPILE(".\n")) - : fmt::print(f.get(), FMT_COMPILE("{}\n"), w); + !std::isfinite(w) ? fmt::print(f.get(), FMT_COMPILE(".\n")) + : fmt::print(f.get(), FMT_COMPILE("{}\n"), w); if (!bool(f)) { // NOLINT throw fmt::system_error( errno, FMT_STRING("an error occurred while writing weights to file {}"), weight_file); @@ -288,7 +288,8 @@ static bool dump_weights(const ConvertConfig& c, const std::filesystem::path& we void cool_to_hic(const ConvertConfig& c) { std::ignore = find_java(); - const internal::TmpDir tmpdir{c.tmp_dir / c.path_to_output.filename()}; + const internal::TmpDir tmpdir{ + c.tmp_dir / std::filesystem::path(c.path_to_input.filename()).replace_extension(".tmp")}; const auto chrom_sizes = tmpdir() / "reference.chrom.sizes"; const auto pixels = [&]() {