Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump deps #113

Merged
merged 4 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions cmake/FetchExternalDeps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ endif()

# cmake-format: off
FetchContent_Declare(
coolerpp
URL ${CMAKE_CURRENT_SOURCE_DIR}/external/coolerpp-0b19a5b.tar.xz
URL_HASH SHA512=b8df4b89afba941851573033ddf72a5725faadc3476ff4ac9a1d9abb7070d6a503be4bdf91ace0fa0ec9b87239d801d45f0bc6170b284cc21b99f45dda55e507
hictk
URL ${CMAKE_CURRENT_SOURCE_DIR}/external/hictk-24f75ae.tar.xz
URL_HASH SHA256=452519a7b4e6d64f45d84ac6eacff9fc7ef119fa4aeb10e5d57ca6251710969c
)
# cmake-format: on

set(COOLERPP_ENABLE_TESTING OFF)
set(COOLERPP_BUILD_EXAMPLES OFF)
set(HICTK_ENABLE_TESTING OFF)
set(HICTK_BUILD_EXAMPLES OFF)
set(HICTK_BUILD_BENCHMARKS OFF)
set(HICTK_BUILD_TOOLS OFF)

FetchContent_MakeAvailable(coolerpp)
FetchContent_MakeAvailable(hictk)
33 changes: 15 additions & 18 deletions conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,33 @@
[requires]
abseil/20230125.3#5431a4c609f5fb48bb8d8567e953243f
bitflags/1.5.0#626da9d1913161321841f30caf9b994e
boost/1.81.0#9bd7ae86a881631b6cc76590621e470b
bshoshany-thread-pool/3.3.0#22e99aee6babc19e679754d95dad2de4
boost/1.82.0#902463606663219fc8c6d2102f1b8c6a
bshoshany-thread-pool/3.5.0#3c9fd1e21a688432b7f31b40d2d168ee
bzip2/1.0.8#411fc05e80d47a89045edc1ee6f23c1d
catch2/3.3.2#be6a2f0225146ba4fd8573ee9013e5ae
catch2/3.3.2#99b3464731b1ad237007c24291481c2a
cli11/2.3.2#8ccdf14fb1ad53532d498c16ae580b4b
concurrentqueue/1.0.3#c1cb7d960d8b64073643b45fa63f0bd1
concurrentqueue/1.0.4#1e48e1c712bcfd892087c9c622a51502
cpp-sort/1.14.0#3453aaaf83c1dae4214ca3b5c4c3a5c8
fast_float/4.0.0#90cac63d3ae321f6318b9abf8af9cbb1
fmt/9.1.0#e747928f85b03f48aaf227ff897d9634
hdf5/1.14.0#011206975dc4c5ca80dd612d3a34cab3 # Coolerpp
highfive/2.7.1#a73bc6937c9add30c9d47a7a70a466eb # Coolerpp
fast_float/5.2.0#9bf1a3fac625789f2b571d43efb8013b
fmt/10.0.0#dd5e3eb81b512a1bb34a5aab88a07e82
hdf5/1.14.0#011206975dc4c5ca80dd612d3a34cab3 # hictk
highfive/2.7.1#a73bc6937c9add30c9d47a7a70a466eb # hictk
libarchive/3.6.2#b768ab8c0dcfb9e27b912a7f32fd02c1
libbigwig/0.4.7#97113380bd925b2220b1d1e63c454d91
libbigwig/0.4.7#c029f7693c143b39a52a99e0d43dff05
libcuckoo/0.3.1#7e514d4c23a9aba3d8d80758824e9dc0
libdeflate/1.18#3697b637656a9af04cabcbed50db9a7e # hictk
lz4/1.9.4#bce1f314775b83c195dffc8e177ff368
lzo/2.10#850936b57f92160152bd9385b1770a69
range-v3/0.12.0#abb9932b80d96eaf8fc992debe3870ed
readerwriterqueue/1.0.6#aaa5ff6fac60c2aee591e9e51b063b83
spdlog/1.11.0#d0fdbaa523550b89156084bf42b41c90
spdlog/1.11.0#8b4bd1da26e0ec97698369d6224d93bf
span-lite/0.10.3#1967d71abb32b314387c2ab9c558dd22 # hictk
tomlplusplus/3.3.0#ebb2a36577011fb1959b0de8c1509a6d
tsl-hopscotch-map/2.3.0#497d3f41172cefe2df9ac17692c52734 # Coolerpp
tsl-ordered-map/1.1.0#c8a6d6831f079d7fb012c46b5bcfa767 # Coolerpp
xoshiro-cpp/1.1#94bd663a04c5335309723bfb757ae23c
tsl-hopscotch-map/2.3.0#497d3f41172cefe2df9ac17692c52734 # hictk
tsl-ordered-map/1.1.0#c8a6d6831f079d7fb012c46b5bcfa767 # hictk
xoshiro-cpp/1.1#20f566efb3e2bf6e1b813d4abfc5e62c
xxhash/0.8.1#b60fcc5f9821c988a155935d87562e1d
xz_utils/5.4.2#b6ee8320403def553418874435445982
zlib/1.2.13#e377bee636333ae348d51ca90874e353
zlib-ng/2.0.7#fbf3d453595da4be4245283c4ca065b8
zstd/1.5.5#93372fe14bb7883bd4de82914e0a1841

[generators]
Expand Down Expand Up @@ -91,7 +91,4 @@ libarchive*:with_lzo=True
libarchive*:with_lzma=True
libarchive*:with_zstd=True
libbigwig*:with_curl=False
libbigwig*:with_zlibng=True
xxhash*:utility=False
zlib-ng*:with_optim=True
zlib-ng*:zlib_compat=True
Binary file removed external/coolerpp-0b19a5b.tar.xz
Binary file not shown.
Binary file added external/hictk-24f75ae.tar.xz
Binary file not shown.
2 changes: 1 addition & 1 deletion src/common/const_map_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ constexpr const Value &ConstMap<Key, Value, Size>::at(const Key &key) const {
assert(itr.second);
return *itr.second;
}
throw std::range_error(fmt::format(FMT_STRING("unable to find key \"{}\""), key));
throw std::range_error("unable to find key");
}

template <class Key, class Value, usize Size>
Expand Down
2 changes: 0 additions & 2 deletions src/libmodle/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ target_sources(
${CMAKE_CURRENT_SOURCE_DIR}/simulation_impl.hpp
${CMAKE_CURRENT_SOURCE_DIR}/state_logger.cpp)



target_include_directories(libmodle_cpu PUBLIC include/)

target_link_libraries(
Expand Down
25 changes: 13 additions & 12 deletions src/libmodle/cpu/simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
#include <fmt/compile.h>
#include <spdlog/spdlog.h> // for info, warn

#include <algorithm> // for max, fill, min, copy, clamp
#include <atomic> // for atomic
#include <cassert> // for assert
#include <chrono> // for microseconds
#include <cmath> // for log, round, exp, floor, sqrt
#include <coolerpp/coolerpp.hpp>
#include <cstdlib> // for abs
#include <deque> // for _Deque_iterator<>::_Self
#include <filesystem> // for operator<<, path
#include <algorithm> // for max, fill, min, copy, clamp
#include <atomic> // for atomic
#include <cassert> // for assert
#include <chrono> // for microseconds
#include <cmath> // for log, round, exp, floor, sqrt
#include <cstdlib> // for abs
#include <deque> // for _Deque_iterator<>::_Self
#include <filesystem> // for operator<<, path
#include <hictk/cooler.hpp>
#include <limits> // for numeric_limits
#include <memory> // for shared_ptr, unique_ptr, make...
#include <mutex> // for mutex
Expand Down Expand Up @@ -111,7 +111,7 @@ usize Simulation::size() const { return this->_genome.size(); }

usize Simulation::simulated_size() const { return this->_genome.simulated_size(); }

[[nodiscard]] static coolerpp::File init_cooler_file(
[[nodiscard]] static hictk::cooler::File init_cooler_file(
const std::filesystem::path& path, bool force,
const std::vector<std::shared_ptr<const Chromosome>>& chroms, bp_t bin_size,
std::string_view assembly_name, std::string_view metadata) {
Expand All @@ -136,7 +136,8 @@ usize Simulation::simulated_size() const { return this->_genome.simulated_size()
return bwf;
}

static void write_contact_matrix_to_cooler(coolerpp::File& cf, const GenomicInterval& interval) {
static void write_contact_matrix_to_cooler(hictk::cooler::File& cf,
const GenomicInterval& interval) {
if (!cf) {
return;
}
Expand Down Expand Up @@ -196,7 +197,7 @@ static void write_lef_occupancy_to_bwig(io::bigwig::Writer& bw, const GenomicInt

// GCC8 doesn't compile init_output_file_writers if we use std::pair<> as return type
struct CoolerBigwigPair {
coolerpp::File clr{};
hictk::cooler::File clr{};
io::bigwig::Writer bw{};
};

Expand Down
3 changes: 1 addition & 2 deletions src/libmodle_io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,14 @@ target_link_libraries(
project_options
Modle::cmatrix
Modle::common
Coolerpp::Coolerpp
fmt::fmt)

target_link_system_libraries(
libmodle_io_contact_matrix
INTERFACE
project_warnings
project_options
coolerpp)
hictk::cooler)

set_target_properties(libmodle_io_contact_matrix PROPERTIES OUTPUT_NAME modle_io_contact_matrix)
install(
Expand Down
101 changes: 54 additions & 47 deletions src/libmodle_io/contact_matrix_dense_io_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#include <algorithm>
#include <cassert>
#include <coolerpp/coolerpp.hpp>
#include <filesystem>
#include <hictk/cooler.hpp>
#include <limits>
#include <stdexcept>
#include <string>
Expand All @@ -26,28 +26,29 @@ namespace modle::io {
namespace internal {

template <class PixelT, class N>
inline bool emplace_pixel(const coolerpp::File& f, std::vector<PixelT>& buff, usize chrom_id,
inline bool emplace_pixel(const hictk::cooler::File& f, std::vector<PixelT>& buff, usize chrom_id,
bp_t offset, usize bin1_id, usize bin2_id, N n) {
using T = decltype(std::declval<PixelT>().count);

const auto bin1_start = utils::conditional_static_cast<u32>(offset) +
(utils::conditional_static_cast<u32>(bin1_id) * f.bin_size());
const auto bin2_start = utils::conditional_static_cast<u32>(offset) +
(utils::conditional_static_cast<u32>(bin2_id) * f.bin_size());
buff.emplace_back(PixelT{{f.bins_ptr(), static_cast<u32>(chrom_id), bin1_start, bin2_start},
buff.emplace_back(PixelT{f.bins().at(static_cast<u32>(chrom_id), bin1_start),
f.bins().at(static_cast<u32>(chrom_id), bin2_start),
utils::conditional_static_cast<T>(n)});

return buff.size() == buff.capacity();
}

template <class PixelT>
inline void write_pixels(coolerpp::File& f, std::vector<PixelT>& buff) {
f.append_pixels(buff.begin(), buff.end(), utils::ndebug_not_defined(), buff.size());
inline void write_pixels(hictk::cooler::File& f, std::vector<PixelT>& buff) {
f.append_pixels(buff.begin(), buff.end(), utils::ndebug_not_defined());
buff.clear();
}

template <class N, class PixelT, usize chunk_size>
inline void append_contact_matrix_to_cooler(coolerpp::File& f, usize chrom_id,
inline void append_contact_matrix_to_cooler(hictk::cooler::File& f, usize chrom_id,
const ContactMatrixDense<N>& matrix,
std::vector<PixelT>& buff, bp_t offset) {
assert(f.has_pixel_of_type<i32>() || f.has_pixel_of_type<double>());
Expand All @@ -71,10 +72,11 @@ inline void append_contact_matrix_to_cooler(coolerpp::File& f, usize chrom_id,
} // namespace internal

template <class N, class ChromIt>
inline coolerpp::File init_cooler_file(const std::filesystem::path& path, bool force_overwrite,
ChromIt first_chrom, ChromIt last_chrom, usize bin_size,
std::string_view assembly, std::string_view generated_by,
std::string_view metadata_str) {
inline hictk::cooler::File init_cooler_file(const std::filesystem::path& path, bool force_overwrite,
ChromIt first_chrom, ChromIt last_chrom, usize bin_size,
std::string_view assembly,
std::string_view generated_by,
std::string_view metadata_str) {
const auto num_chroms = static_cast<usize>(std::distance(first_chrom, last_chrom));
std::vector<std::string> chrom_names(num_chroms);
std::vector<u32> chrom_sizes(num_chroms);
Expand All @@ -90,10 +92,10 @@ inline coolerpp::File init_cooler_file(const std::filesystem::path& path, bool f
}

template <class N, class ChromIt>
[[nodiscard]] inline coolerpp::File init_cooler_file(const std::filesystem::path& path,
bool force_overwrite, ChromIt first_chrom,
ChromIt last_chrom,
coolerpp::StandardAttributes attrs) {
[[nodiscard]] inline hictk::cooler::File init_cooler_file(const std::filesystem::path& path,
bool force_overwrite, ChromIt first_chrom,
ChromIt last_chrom,
hictk::cooler::StandardAttributes attrs) {
const auto num_chroms = static_cast<usize>(std::distance(first_chrom, last_chrom));
std::vector<std::string> chrom_names(num_chroms);
std::vector<u32> chrom_sizes(num_chroms);
Expand All @@ -109,14 +111,16 @@ template <class N, class ChromIt>
}

template <class N, class ChromNameIt, class ChromSizeIt>
inline coolerpp::File init_cooler_file(const std::filesystem::path& path, bool force_overwrite,
ChromNameIt first_name, ChromNameIt last_name,
ChromSizeIt first_size, usize bin_size,
std::string_view assembly, std::string_view generated_by,
std::string_view metadata_str) {
inline hictk::cooler::File init_cooler_file(const std::filesystem::path& path, bool force_overwrite,
ChromNameIt first_name, ChromNameIt last_name,
ChromSizeIt first_size, usize bin_size,
std::string_view assembly,
std::string_view generated_by,
std::string_view metadata_str) {
assert(!assembly.empty());
assert(!generated_by.empty());
auto attrs = coolerpp::StandardAttributes::init(utils::conditional_static_cast<u32>(bin_size));
auto attrs =
hictk::cooler::StandardAttributes::init(utils::conditional_static_cast<u32>(bin_size));
attrs.assembly = assembly;
attrs.generated_by = generated_by;
if (!metadata_str.empty()) {
Expand All @@ -128,34 +132,35 @@ inline coolerpp::File init_cooler_file(const std::filesystem::path& path, bool f
}

template <class N, class ChromNameIt, class ChromSizeIt>
inline coolerpp::File init_cooler_file(const std::filesystem::path& path, bool force_overwrite,
ChromNameIt first_name, ChromNameIt last_name,
ChromSizeIt first_size, coolerpp::StandardAttributes attrs) {
return coolerpp::File::create_new_cooler<N>(
path.string(), coolerpp::ChromosomeSet{first_name, last_name, first_size}, attrs.bin_size,
inline hictk::cooler::File init_cooler_file(const std::filesystem::path& path, bool force_overwrite,
ChromNameIt first_name, ChromNameIt last_name,
ChromSizeIt first_size,
hictk::cooler::StandardAttributes attrs) {
return hictk::cooler::File::create_new_cooler<N>(
path.string(), hictk::Reference{first_name, last_name, first_size}, attrs.bin_size,
force_overwrite, std::move(attrs));
}

template <class N>
inline coolerpp::File init_cooler_file(const std::filesystem::path& path, bool force_overwrite,
coolerpp::ChromosomeSet chroms,
coolerpp::StandardAttributes attrs) {
return coolerpp::File::create_new_cooler<N>(path.string(), std::move(chroms), attrs.bin_size,
force_overwrite, std::move(attrs));
inline hictk::cooler::File init_cooler_file(const std::filesystem::path& path, bool force_overwrite,
hictk::Reference chroms,
hictk::cooler::StandardAttributes attrs) {
return hictk::cooler::File::create_new_cooler<N>(path.string(), std::move(chroms), attrs.bin_size,
force_overwrite, std::move(attrs));
}

template <class N, usize chunk_size>
inline void append_contact_matrix_to_cooler(coolerpp::File& f, std::string_view chrom_name,
inline void append_contact_matrix_to_cooler(hictk::cooler::File& f, std::string_view chrom_name,
const ContactMatrixDense<N>& matrix, bp_t offset) {
append_contact_matrix_to_cooler<N, chunk_size>(
f, static_cast<usize>(f.chromosomes().get_id(chrom_name)), matrix, offset);
}

template <class N, usize chunk_size>
inline void append_contact_matrix_to_cooler(coolerpp::File& f, usize chrom_id,
inline void append_contact_matrix_to_cooler(hictk::cooler::File& f, usize chrom_id,
const ContactMatrixDense<N>& matrix, bp_t offset) {
using T = std::conditional_t<std::is_floating_point_v<N>, double, i32>;
using PixelT = coolerpp::Pixel<T>;
using PixelT = hictk::Pixel<T>;
std::vector<PixelT> buff{};

internal::append_contact_matrix_to_cooler<N, PixelT, chunk_size>(f, chrom_id, matrix, buff,
Expand All @@ -166,20 +171,22 @@ template <class N>
inline ContactMatrixDense<N> read_contact_matrix_from_cooler(
const std::filesystem::path& path_to_cooler, std::string_view chrom_name, bp_t start_pos,
bp_t end_pos, bp_t diagonal_width) {
return read_contact_matrix_from_cooler<N>(coolerpp::File::open_read_only(path_to_cooler.string()),
chrom_name, start_pos, end_pos, diagonal_width);
return read_contact_matrix_from_cooler<N>(
hictk::cooler::File::open_read_only(path_to_cooler.string()), chrom_name, start_pos, end_pos,
diagonal_width);
}

template <class N>
inline ContactMatrixDense<N> read_contact_matrix_from_cooler(
const std::filesystem::path& path_to_cooler, usize chrom_id, bp_t start_pos, bp_t end_pos,
bp_t diagonal_width) {
return read_contact_matrix_from_cooler<N>(coolerpp::File::open_read_only(path_to_cooler.string()),
chrom_id, start_pos, end_pos, diagonal_width);
return read_contact_matrix_from_cooler<N>(
hictk::cooler::File::open_read_only(path_to_cooler.string()), chrom_id, start_pos, end_pos,
diagonal_width);
}

template <class N>
inline ContactMatrixDense<N> read_contact_matrix_from_cooler(const coolerpp::File& f,
inline ContactMatrixDense<N> read_contact_matrix_from_cooler(const hictk::cooler::File& f,
std::string_view chrom_name,
bp_t start_pos, bp_t end_pos,
bp_t diagonal_width) {
Expand All @@ -189,20 +196,20 @@ inline ContactMatrixDense<N> read_contact_matrix_from_cooler(const coolerpp::Fil
}

template <class N>
inline ContactMatrixDense<N> read_contact_matrix_from_cooler(const coolerpp::File& f,
inline ContactMatrixDense<N> read_contact_matrix_from_cooler(const hictk::cooler::File& f,
usize chrom_id, bp_t start_pos,
bp_t end_pos, bp_t diagonal_width) {
try {
assert(start_pos < end_pos);
assert(f.bin_size() != 0);
const auto& chrom = f.chromosomes().at(static_cast<u32>(chrom_id));

if (end_pos > chrom.size) {
if (end_pos > chrom.size()) {
if (end_pos != std::numeric_limits<bp_t>::max()) {
throw std::runtime_error(fmt::format(FMT_STRING("Interval {}:{}-{} lies outside of {}"),
chrom.name, start_pos, end_pos, chrom));
chrom.name(), start_pos, end_pos, chrom));
}
end_pos = chrom.size;
end_pos = chrom.size();
}

const auto interval_span = end_pos - start_pos;
Expand All @@ -212,10 +219,10 @@ inline ContactMatrixDense<N> read_contact_matrix_from_cooler(const coolerpp::Fil

ContactMatrixDense<N> m{interval_span, diagonal_width, f.bin_size()};
for (auto&& pixel :
f.fetch<N>(chrom.name, static_cast<u32>(start_pos), static_cast<u32>(end_pos))) {
if (pixel.coords.bin2().start - pixel.coords.bin1().start < diagonal_width) {
const auto i = (pixel.coords.bin1().start - static_cast<u32>(start_pos)) / f.bin_size();
const auto j = (pixel.coords.bin2().start - static_cast<u32>(start_pos)) / f.bin_size();
f.fetch<N>(chrom.name(), static_cast<u32>(start_pos), static_cast<u32>(end_pos))) {
if (pixel.coords.bin2.start() - pixel.coords.bin1.start() < diagonal_width) {
const auto i = (pixel.coords.bin1.start() - static_cast<u32>(start_pos)) / f.bin_size();
const auto j = (pixel.coords.bin2.start() - static_cast<u32>(start_pos)) / f.bin_size();
m.unsafe_set(i, j, pixel.count);
}
}
Expand All @@ -227,7 +234,7 @@ inline ContactMatrixDense<N> read_contact_matrix_from_cooler(const coolerpp::Fil
}
}

inline bool query_returns_no_pixels(const coolerpp::File& f, std::string_view chrom_name,
inline bool query_returns_no_pixels(const hictk::cooler::File& f, std::string_view chrom_name,
bp_t start_pos, bp_t end_pos) {
const auto match =
f.fetch<double>(chrom_name, static_cast<u32>(start_pos), static_cast<u32>(end_pos));
Expand Down
Loading