View Single Post
Old 12-21-2011, 04:51 PM   #3
jbrwn
Member
 
Location: Denver, CO

Join Date: Mar 2011
Posts: 37
Default

Quote:
Originally Posted by eilosei View Post
Hi there,

I've aligned my ChIP-seq data with BWA and filtered for uniquely mapped reads with this command:

samtools view file.bam | grep "XT:A:U" > file.unique.bam

Then I tried to convert the file.unique.bam to .bed file with Bedtools but failed. The command I used is:

bamToBed -i file.unique.bam > file.bed

And I got error message like:

BgzfStream ERROR: read block failed - invalid block header
BamHeader ERROR: could not read magic number
BamReader ERROR: Could not load header data for file.unique.bam

Does anyone have this problem before? How can I solve it?

Thanks!
grab header
Code:
samtools view -H .bam > new.sam
stick on the unique reads
Code:
samtools view .bam | grep ... >> new.sam
convert to bam
Code:
samtools view -Sb -o unique.bam new.sam
also check out samtools reheader.
jbrwn is offline   Reply With Quote