Skip to content

Commit be36837

Browse files
authored
Merge pull request #336 from Plant-Food-Research-Open/fix/318
[GH-318] --hic_map_combinations does not allow self-referential combinationsnations anymore
2 parents 1e4d9c8 + bea3a4c commit be36837

3 files changed

Lines changed: 95 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
44
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6-
## v3.1.0dev - [10-Aug-2026]
6+
## v3.1.0dev - [11-Aug-2026]
77

88
### `Added`
99

@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
### `Fixed`
1616

1717
1. Fixed an issue where `--hic_map_combinations` parameter set to "" was not being interpreted as `null` and resulted in no HiC maps being generated [#321](https://github.com/Plant-Food-Research-Open/assemblyqc/issues/321)
18+
2. Fixed an issue where `--hic_map_combinations` parameter was not being validated correctly and allowed self-referential combinations to be specified [#318](https://github.com/Plant-Food-Research-Open/assemblyqc/issues/318)
1819

1920
### `Dependencies`
2021

subworkflows/local/utils_nfcore_assemblyqc_pipeline/main.nf

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def validateInputParameters() {
333333
}
334334
}
335335

336-
def validateInputTags(assemblyTags, hicCombinations) {
336+
def validateInputTags(List<String> assemblyTags, String hicCombinations) {
337337

338338
def tagCounts = [:]
339339
assemblyTags.each { tag ->
@@ -345,11 +345,29 @@ def validateInputTags(assemblyTags, hicCombinations) {
345345
error("Please check input assemblysheet -> Multiple assemblies have the same tags!: ${repeatedTags}")
346346
}
347347

348-
def hicTags = hicCombinations != null ? hicCombinations.tokenize(' ').collect { it.tokenize(':') }.flatten() : []
348+
def hicTags = hicCombinations != null ? hicCombinations.tokenize(' ').collect { combination -> combination.tokenize(':') }.flatten() : []
349349

350-
hicTags.each {
351-
if ( it !in assemblyTags ) {
352-
error("Please check input hic_map_combinations -> $it was not found in the assemblysheet!")
350+
hicTags.each { hicTag ->
351+
if ( hicTag !in assemblyTags ) {
352+
error("Please check input hic_map_combinations -> $hicTag was not found in the assemblysheet!")
353+
}
354+
}
355+
356+
if ( hicCombinations == null || hicCombinations == "" ) {
357+
return true
358+
}
359+
360+
// Make sure that all hic combinations are unique
361+
def hicCombinationsUnique = hicCombinations.tokenize(' ').unique()
362+
if ( hicCombinationsUnique.size() != hicCombinations.tokenize(' ').size() ) {
363+
error("Please check input hic_map_combinations -> Some combinations are repeated!")
364+
}
365+
366+
// Make sure that no hic combination is self-referential
367+
hicCombinationsUnique.each { hicCombination ->
368+
def hicCombinationTags = hicCombination.tokenize(':')
369+
if ( hicCombinationTags.size() != hicCombinationTags.unique().size() ) {
370+
error("Please check input hic_map_combinations -> ${hicCombination} combination is self-referential!")
353371
}
354372
}
355373

tests/hic/hictags.nf.test

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
nextflow_function {
2+
3+
name "checkHiCParam"
4+
script "../../subworkflows/local/utils_nfcore_assemblyqc_pipeline/main.nf"
5+
function "validateInputTags"
6+
7+
test("HY -- HY -- pass") {
8+
when {
9+
function {
10+
"""
11+
input[0] = [ "HY" ]
12+
input[1] = "HY"
13+
"""
14+
}
15+
}
16+
17+
then {
18+
assert function.success
19+
assert function.result
20+
}
21+
}
22+
23+
test("HY1 HY2 -- HY1 HY1:HY2 -- pass") {
24+
when {
25+
function {
26+
"""
27+
input[0] = [ "HY1", "HY2" ]
28+
input[1] = "HY1 HY1:HY2"
29+
"""
30+
}
31+
}
32+
33+
then {
34+
assert function.success
35+
assert function.result
36+
}
37+
}
38+
39+
test("HY -- HY HY -- fail") {
40+
when {
41+
function {
42+
"""
43+
input[0] = [ "HY" ]
44+
input[1] = "HY HY"
45+
"""
46+
}
47+
}
48+
49+
then {
50+
assert ! function.success
51+
assert 'Please check input hic_map_combinations -> Some combinations are repeated!' in function.stdout
52+
}
53+
}
54+
55+
test("HY -- HY:HY -- fail") {
56+
when {
57+
function {
58+
"""
59+
input[0] = [ "HY" ]
60+
input[1] = "HY:HY"
61+
"""
62+
}
63+
}
64+
65+
then {
66+
assert ! function.success
67+
assert 'Please check input hic_map_combinations -> HY:HY combination is self-referential!' in function.stdout
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)