There is a -B
flag in bwa aln
:
Length of barcode starting from the 5’-end. When INT is positive, the barcode of each read will be trimmed before mapping and will be written at the BC SAM tag. For paired-end reads, the barcode from both ends are concatenated. [0]
However, it does not seem to be present in bwa mem
. Is there a way to replicate this behavior in bwa mem
? It doesn't actually affect the actual alignment (as far as I can tell), so technically it should be possible for both alignment options.
Also, are there other aligners that support this behavior?
The reason why I mentioned the
-B
flag was because it allowed you to keep the barcode associated with the corresponding read. If you trim prior to alignment, then you lose the barcode which would defeat the entire purpose.I am familiar with demultiplexing and read trimming. My question was about a specific task that is related, but completely different.
"bwa mem" is a local aligner. Thus technically, it can align your reads even with barcodes present. Do you have reads with different barcodes in a single FASTQ file?
Yes. Otherwise, there is no point in having the barcode in the aligned file.
If you would store the stripped reads in different files, you could use read groups to keep track of the barcodes. See this (great) comment from John C: Read Group In Sam/Bam Files: What Do They Exactly Describe?