Can I make the filename pattern case _insensitive_?

I’m writing a custom_data section and for the fn: section I need to specify the pattern in a case-insensitive way. I could get around this by copying files around, but I’d rather not. Is there a way to control the options on the pattern-matching that is used behind the scenes?

I tried setting chopt -s nocaseglob but that doesn’t seem to help.

Absolutely, see the docs here and here for using custom search patterns with MultiQC modules.

Instead of using fn, use fn_re and define a case-insensitive regular expression.

Thanks for the swift response, but I’m not sure it fully resolves my problem.

My pattern is actually provided to me using !ENV. Specifically I’m given the name of a gene and am looking for files with that gene in a particular location in the filename. The problem is that the gene name is provided by the user and the filename comes from a case-insensitive match with a resource. I could process the <gene_name> and create the pattern “[gG][eE][nN][eE]_[nN][aA][mM][eE]” from it and use that in fn_re but I was hoping for a cleaner solution, something like "oh sure, just add case_sensitive_pattern_match: true under the fn_re element…

I understand form your response that this isn’t possible, but perhaps you’d consider it as a future feature…

Could you please post your current config, plus a handful of example file names - so that I can have a play and experiment a bit? Thanks!

sure. I’ll post the relevant section.

    section_name: !ENV "Clustering UMAP (Gene: ${UMAP_GENE_0})"
    fn: !ENV "*.clust.scaled.${UMAP_GENE_0}*.png"

ignore_images: false

Now I’d like to have enviroment settings UMAP_GENE_0="galc" and the file
sample_name.clust.scaled.GALC_1234.png will contain the image

Ok, I think I finally figured out a way to do it (after trying several approaches!). You can use a regular expression instead of a glob, then pass a case-insensitive modifier within the regex: (?i)

So, for your example above, I think that this should work:

    fn_re: !ENV "(?i).*\\.clust\\.scaled\\.${UMAP_GENE_0}.*\\.png"

Let me know how you get on with that!

That’s great! thanks for teaching me about in-pattern modifers! Exactly what I was looking for.

(for others looking here’s a nice list: Regex Tutorial - Turning Modes On and Off for Only Part of The Regular Expression)

Also, for the record, in order to limit the insensitivity to the gene-name, I used

fn_re: !ENV ".*\\.clust\\.scaled\\.((?i)${UMAP_GENE_0})..*\\.png"   

However, it turns out that in python, this doesn’t actually limit the case-insensitivity as I had hoped. Still, this works!