Hi guys,
I have a folder with around 300 .bam
files. Each .bam
file is a lane of a sample and hence 4 lanes make a sample. I would like to merge the .bam files of the four lanes in a single one by _*S*_
where S is followed by a number that represent the number of the sample (e.g. my_experimet_xxx__L001_S1_stimulated_Aligned.bam
).
Suppose I have 75 samples, i.e. ${1...75}
.
Can anyone help me please?
The line I use to merge normally is the following:
samtools merge S1_merged.bam *bam
Thank you in advance
This is not a job posting. The "job" tage should be used for jobs like career jobs. Most posts are about a computational "job" so I think this is implicit. Just use tags related to the type of computational job you want help with.
drkennetz is correct. Plus, the type says "Job Ad", not "job". Please be more mindful in the future, elb.
*bam
will select all files, including your output bam. Maybe use a different glob pattern or the-b
option?Try on few files ( edit seq accordingly):
input format:
output format: my_experimet_xxx___S{1..75}_stimulated_Aligned.bam
input format: my_experimet_xxx__L00{1..4}_S{1..75}_stimulated_Aligned.bam
First check if samtools supports bash string extension on your machine: something like:
samtools merge my_experimet_xxx___S75_stimulated_Aligned.bam my_experimet_xxx__L00{1..4}_S75_stimulated_Aligned.bam