Skip to content

Commit

Permalink
Add integration tests for hictk fix-mcool. Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robomics committed Sep 29, 2023
1 parent b6a7175 commit fcd010f
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 20 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/macos-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: |
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/ubuntu-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: |
Expand Down
4 changes: 2 additions & 2 deletions cmake/FetchTestDataset.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
73 changes: 73 additions & 0 deletions test/scripts/hictk_fix_mcool.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env bash

# Copyright (C) 2023 Roberto Rossini <roberros@uio.no>
#
# 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"
2 changes: 1 addition & 1 deletion test/scripts/hictk_validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
10 changes: 8 additions & 2 deletions test/units/cooler/utils_validation_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}
}

Expand Down

0 comments on commit fcd010f

Please sign in to comment.