Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bedtools intersect drops bam header line in latest version #803

Closed
jfreimer opened this issue Dec 11, 2019 · 5 comments · Fixed by #804
Closed

Bedtools intersect drops bam header line in latest version #803

jfreimer opened this issue Dec 11, 2019 · 5 comments · Fixed by #804

Comments

@jfreimer
Copy link

I am trying to use bedtools intersect and it drops the sorted status in the bam file header in bedtools 2.29.1, but not in 2.29.0

bedtools intersect -v -abam test1.bam -b test.bed -wa > test2.bam

2.29.0
@HD VN:1.0 SO:coordinate @SQ SN:chr1 LN:248956422 @SQ SN:chr2 LN:242193529 @SQ SN:chr3 LN:198295559

2.29.1
@SQ SN:chr1 LN:248956422 @SQ SN:chr2 LN:242193529 @SQ SN:chr3 LN:198295559 @SQ SN:chr4 LN:190214555

@38
Copy link
Contributor

38 commented Dec 11, 2019

Hi, could you please share the file to repo this?

@dinvlad
Copy link

dinvlad commented Dec 12, 2019

We're experiencing exactly the same issue! In our case, it's

bedtools pairtobed -abam stdin -b hg19.bed < in.bam > out.bam

This command drops any and all @PG and @RG headers from in.bam...

@arq5x
Copy link
Owner

arq5x commented Dec 12, 2019

Hi @38,

The following will reproduce the problem:

wget http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeUwRepliSeq/wgEncodeUwRepliSeqBg02esG1bAlnRep1.bam
samtools sort wgEncodeUwRepliSeqBg02esG1bAlnRep1.bam -o wgEncodeUwRepliSeqBg02esG1bAlnRep1.sorted.bam

Note the sorted file with have the sorted indicator in the first line of the header with samtools view -H wgEncodeUwRepliSeqBg02esG1bAlnRep1.sorted.bam | less

Intersect that sorted file with a bed file, the header will lose the sorted indicator.

cat test.bed
chr1	10000000	20000000

bedtools intersect -a wgEncodeUwRepliSeqBg02esG1bAlnRep1.sorted.bam -b test.bed > wgEncodeUwRepliSeqBg02esG1bAlnRep1.sorted.intersecting.bam

38 added a commit to 38/bedtools2 that referenced this issue Dec 12, 2019
@38
Copy link
Contributor

38 commented Dec 12, 2019

Hi @arq5x , Just add a fix to this issue

arq5x added a commit that referenced this issue Dec 13, 2019
Fix issue #803 and add test cases
@arq5x
Copy link
Owner

arq5x commented Dec 13, 2019

Thanks so much for catching this. Now fixed in master thanks to @38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants