Hi,
I have multiple bam files in a folder, for example, there are two pairs (as marked in bold) with each file of pair being R1 and R2:
GC121284_ATCACGTT.220830.R1_trimmed.bam
GC121284_ATCACGTT.220830.R2_trimmed.bam
GC121284_TAGCTTGT.220830.R1_trimmed.bam
GC121284_TAGCTTGT.220830.R2_trimmed.bam
I am trying to write a bash script to identify the paired files (according to their barcode in bold) and merge them using samtools.
I would be grateful if someone could please suggest, how to write the script.
Before investing any effort, please confirm that separate alignment of paired-end data is indeed what you want and need.
These files are aligned files, I only need to merge these files like:
samtools merge -@ 8 -o GC121284_ATCACGTT_trimmed_merged.bam -n GC121284_ATCACGTT.220830.R1_trimmed.bam GC121284_ATCACGTT.220830.R2_trimmed.bam
But without writing the same script for every pair. Rather I am trying to write a script for samtools to identify the paired files (according to their barcode in bold) and merge them as separate file per barcode.