Okay I see, I'll merge only desired results using bcftools concat and remove the intermediate files. Thanks, I'll edit the test_bam.bam inputs.
One of the problems (which is not obvious from here) was the contents of search_file.txt. I had two extra spaces at the end of the file and for some reason, when running the following command:
samtools idxstats test_bam.bam | cut -f 1 | grep -w -f search_file.txt
The output has a * at the end of the list.
Correcting this error and encasing all instances of $1 and $2 in "" seems to have the desired result.
I'm not sure parallel is the right tool here. While it's powerful you should have look at
Makeand the workflow managers likesnakemakeornextflowsee Is it possible to run variant calling software in parallel, are there any Shell and Python/R code examples available? for an example with
makecross-posted: https://stackoverflow.com/questions/71307235