diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index fb62099e..806f6830 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -192,20 +192,22 @@ jobs: run: | test/scripts/hictk_balance.sh build/src/hictk/hictk hic_tools.jar + test/scripts/hictk_convert_hic2cool.sh build/src/hictk/hictk + test/scripts/hictk_convert_cool2hic.sh build/src/hictk/hictk hic_tools.jar + test/scripts/hictk_dump_chroms.sh build/src/hictk/hictk test/scripts/hictk_dump_bins.sh build/src/hictk/hictk test/scripts/hictk_dump_resolutions.sh build/src/hictk/hictk test/scripts/hictk_dump_normalizations.sh build/src/hictk/hictk test/scripts/hictk_dump_cells.sh build/src/hictk/hictk + test/scripts/hictk_fix_mcool.sh build/src/hictk/hictk + test/scripts/hictk_dump_gw.sh build/src/hictk/hictk test/scripts/hictk_dump_cis.sh build/src/hictk/hictk test/scripts/hictk_dump_trans.sh build/src/hictk/hictk test/scripts/hictk_dump_balanced.sh build/src/hictk/hictk - test/scripts/hictk_convert_hic2cool.sh build/src/hictk/hictk - test/scripts/hictk_convert_cool2hic.sh build/src/hictk/hictk hic_tools.jar - test/scripts/hictk_load_coo.sh build/src/hictk/hictk sorted test/scripts/hictk_load_coo.sh build/src/hictk/hictk unsorted test/scripts/hictk_load_bg2.sh build/src/hictk/hictk sorted diff --git a/.github/workflows/macos-ci.yml b/.github/workflows/macos-ci.yml index 5c8a0857..9dcbcc06 100644 --- a/.github/workflows/macos-ci.yml +++ b/.github/workflows/macos-ci.yml @@ -366,6 +366,14 @@ jobs: run: | test/scripts/hictk_balance.sh bin/hictk hic_tools.jar + - name: Test hictk convert (hic2cool) + run: | + test/scripts/hictk_convert_hic2cool.sh bin/hictk + + - name: Test hictk convert (cool2hic) + run: | + test/scripts/hictk_convert_cool2hic.sh bin/hictk hic_tools.jar + - name: Test hictk dump chroms run: | test/scripts/hictk_dump_chroms.sh bin/hictk @@ -402,13 +410,9 @@ jobs: run: | test/scripts/hictk_dump_balanced.sh bin/hictk - - name: Test hictk convert (hic2cool) + - name: Test hictk fix-mcool run: | - test/scripts/hictk_convert_hic2cool.sh bin/hictk - - - name: Test hictk convert (cool2hic) - run: | - test/scripts/hictk_convert_cool2hic.sh bin/hictk hic_tools.jar + test/scripts/hictk_fix_mcool.sh bin/hictk - name: Test hictk load coo sorted run: | diff --git a/.github/workflows/ubuntu-ci.yml b/.github/workflows/ubuntu-ci.yml index 17953490..329d7ecb 100644 --- a/.github/workflows/ubuntu-ci.yml +++ b/.github/workflows/ubuntu-ci.yml @@ -419,6 +419,14 @@ jobs: run: | test/scripts/hictk_balance.sh bin/hictk hic_tools.jar + - name: Test hictk convert (hic2cool) + run: | + test/scripts/hictk_convert_hic2cool.sh bin/hictk + + - name: Test hictk convert (cool2hic) + run: | + test/scripts/hictk_convert_cool2hic.sh bin/hictk hic_tools.jar + - name: Test hictk dump chroms run: | test/scripts/hictk_dump_chroms.sh bin/hictk @@ -455,13 +463,9 @@ jobs: run: | test/scripts/hictk_dump_balanced.sh bin/hictk - - name: Test hictk convert (hic2cool) + - name: Test hictk fix-mcool run: | - test/scripts/hictk_convert_hic2cool.sh bin/hictk - - - name: Test hictk convert (cool2hic) - run: | - test/scripts/hictk_convert_cool2hic.sh bin/hictk hic_tools.jar + test/scripts/hictk_fix_mcool.sh bin/hictk - name: Test hictk load coo sorted run: | diff --git a/cmake/FetchTestDataset.cmake b/cmake/FetchTestDataset.cmake index 856a3b9d..e01c0c39 100644 --- a/cmake/FetchTestDataset.cmake +++ b/cmake/FetchTestDataset.cmake @@ -4,8 +4,8 @@ # cmake-format: off file( - DOWNLOAD https://zenodo.org/record/8386066/files/hictk_test_data.tar.xz?download=1 - EXPECTED_HASH SHA256=77e2b9186d9edb90a8436fc41d6c0632727df3af95acb74e9635d1c0f29f2b8d + DOWNLOAD https://zenodo.org/record/8392109/files/hictk_test_data.tar.xz?download=1 + EXPECTED_HASH SHA256=43d05077082603cf03dc5ce2bfc0f81b2422c7249ee987e09512d2e3a56afff1 "${PROJECT_SOURCE_DIR}/test/data/hictk_test_data.tar.xz") # cmake-format: on diff --git a/test/scripts/hictk_fix_mcool.sh b/test/scripts/hictk_fix_mcool.sh new file mode 100755 index 00000000..06c81aea --- /dev/null +++ b/test/scripts/hictk_fix_mcool.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash + +# Copyright (C) 2023 Roberto Rossini +# +# SPDX-License-Identifier: MIT + +set -e +set -o pipefail +set -u + +echo "#########################" +echo "#### hictk fix-mcool ####" + +# readlink -f is not available on macos... +function readlink_py { + set -eu + python3 -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' "$1" +} + +function check_files_exist { + set -eu + status=0 + for f in "$@"; do + if [ ! -f "$f" ]; then + 2>&1 echo "Unable to find test file \"$f\"" + status=1 + fi + done + + return "$status" +} + +status=0 + +if [ $# -ne 1 ]; then + 2>&1 echo "Usage: $0 path_to_hictk" + status=1 +fi + +hictk_bin="$1" + +data_dir="$(readlink_py "$(dirname "$0")/../data/")" +script_dir="$(readlink_py "$(dirname "$0")")" + +invalid_mcool="$data_dir/cooler/invalid_coolers/corrupted_index.mcool" + +export PATH="$PATH:$script_dir" + +if [ $status -ne 0 ]; then + exit $status +fi + +if ! check_files_exist "$invalid_mcool"; then + exit 1 +fi + +outdir="$(mktemp -d -t hictk-tmp-XXXXXXXXXX)" +trap 'rm -rf -- "$outdir"' EXIT + +"$hictk_bin" fix-mcool "$invalid_mcool" "$outdir/out.mcool" + +if ! "$hictk_bin" validate --validate-index "$outdir/out.mcool"; then + status=1 +fi + +if [ "$status" -eq 0 ]; then + printf '\n### PASS ###\n' +else + cat "$outdir/out.txt" + printf '\n### FAIL ###\n' +fi + +exit "$status" diff --git a/test/scripts/hictk_validate.sh b/test/scripts/hictk_validate.sh index c03cdf5d..da139649 100755 --- a/test/scripts/hictk_validate.sh +++ b/test/scripts/hictk_validate.sh @@ -46,7 +46,7 @@ valid_hic="$data_dir/hic/4DNFIZ1ZVXC8.hic8" valid_cooler="$data_dir/cooler/ENCFF993FGR.2500000.cool" valid_mcool="$data_dir/cooler/multires_cooler_test_file.mcool" valid_scool="$data_dir/cooler/single_cell_cooler_test_file.scool" -invalid_cooler="$data_dir/cooler/invalid_coolers/4DNFI9GMP2J8.1000000.cool" +invalid_cooler="$data_dir/cooler/invalid_coolers/corrupted_index.mcool::/resolutions/10000000" export PATH="$PATH:$script_dir" diff --git a/test/units/cooler/utils_validation_test.cpp b/test/units/cooler/utils_validation_test.cpp index 33b40c40..87ab082a 100644 --- a/test/units/cooler/utils_validation_test.cpp +++ b/test/units/cooler/utils_validation_test.cpp @@ -118,8 +118,14 @@ TEST_CASE("Cooler: index validation", "[cooler][short]") { CHECK(cooler::utils::index_is_valid(path2.string())); } SECTION("broken index") { - const auto path = datadir / "invalid_coolers/4DNFI9GMP2J8.1000000.cool"; - CHECK_FALSE(cooler::utils::index_is_valid(path.string())); + SECTION(".cool") { + const auto path = datadir / "invalid_coolers/corrupted_index.mcool::/resolutions/10000000"; + CHECK_FALSE(cooler::utils::index_is_valid(path.string())); + } + SECTION(".mcool") { + const auto path = datadir / "invalid_coolers/corrupted_index.mcool"; + CHECK_FALSE(cooler::utils::index_is_valid(path.string())); + } } }