Skip to content

PROOF OF CONCEPT: samtools/multicommand - #11550

Open
prototaxites wants to merge 20 commits into
nf-core:masterfrom
prototaxites:samtools-pipeline
Open

PROOF OF CONCEPT: samtools/multicommand#11550
prototaxites wants to merge 20 commits into
nf-core:masterfrom
prototaxites:samtools-pipeline

Conversation

@prototaxites

@prototaxites prototaxites commented May 7, 2026

Copy link
Copy Markdown
Contributor

See discussion on the nf-core slack: https://nfcore.slack.com/archives/C043UU89KKQ/p1777986494144269

Here is a working example of a "samtools/multicommand" module that constructs a chain of samtools commands that pipe into each other following a user-specified input describing which tools to use.

Currently the supported commands are only those which write *AM or fasta/fastq - I think that limits the scope helpfully. If you want to run samtools stats, for example, pass the output from this into that dedicated module.

# valid commands:
['view', 'sort', 'markdup', 'fixmate', 'merge', 'cat', 'collate', 'fastq', 'fasta']

The exact order of operations is specified by the pipeline input, which takes a list such as [view, sort, markdup]. This is then interpolated to a script where the output of each command is streamed to the next before being written to disk. The script can handle references being passed, as well as writing indexes, outputting in CRAM format, and conversion to FASTA and FASTQ.

By default, the threads for each tool are set to the total number of available cpus. However, it may be desirable to configure the number of threads used for each step, for example to give more threads to samtools sort than to samtools view. This can be achieved by specifying a number of threads in $argsX with -@, which will override the number of threads for that command. There is no sanity check that the number of threads is less than the total number available when doing this.

PR checklist

Closes #XXX

  • 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
    • For subworkflows:
      • nf-core subworkflows test <SUBWORKFLOW> --profile docker
      • nf-core subworkflows test <SUBWORKFLOW> --profile singularity
      • nf-core subworkflows test <SUBWORKFLOW> --profile conda

Comment thread modules/nf-core/samtools/multicommand/main.nf Outdated
Comment thread modules/nf-core/samtools/multicommand/main.nf Outdated
Comment thread modules/nf-core/samtools/multicommand/main.nf
Comment thread modules/nf-core/samtools/multicommand/main.nf Outdated
Comment thread modules/nf-core/samtools/multicommand/main.nf Outdated
Comment thread modules/nf-core/samtools/multicommand/main.nf Outdated
Comment thread subworkflows/nf-core/bam_markduplicates_samtools_module_replacement/meta.yml Outdated
Comment thread modules/nf-core/samtools/multicommand/main.nf Outdated
Comment thread modules/nf-core/samtools/multicommand/main.nf Outdated
Comment thread modules/nf-core/samtools/multicommand/main.nf Outdated
@prototaxites
prototaxites marked this pull request as ready for review September 4, 2026 12:39
@prototaxites
prototaxites requested a review from muffato September 4, 2026 12:49
Comment thread modules/nf-core/samtools/multicommand/main.nf Outdated
Comment thread modules/nf-core/samtools/multicommand/main.nf Outdated
Comment thread modules/nf-core/samtools/multicommand/main.nf Outdated

@muffato muffato left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good for me !

@prototaxites

Copy link
Copy Markdown
Contributor Author

I will see if anyone else wants to weigh in before I merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants