jsh58 / Genrich

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

Error! Cannot parse BAM file #46

Closed ScientistJake closed 4 years ago

ScientistJake commented 4 years ago

Genrich compiled with no errors or warnings. When I tried to run it on some samples aligned with bwa mem I got the following error:
Error! Cannot parse BAM file
Here's my call to Genrich:
Genrich -t sample.bwa.mem.bam -o sample.bwa.mem.narrowPeak -j -y -r -e -v
And here's the structure of the bamfile:

samtools view sample.bwa.mem.bam | head -n 2
A00410:109:HCWHGDRXX:1:2101:1090:1000   99  ScPm3Vo_531_HRSCAF_2080 32618107    60  102M    =   32618107    102 GTGTTCGAAACAGTACTAAATGTCCCTTTAAGGTGACACGACATATACTCCTGCGAAAATTGCGATAATTAATATCTCAGAAGGTATAGGATTAGTGTTAGG  FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF  NM:i:0  MD:Z:102    MC:Z:102M   AS:i:102    XS:i:92
A00410:109:HCWHGDRXX:1:2101:1090:1000   147 ScPm3Vo_531_HRSCAF_2080 32618107    60  102M    =   32618107    -102    GTGTTCGAAACAGTACTAAATGTCCCATTAAGGTGACACGACATATACTCCTGCGAAAATTGCGATAATTAATATCTCAGAAGGTATAGGATTAGTGTTAGG  FFFFFF:FFFF,,:FFFFFFFFFFFF,FFFFFFFFFFFFFF:FFFFFFFFFFFFFFFFFFF:FFFFFFFFFFF:FFFFFFFF,FFFFFFFFFF,FFFFFFFF  NM:i:1  MD:Z:26T75  MC:Z:102M   AS:i:97 XS:i:87

Am I missing something?

jsh58 commented 4 years ago

Thanks for the question. From the limited information, it is impossible to tell if there is something wrong with the BAM header or the alignment records. You can try piping the BAM file as a SAM to Genrich with samtools view -h <BAM> | Genrich -t - [...]. Also, the arguments -e -v mean that all alignments to chromosome -v are ignored, and Genrich will not be verbose.

ScientistJake commented 4 years ago

Thank you for the quick response. Passing it through samtools works. I'm not sure what the issue was with my bamfile as MACS2 did not have issues.

jsh58 commented 4 years ago

You're welcome. MACS2 definitely does not check the validity of BAM files (and see this).