Skip to content

added new module: hackgap/count#12386

Merged
LeonHornich merged 5 commits into
nf-core:masterfrom
LeonHornich:hackgap
Jul 22, 2026
Merged

added new module: hackgap/count#12386
LeonHornich merged 5 commits into
nf-core:masterfrom
LeonHornich:hackgap

Conversation

@LeonHornich

Copy link
Copy Markdown
Contributor

This PR adds a module supporting Hackgap, a k-mer counter supporting gapped k-mers.

Note: the tool outputs 2 types of files:

  • .hash: hash table resulting from Bucketed Cuckoo. Since this is a probabilistic method, the files content (and with this the nf-test snapshots) are not reproducible between runs. That's why we only check for the files existence during testing.
  • .info: metadata of hashing process.

PR checklist

  • This comment contains a description of changes (with reason).
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added a new tool - have you followed the module conventions in the contribution docs
  • If necessary, include test data in your PR.
  • Remove all TODO statements.
  • Broadcast software version numbers to topic: versions - See version_topics
  • Follow the naming conventions.
  • Follow the parameters requirements.
  • Follow the input/output options guidelines.
  • Add a resource label
  • Use BioConda and BioContainers if possible to fulfil software requirements.
  • Ensure that the test works with either Docker / Singularity. Conda CI tests can be quite flaky:
    • For modules:
      • nf-core modules test <MODULE> --profile docker
      • nf-core modules test <MODULE> --profile singularity
      • nf-core modules test <MODULE> --profile conda

@LeonHornich LeonHornich self-assigned this Jul 20, 2026
Comment thread modules/nf-core/hackgap/count/main.nf Outdated
script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def split_threads = Math.max(1, (task.cpus / 4) as int)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better passing task.cpus only as this may become hidden from the user

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the issue with this?

@piplus2 piplus2 Jul 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this hides the cpu settings from the user. I don't get why one should set task.cpus and then it gets into 1/4th. Passing the right number makes it transparent.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get that they must sum to task.cpus, but 1/4 seems arbitrary. Any reason why that fraction?

@LeonHornich LeonHornich Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No particular reason. I used a similar logic on the last module i added and it wasn't commented on. Therefore I assumed it was good to go. But please if you have a suggestion for a better cpu thread handling let me know, I"ll gladly adapt it :)

@piplus2 piplus2 Jul 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://gitlab.com/rahmannlab/hackgap/-/blob/master/hackgap/hackgap/hackgap_count.py

def check_threads(args):
    adjust = (args.subtables is None) or (args.threads_split is None) or (args.threads_read is None)
    # 1. Define number of subtables
    cpus = os.cpu_count()
    subtables = args.subtables
    if subtables is None:
        subtables = max(min(cpus // 2 - 1, cpus - 3, 19), 1)
        if (subtables % 2) == 0:
            subtables += 1
    if subtables < 1:
        debugprint0(f"- Error: At least one subtable is required, but {subtables=}")
        sys.exit(1)
    if subtables % 2 == 0:
        debugprint0(f"- Error: Number of subtables must be odd, but {subtables=}")
        sys.exit(1)
    # 2. Define threads for reading files
    threads_read = args.threads_read
    if threads_read is None:
        threads_read = int(ceil(subtables / 10))  # who knows?
    # 3. Define threads for
    threads_split = args.threads_split
    if threads_split is None:
        threads_split = 2 * threads_read
    if adjust and (subtables + threads_read + threads_split >= cpus):
        threads_read = 1
        threads_split = 2
    # 4. Return results
    assert threads_read >= 1
    assert threads_split >= 1
    return (subtables, threads_read, threads_split)

from the source code it looks like that threads_split is suggested to be twice threads_read. I'd suggest to follow the same logic. Also please be sure that the sum subtables + threads_read + threads_split is never >= task.cpus, or it drops to 1 and 2 as from the source. Thanks!

Comment thread modules/nf-core/hackgap/count/main.nf Outdated

@piplus2 piplus2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny stuff

Comment thread modules/nf-core/hackgap/count/main.nf

@piplus2 piplus2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once threads are fixed

@LeonHornich
LeonHornich added this pull request to the merge queue Jul 22, 2026
Merged via the queue into nf-core:master with commit 10c8c7a Jul 22, 2026
31 of 44 checks passed
@LeonHornich
LeonHornich deleted the hackgap branch July 22, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants