# How to have configure secondaryFiles to recognize two different patterns for the same file

**URL:** https://cwl.discourse.group/t/how-to-have-configure-secondaryfiles-to-recognize-two-different-patterns-for-the-same-file/729
**Category:** CWL Questions
**Created:** [December 13, 2022, 9:51pm UTC](https://cwl.discourse.group/t/how-to-have-configure-secondaryfiles-to-recognize-two-different-patterns-for-the-same-file/729 "2022-12-13T21:51:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![steve](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@steve](https://cwl.discourse.group/u/steve)
#### Post date: [December 13, 2022, 9:51pm UTC](https://cwl.discourse.group/t/how-to-have-configure-secondaryfiles-to-recognize-two-different-patterns-for-the-same-file/729/1 "2022-12-13T21:51:30Z")

</div>

We have a lot of legacy systems that output files in a naming format like this;

```auto
Sample1.bam
Sample1.bai

```

And we have some other systems that have the same files named like this;

```auto
Sample1.bam
Sample1.bam.bai

```

I need to accomodate both naming schemes. I need the CWL input for a .bam file to require _either_ a .bai secondary file _or_ a .bam.bai file. One of the two must be present (but not both).

As per the docs, I had been using this as the input schema for my CWL

[https://www.commonwl.org/v1.2/Workflow.html#WorkflowInputParameter](https://www.commonwl.org/v1.2/Workflow.html#WorkflowInputParameter)

```auto

type: File
      secondaryFiles:
        - .bai
        - ^.bai

```

However I am now realizing that this does not work. It requires that _both_ Sample1.bai and Sample1.bam.bai must exist.

What I really want is this;

```auto
secondaryFiles:
        - ^.bai|.bai

```

However this does not work, instead it looks for a file named something like `Sample1.bai|.bai`.

Is there a way to make this work? It is not possible to “fix” all the .bai files on disk, and being forced to re-index **every**.bam file in **every** workflow just because some .bam’s are misnamed is becoming ridiculous. Thanks.

---

<div class="post-metadata">

### Author: ![mrc](https://yyz2.discourse-cdn.com/free1/user_avatar/cwl.discourse.group/mrc/32/3_2.png) [@mrc](https://cwl.discourse.group/u/mrc)
#### Post date: [December 14, 2022, 12:16pm UTC](https://cwl.discourse.group/t/how-to-have-configure-secondaryfiles-to-recognize-two-different-patterns-for-the-same-file/729/2 "2022-12-14T12:16:11Z")

</div>

Interesting! I guess making both patterns optional isn’t what you want?

Maybe an ExpressionTool that takes two separate inputs (BAM + BAI) and outputs a singe File with a secondaryFile using your preferred form (`.bai` or `^.bai`)

---

<div class="post-metadata">

### Author: ![Ryan\_G](https://yyz2.discourse-cdn.com/free1/user_avatar/cwl.discourse.group/ryan_g/32/534_2.png) [@Ryan\_G](https://cwl.discourse.group/u/Ryan_G)
#### Post date: [May 18, 2024, 8:27pm UTC](https://cwl.discourse.group/t/how-to-have-configure-secondaryfiles-to-recognize-two-different-patterns-for-the-same-file/729/3 "2024-05-18T20:27:29Z")

</div>

> [@steve](#):
>
> ver I am now realizing that this does not work. It requires that _both_ Sample1.bai and Sample1.bam.bai must exist.
> 
> What I really want is this;

^.bai is “replace the extension with .bai”.
