nf-core / nf-core/detaxizer

filter.nf: `$(COUNTER-1)` should be `$((COUNTER-1))`

Open Beginner friendly
#99 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Nextflow
Stars
24
Forks
10
PR merge metrics
No merged PRs in 30d

Description

Description of the bug

modules/local/filter.nf (lines 31 and 33) indexes the id-file array with $(COUNTER-1) — command substitution — where $((COUNTER-1)) was meant. Line 30, two lines above, gets it right:

COUNTER=$((COUNTER+1))                          # line 30, arithmetic
seqkit grep -v -f ${array2[$(COUNTER-1)]} ...   # line 31, runs a command named "COUNTER-1"

Every paired-end FILTER task therefore logs COUNTER-1: command not found, and the subscript collapses to ${array2[]}, which bash coerces to 0:

$ array2=(sample.ids.txt); COUNTER=1; echo "[${array2[$(COUNTER-1)]}]"
bash: COUNTER-1: command not found
[sample.ids.txt]

Output is currently correct. MERGE_IDS emits one .ids.txt per sample, so 0 is the only valid index — and applying that single union list to both mates is exactly what keeps R1/R2 synchronised. The problem is that the loop is written as if array2 were parallel to array (one id file per mate). If that ever becomes true, R2 gets filtered with R1's ids and the pairs desynchronise silently, which a downstream assembler cannot detect.

Fix, either:

  • ${array2[$((COUNTER-1))]} on lines 31 and 33, or
  • drop the indexing and use ${ids_to_remove} directly, making the one-file-per-sample invariant explicit.

Found by reading the 1.3.0 source while checking mate synchronisation for a detaxizer → metatdenovo handoff. Unchanged on dev.

System information

Source inspection of 1.3.0 and dev, no pipeline run — the stderr line above is reproducible in bash alone.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in modules/local/filter.nf at lines 30-33 and compare the arithmetic expression on line 30 with the two array subscripts in the paired-end FILTER task. Check how MERGE_IDS produces ids_to_remove, then verify that the selected correction removes the COUNTER-1 shell error and preserves synchronized R1/R2 filtering.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash
Domain
bioinformatics
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.