Download construction/tests/test_normalisation_helpers.py from HFMI-PROFOUND/BILBY-PRO: direct link, hf CLI and curl.
- Browser
- Download file 1.83 kB
-
https://huggingface.co/datasets/HFMI-PROFOUND/BILBY-PRO/resolve/main/construction/tests/test_normalisation_helpers.py
- Command line
-
hf download hf://datasets/HFMI-PROFOUND/BILBY-PRO/construction/tests/test_normalisation_helpers.py
-
curl -L -o test_normalisation_helpers.py https://huggingface.co/datasets/HFMI-PROFOUND/BILBY-PRO/resolve/main/construction/tests/test_normalisation_helpers.py
1.83 kB
| # Copyright 2026 Emile de Bruyn | |
| # SPDX-License-Identifier: Apache-2.0 | |
| import pytest | |
| from motifbench_prosite.normalisation import ( | |
| _parse_segment, | |
| _format_segment, | |
| remap_segments_with_residue_map, | |
| remap_contig_string, | |
| ) | |
| def test_parse_segment_range(): | |
| chain, start, end = _parse_segment("L24-43") | |
| assert chain == "L" | |
| assert start == 24 | |
| assert end == 43 | |
| def test_parse_segment_single(): | |
| chain, start, end = _parse_segment("A5") | |
| assert chain == "A" | |
| assert start == end == 5 | |
| def test_format_segment_range(): | |
| assert _format_segment("A", 1, 10) == "A1-10" | |
| def test_format_segment_single(): | |
| assert _format_segment("B", 7, 7) == "B7" | |
| def test_remap_segments_with_residue_map_simple(): | |
| residue_map = { | |
| ("L", 24): ("A", 1), | |
| ("L", 25): ("A", 2), | |
| ("L", 26): ("A", 3), | |
| } | |
| out = remap_segments_with_residue_map("L24-26", residue_map) | |
| assert out == "A1-3" | |
| def test_remap_segments_with_residue_map_split_chain_and_range_break(): | |
| residue_map = { | |
| ("L", 24): ("A", 1), | |
| ("L", 25): ("A", 2), | |
| ("L", 27): ("A", 4), | |
| ("H", 10): ("B", 1), | |
| } | |
| out = remap_segments_with_residue_map("L24-27;H10-10", residue_map) | |
| assert set(out.split(";")) == {"A1-2", "A4", "B1"} | |
| def test_remap_segments_drops_unknown(): | |
| residue_map = {("L", 24): ("A", 1)} | |
| out = remap_segments_with_residue_map("L24-25;H10", residue_map) | |
| assert out == "A1" | |
| def test_remap_contig_string_motif_segments(): | |
| segment_map = {"L24-43": "A1-20"} | |
| contig = "0-100;L24-43;10-20" | |
| out = remap_contig_string(contig, segment_map) | |
| assert out == "0-100;A1-20;10-20" | |
| def test_remap_contig_string_leaves_numeric_unchanged(): | |
| out = remap_contig_string("0-100;10-20", {"L24-43": "A1-20"}) | |
| assert out == "0-100;10-20" | |