jsh58 / Genrich

Detecting sites of genomic enrichment
MIT License
182 stars 27 forks source link

BAM5: poorly formatted SAM/BAM record #52

Closed GBeattie closed 4 years ago

GBeattie commented 4 years ago

Hey!

I was getting an error when inputing non-name sorted BAM files, so I prepended with a samtools sort -n pipe, followed by a zcat pipe (as requested by Genrich) which resulted in a broken pipe. Also tried getting around this with samtools sort -n -l 0, but that gave the same error.

My current attempt is:

samtools sort -n -l 0 1-aCT-CD8-neg_S12_L001.sorted.bam | zcat > test.bam.zcat
Genrich -t test.bam.zcat -o test.narrowPeak -j -y -r -e chrM -v

Output:

Processing experimental file #0: test.bam.zcat
Error! BAM5: poorly formatted SAM/BAM record

I will add that the command runs to completion with the starting BAM file using the -S flag, although my understanding is that this isn't ideal.

Genrich -t 1-aCT-CD8-neg_S12_L001.sorted.bam -o test.narrowPeak -j -y -r -S -e chrM -v

Is there an alternate approach that would allow for the input to be name sorted, preferably in a single piped command?

jsh58 commented 4 years ago

Thanks for the question. If you want to pipe in a SAM, you should use

samtools sort -n | samtools view -h | Genrich -t -
AhmedArslan commented 2 years ago

Hi, I am facing the same error: samtools sort -n S.sam | samtools view -h - | Genrich -t - -o S.site
[bam_sort_core] merging from 66 files... Error! m54294U_200627_102135/723/0_112904_rep0_sub0: poorly formatted SAM/BAM record