I wanted to extract specific lines from multiple
bam (a binary file format) files. I can select the lines from a single
bam file using this command:
samtools view -c TCGA-BH-A0BW-11A.sorted.bam "5:13744354-13744380" 550
I have a directory with 100
bam files like below:
TCGA-AC-A2FB-11A.sorted.bam TCGA-AC-A2FF-11A.sorted.bam TCGA-AC-A2FM-11B.sorted.bam TCGA-AC-A2QH-01A.sorted.bam TCGA-AC-A2QJ-01A.sorted.bam TCGA-BH-A0BW-11A.sorted.bam TCGA-BH-A0BW-01A.sorted.bam TCGA-CH-A0BW-11A.sorted.bam
How do I apply the command to multiple
bam files and save the output in a single file with the first column as the file name without the extension and the second column being the result of the
samtools command on this file?
For example: It should somehow look like this
TCGA-BH-A0BW-11A 550 TCGA-BH-A0BW-01A 220 TCGA-CH-A0BW-11A 100
I am working on a Linux system.