Skip to content

PROOF OF CONCEPT: samtools/multicommand#11550

Draft
prototaxites wants to merge 6 commits intonf-core:masterfrom
prototaxites:samtools-pipeline
Draft

PROOF OF CONCEPT: samtools/multicommand#11550
prototaxites wants to merge 6 commits intonf-core:masterfrom
prototaxites:samtools-pipeline

Conversation

@prototaxites
Copy link
Copy Markdown
Contributor

@prototaxites prototaxites commented May 7, 2026

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']

Name TBD, and probably pending further discussion about the guidelines, how this fits and what would need to change.

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 on lines +80 to +102
def pipeline_command = pipeline.withIndex().collect { subcommand, idx ->
def argsKey = idx == 0 ? "args" : "args${idx + 1}"
def taskArgs = task.ext[argsKey] ?: ""

def cmd_parts = ["samtools", subcommand]
if (taskArgs) {
cmd_parts << taskArgs
}
if (idx == 0) {
if (input_reference) {
cmd_parts << input_reference
}
cmd_parts << (input instanceof List ? input.join(" ") : input)
}
if (idx == n_commands - 1) {
if (output_reference) {
cmd_parts << output_reference
}
cmd_parts << output_string
}

return cmd_parts.join(" ")
}.join(" |\\\n")
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.

You just pipe the commands directly. Don't you need to add some - or -o - to force stdin/stdout ? I did that in my version https://github.com/nf-core/modules/pull/4571/changes#diff-34320bc32138ad0bc2d6a277f60183a5c4fc988b01314cab05ac6ff6245a9c94R38 , but perhaps that was unnecessary.

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.

AFAIK it's not mandatory in samtools?

Comment thread modules/nf-core/samtools/multicommand/main.nf
Comment thread modules/nf-core/samtools/multicommand/main.nf
Comment thread modules/nf-core/samtools/multicommand/main.nf
Comment thread modules/nf-core/samtools/multicommand/main.nf
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