Get bai file generated by galaxy in tool xml?

Hello!

I made xml wrappers for some gatk4 tools. They receive and/or generate bam files and also corresponding bai files. So i made separate inputs/outputs via which they can pass that bai files.

But today i tried to download some bam from galaxy web interface (21.05), and it showed me menu in which i can also download bai file, and this bai is not the bai generated by my tools cos it weighs about 1.5 times less. I found it by size, and it was there:

/home/transgen/galaxy/database/objects/_metadata_files/8/9/c/metadata_89ca5b70-7881-4cc1-bc7a-fcc701c18b8b.dat

, whereas the bam file was there:

/home/transgen/galaxy/database/objects/9/4/b/dataset_94bc20e7-2eaf-4345-9b1f-a2e7c0988b5d.dat

Is there a way to use this bai in tool xmls so i could pass only one noodle for each bam file?

Thanks in advance.

The right answer is:

ln -s '$bam.metadata.bam_index' 'input.bam.bai'