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

Initial implementation of NCHG cartesian-product #43

Merged
merged 18 commits into from
Nov 13, 2024
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
83 changes: 73 additions & 10 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,6 @@ jobs:

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_PREFIX_PATH="$PWD/conan-env" \
-DENABLE_DEVELOPER_MODE=ON \
-DOPT_ENABLE_INTERPROCEDURAL_OPTIMIZATION=OFF \
-DOPT_ENABLE_SANITIZER_ADDRESS=OFF \
-DOPT_ENABLE_SANITIZER_LEAK=OFF \
-DOPT_ENABLE_SANITIZER_POINTER_COMPARE=OFF \
-DOPT_ENABLE_SANITIZER_POINTER_SUBTRACT=OFF \
-DOPT_ENABLE_SANITIZER_UNDEFINED_BEHAVIOR=OFF \
-DOPT_ENABLE_CPPCHECK=OFF \
-DOPT_ENABLE_CLANG_TIDY=OFF \
-DNCHG_ENABLE_TESTING=ON \
-DNCHG_DOWNLOAD_TEST_DATASET=OFF \
-DCMAKE_C_FLAGS="$cov_flags" \
Expand Down Expand Up @@ -379,6 +370,78 @@ jobs:
echo "DATA_DIR=$PWD/test/data/integration_tests" | tee -a "$GITHUB_ENV"
echo "OUT_PREFIX=ENCFF447ERX.1000000" | tee -a "$GITHUB_ENV"

- name: Test NCHG cartesian-product (gw)
run: |
LLVM_PROFILE_FILE="$PWD/nchg.cartesian-product-gw.profraw"

sudo -u devel \
-E env "LLVM_PROFILE_FILE=$LLVM_PROFILE_FILE" \
build/src/nchg/NCHG cartesian-product \
test/data/ENCFF447ERX.1000000.compartments.bed \
> "$OUT_PREFIX.bedpe"

test/scripts/validate_nchg_output.py cartesian-product \
"$OUT_PREFIX.bedpe" \
"$DATA_DIR/cartesian_product/$OUT_PREFIX.gw-domains.bedpe"

rm "$OUT_PREFIX"*

- name: Test NCHG cartesian-product (cis)
run: |
LLVM_PROFILE_FILE="$PWD/nchg.cartesian-product-cis.profraw"

sudo -u devel \
-E env "LLVM_PROFILE_FILE=$LLVM_PROFILE_FILE" \
build/src/nchg/NCHG cartesian-product \
--cis-only \
test/data/ENCFF447ERX.1000000.compartments.bed \
> domains.bedpe

test/scripts/validate_nchg_output.py cartesian-product \
domains.bedpe \
"$DATA_DIR/cartesian_product/$OUT_PREFIX.cis-domains.bedpe"

rm *.bedpe

- name: Test NCHG cartesian-product (trans)
run: |
LLVM_PROFILE_FILE="$PWD/nchg.cartesian-product-trans.profraw"

sudo -u devel \
-E env "LLVM_PROFILE_FILE=$LLVM_PROFILE_FILE" \
build/src/nchg/NCHG cartesian-product \
--trans-only \
test/data/ENCFF447ERX.1000000.compartments.bed \
> domains.bedpe

test/scripts/validate_nchg_output.py cartesian-product \
domains.bedpe \
"$DATA_DIR/cartesian_product/$OUT_PREFIX.trans-domains.bedpe"

rm *.bedpe

- name: Test NCHG cartesian-product (chr1:chr3)
run: |
LLVM_PROFILE_FILE="$PWD/nchg.cartesian-product-chr1-chr3.profraw"

sudo -u devel \
-E env "LLVM_PROFILE_FILE=$LLVM_PROFILE_FILE" \
build/src/nchg/NCHG cartesian-product \
--chrom1 chr1 \
--chrom2 chr3 \
test/data/ENCFF447ERX.1000000.compartments.bed \
> domains.bedpe

grep -E '\bchr1\b.*\bchr3\b' \
"$DATA_DIR/cartesian_product/$OUT_PREFIX.trans-domains.bedpe" \
> expected.bedpe

test/scripts/validate_nchg_output.py cartesian-product \
domains.bedpe \
expected.bedpe

rm *.bedpe

- name: Test NCHG compute (mt)
run: |
LLVM_PROFILE_FILE="$PWD/nchg.compute-mt.%$(nproc)m.profraw"
Expand Down Expand Up @@ -420,7 +483,7 @@ jobs:
test/data/ENCFF447ERX.1000000.cool \
"$OUT_PREFIX" \
--threads "$(nproc)" \
--domains test/data/ENCFF447ERX.1000000.compartments.bed
--domains "$DATA_DIR/cartesian_product/$OUT_PREFIX.gw-domains.bedpe"

test/scripts/validate_nchg_output.py compute \
"$OUT_PREFIX" \
Expand Down
58 changes: 57 additions & 1 deletion .github/workflows/macos-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,62 @@ jobs:
echo "DATA_DIR=$PWD/test/data/integration_tests" | tee -a "$GITHUB_ENV"
echo "OUT_PREFIX=ENCFF447ERX.1000000" | tee -a "$GITHUB_ENV"

- name: Test NCHG cartesian-product (gw)
run: |
bin/NCHG cartesian-product \
test/data/ENCFF447ERX.1000000.compartments.bed \
> "$OUT_PREFIX.bedpe"

test/scripts/validate_nchg_output.py cartesian-product \
"$OUT_PREFIX.bedpe" \
"$DATA_DIR/cartesian_product/$OUT_PREFIX.gw-domains.bedpe"

rm "$OUT_PREFIX"*

- name: Test NCHG cartesian-product (cis)
run: |
bin/NCHG cartesian-product \
--cis-only \
test/data/ENCFF447ERX.1000000.compartments.bed \
> domains.bedpe

test/scripts/validate_nchg_output.py cartesian-product \
domains.bedpe \
"$DATA_DIR/cartesian_product/$OUT_PREFIX.cis-domains.bedpe"

rm *.bedpe

- name: Test NCHG cartesian-product (trans)
run: |
bin/NCHG cartesian-product \
--trans-only \
test/data/ENCFF447ERX.1000000.compartments.bed \
> domains.bedpe

test/scripts/validate_nchg_output.py cartesian-product \
domains.bedpe \
"$DATA_DIR/cartesian_product/$OUT_PREFIX.trans-domains.bedpe"

rm *.bedpe

- name: Test NCHG cartesian-product (chr1:chr3)
run: |
bin/NCHG cartesian-product \
--chrom1 chr1 \
--chrom2 chr3 \
test/data/ENCFF447ERX.1000000.compartments.bed \
> domains.bedpe

grep -E '\bchr1\b.*\bchr3\b' \
"$DATA_DIR/cartesian_product/$OUT_PREFIX.trans-domains.bedpe" \
> expected.bedpe

test/scripts/validate_nchg_output.py cartesian-product \
domains.bedpe \
expected.bedpe

rm *.bedpe

- name: Test NCHG compute (mt)
run: |
bin/NCHG compute \
Expand Down Expand Up @@ -484,7 +540,7 @@ jobs:
test/data/ENCFF447ERX.1000000.cool \
"$OUT_PREFIX" \
--threads "$NPROC" \
--domains test/data/ENCFF447ERX.1000000.compartments.bed
--domains "$DATA_DIR/cartesian_product/$OUT_PREFIX.gw-domains.bedpe"

test/scripts/validate_nchg_output.py compute \
"$OUT_PREFIX" \
Expand Down
62 changes: 61 additions & 1 deletion .github/workflows/ubuntu-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,66 @@ jobs:
echo "DATA_DIR=$PWD/test/data/integration_tests" | tee -a "$GITHUB_ENV"
echo "OUT_PREFIX=ENCFF447ERX.1000000" | tee -a "$GITHUB_ENV"

- name: Test NCHG cartesian-product (gw)
run: |
sudo -u devel \
bin/NCHG cartesian-product \
test/data/ENCFF447ERX.1000000.compartments.bed \
> "$OUT_PREFIX.bedpe"

test/scripts/validate_nchg_output.py cartesian-product \
"$OUT_PREFIX.bedpe" \
"$DATA_DIR/cartesian_product/$OUT_PREFIX.gw-domains.bedpe"

rm "$OUT_PREFIX"*

- name: Test NCHG cartesian-product (cis)
run: |
sudo -u devel \
bin/NCHG cartesian-product \
--cis-only \
test/data/ENCFF447ERX.1000000.compartments.bed \
> domains.bedpe

test/scripts/validate_nchg_output.py cartesian-product \
domains.bedpe \
"$DATA_DIR/cartesian_product/$OUT_PREFIX.cis-domains.bedpe"

rm *.bedpe

- name: Test NCHG cartesian-product (trans)
run: |
sudo -u devel \
bin/NCHG cartesian-product \
--trans-only \
test/data/ENCFF447ERX.1000000.compartments.bed \
> domains.bedpe

test/scripts/validate_nchg_output.py cartesian-product \
domains.bedpe \
"$DATA_DIR/cartesian_product/$OUT_PREFIX.trans-domains.bedpe"

rm *.bedpe

- name: Test NCHG cartesian-product (chr1:chr3)
run: |
sudo -u devel \
bin/NCHG cartesian-product \
--chrom1 chr1 \
--chrom2 chr3 \
test/data/ENCFF447ERX.1000000.compartments.bed \
> domains.bedpe

grep -E '\bchr1\b.*\bchr3\b' \
"$DATA_DIR/cartesian_product/$OUT_PREFIX.trans-domains.bedpe" \
> expected.bedpe

test/scripts/validate_nchg_output.py cartesian-product \
domains.bedpe \
expected.bedpe

rm *.bedpe

- name: Test NCHG compute (mt)
run: |
sudo -u devel \
Expand Down Expand Up @@ -531,7 +591,7 @@ jobs:
test/data/ENCFF447ERX.1000000.cool \
"$OUT_PREFIX" \
--threads "$(nproc)" \
--domains test/data/ENCFF447ERX.1000000.compartments.bed
--domains "$DATA_DIR/cartesian_product/$OUT_PREFIX.gw-domains.bedpe"

test/scripts/validate_nchg_output.py compute \
"$OUT_PREFIX" \
Expand Down
4 changes: 2 additions & 2 deletions cmake/FetchTestDataset.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

# gersemi: off
file(
DOWNLOAD https://zenodo.org/records/14069775/files/nchg_test_data.tar.zst?download=1
EXPECTED_HASH SHA256=097eb7d6228f470000291ad4b83e0d8b7fd916ecfab74749833c01f13e8a882b
DOWNLOAD https://zenodo.org/records/14133677/files/nchg_test_data.tar.zst?download=1
EXPECTED_HASH SHA256=17d89d3d79996eadd5c9e60ed4411a5351abb87af8e0ab214856ea3bc9fab362
"${PROJECT_SOURCE_DIR}/test/data/nchg_test_data.tar.zst"
)
# gersemi: on
Expand Down
40 changes: 40 additions & 0 deletions src/libnchg/include/nchg/hash.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (C) 2024 Roberto Rossini <[email protected]>
//
// SPDX-License-Identifier: GPL-3.0
//
// This library is free software: you can redistribute it and/or
// modify it under the terms of the GNU Public License as published
// by the Free Software Foundation; either version 3 of the License,
// or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Public License along
// with this library. If not, see
// <https://www.gnu.org/licenses/>.

#pragma once

#include <cstddef>
#include <functional>

namespace nchg::internal {
// Adapted from:
// https://www.boost.org/doc/libs/1_37_0/doc/html/hash/reference.html#boost.hash_combine

template <typename T>
[[nodiscard]] inline std::size_t hash_combine(std::size_t seed, const T &v) {
// NOLINTNEXTLINE(*-avoid-magic-numbers)
seed ^= std::hash<T>{}(v) + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
return seed;
}
template <typename T, typename... Args>
[[nodiscard]] inline std::size_t hash_combine(std::size_t seed, const T &v, const Args &...args) {
// NOLINTNEXTLINE(*-avoid-magic-numbers)
seed ^= std::hash<T>{}(v) + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
return hash_combine(seed, args...);
}
} // namespace nchg::internal
1 change: 1 addition & 0 deletions src/nchg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ add_executable(NCHG)
target_sources(
NCHG
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/cartesian_product/cartesian_product.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/common/io.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/compute/compute.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/expected/expected.cpp"
Expand Down
Loading
Loading