This is a test version of Biostars. For the public version, visit https://www.biostars.org.
secondaryFiles for bam: how to handle .bai or/and ^.bai ?

Bam file could have two different file extensions depending on the tools. Given bam file test.bam,

  • test.bam.bai secondaryFiles = [.bai]
  • test.bai secondaryFiles = [^.bai]

For a flow to work with both kinds of bam inputs, how to set the secondaryFiles?
Since secondaryFiles items must be present, it is not possible to set the secondaryFiles to handle bam input from any bam index convention.

cwl

are you trying to get the files that end with either bam.bai or .bai? if that's the case just grep out those with .bai....

how are your writing your workflow? unix shell?

Since this post is tagged cwl I put my money (not all of it) on cwl.

As a workflow, I would like to get the flow to work with both .bam.bai and .bai index files. To make a more symbolic link from .bai to .bam.bai is a workaround.

2 answers

samtools index test.bam

creates test.bai, then

ln -s test.bai test.bam.bai

One solution is extend the spec of cwl to add an attribute "optional" to secondaryFiles items, like

secondaryFiles:
  - .bai
    optional: true
  - .^bai
    optional: true

This will make secondaryFiles mechanism more flexible.

Log in to answer this question.