This is a test version of Biostars. For the public version, visit https://www.biostars.org.
samtools produces truncated error during merging the bam files

Hi, I am using the merge function of samtools to merge all the available bam files produced after HISAT alignment. Every file has >85% alignment with the reference genome. Please guide me how to fix this truncated file issue.

code for samtools merge

module load samtools/1.16.1

samtools merge -@ 30 updated_all_merged.bam DRR128251.bam DRR128253.bam DRR128254.bam SRR13775188.bam SRR13775193.bam SRR13775195.bam SRR13775200.bam SRR13775202.bam SRR13775203.bam SRR15216397.bam SRR15216398.bam SRR15216399.bam SRR15216400.bam SRR15216401.bam SRR15216403.bam SRR15216404.bam SRR15216405.bam SRR19863825.bam SRR19863829.bam SRR2924904.bam SRR3203780.bam SRR8327215.bam

error description

Samtools 1.6 is now loaded
[E::bgzf_uncompress] Inflate operation failed: invalid code lengths set
[E::bgzf_read] Read block operation failed with error 1 after 0 of 4 bytes
samtools merge: "SRR13775195.bam" is truncated
bam samtools hisat

1 answer

test your bams. Run :

samtools quickcheck DRR128251.bam DRR128253.bam DRR128254.bam SRR13775188.bam SRR13775193.bam SRR13775195.bam SRR13775200.bam SRR13775202.bam SRR13775203.bam SRR15216397.bam SRR15216398.bam SRR15216399.bam SRR15216400.bam SRR15216401.bam SRR15216403.bam SRR15216404.bam SRR15216405.bam SRR19863825.bam SRR19863829.bam SRR2924904.bam SRR3203780.bam SRR8327215.bam

_

biostars wants some text please biostars , fix this daaaaa

i just used this quickcheck and it passed successfully. Later I viewed the file and found that EOF marker is absent . So how do we solve this error of truncation? I have also shared a head of the file view here

[tariqr@login509-02-r samtools_merged]$ samtools view -H updated_all_merged.bam | head -10
[W::bam_hdr_read] EOF marker is absent. The input is probably truncated
@HD VN:1.0  SO:coordinate
@SQ SN:ptg000001l   LN:11144287
@SQ SN:ptg000002l   LN:32439499
@SQ SN:ptg000003l   LN:22018945
@SQ SN:ptg000004l   LN:18101700
@SQ SN:ptg000005l   LN:299701
@SQ SN:ptg000006l   LN:2763245
@SQ SN:ptg000007l   LN:3084246
@SQ SN:ptg000008l   LN:19860715
@SQ SN:ptg000009l   LN:9183002

You have to repeat alignment for this one. No way to fix it other than producing the bam properly from scratch.

Log in to answer this question.