Does samtools view -b -h <input.bam> -L <input.bed> keep the original header?
1
0
Entering edit mode
6.6 years ago
rubic ▴ 270

Simple question

Seems like the command:

samtools view -b -h <input.bam> -L <input.bed>

for subsetting the bam file to keep only those reads intersecting the seqnames and their regions in input.bed is retaining the original header in the output bam file, including those seqnames not present in input.bed.

Is there a samtools flag that can be used to tell samtools to also subset the header to keep only those seqnames in input.bed?

samtools header • 2.0k views
ADD COMMENT
1
Entering edit mode
6.6 years ago
d-cameron ★ 2.9k

Is there a samtools flag that can be used to tell samtools to also subset the header to keep only those seqnames in input.bed?

No. You would need to pipe to samtools reheader to do that.

The BAM file format differs from SAM in that RNAME is stored not as a string but as the zero-based integer offset of the match @SQ header instead of the seqname string. This means that a) BAM files must have @SQ headers, and b) any subsetting of @SQ requires rewriting all BAM records with the new offsets. samtools view does not have this capability.

ADD COMMENT

Login before adding your answer.

Traffic: 2344 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6