Truncated bam file after running ReplaceSamHeader(Picard)
Hi guys,
I want to modify the header of a bam file, in order to remove all the un-anchored scaffolds, and following the steps below:
1. get the modified header from the input bam file
samtools view -H input.bam | grep -v scaffold | samtools view -bh - > header.bam
2. Reheading
java -jar /opt/picard-tools-1.110/ReplaceSamHeader.jar I=input.bam HEADER=header.bam O=y.bam
3. Flagstat with samtools
samtools flagstat y.bam
[bam_flagstat_core] Truncated file? Continue anyway.
98 + 0 in total (QC-passed reads + QC-failed reads)
0 + 0 secondary
0 + 0 supplementary
0 + 0 duplicates
98 + 0 mapped (100.00% : N/A)
98 + 0 paired in sequencing
49 + 0 read1
49 + 0 read2
94 + 0 properly paired (95.92% : N/A)
98 + 0 with itself and mate mapped
0 + 0 singletons (0.00% : N/A)
4 + 0 with mate mapped to a different chr
4 + 0 with mate mapped to a different chr (mapQ>=5)
Flagstat of input.bam
416333 + 0 in total (QC-passed reads + QC-failed reads)
0 + 0 secondary
0 + 0 supplementary
0 + 0 duplicates
416333 + 0 mapped (100.00% : N/A)
416333 + 0 paired in sequencing
210024 + 0 read1
206309 + 0 read2
380475 + 0 properly paired (91.39% : N/A)
414402 + 0 with itself and mate mapped
1931 + 0 singletons (0.46% : N/A)
31200 + 0 with mate mapped to a different chr
26679 + 0 with mate mapped to a different chr (mapQ>=5)
Any help will be deeply appreciated!
Thanks
-
Hi kostas alexiou, what is your question? One note - I would recommend updating your GATK version, you are using a very old version of PICARD.
-
Hi Genevieve Brandt. Sorry. I was not very clear in my message. My question was why I am getting a truncated bam file, after running the ReplaceSamHeader tool from picard. As you have suggested, I have run picard with the latest release (v2.23.8) but still getting a truncated bam file. Below is the command that I am using and the flagstat of the output and input files.
java -jar ~/local/software/picard.jar ReplaceSamHeader -I Olea01_genes.bam -HEADER header.bam -O x.bam
$ samtools flagstat x.bam
[bam_flagstat_core] Truncated file? Continue anyway.
155 + 0 in total (QC-passed reads + QC-failed reads)
0 + 0 secondary
0 + 0 supplementary
0 + 0 duplicates
155 + 0 mapped (100.00% : N/A)
155 + 0 paired in sequencing
76 + 0 read1
79 + 0 read2
149 + 0 properly paired (96.13% : N/A)
155 + 0 with itself and mate mapped
0 + 0 singletons (0.00% : N/A)
4 + 0 with mate mapped to a different chr
4 + 0 with mate mapped to a different chr (mapQ>=5)$ samtools flagstat Olea01_genes.bam
484958 + 0 in total (QC-passed reads + QC-failed reads)
0 + 0 secondary
0 + 0 supplementary
0 + 0 duplicates
484958 + 0 mapped (100.00% : N/A)
484958 + 0 paired in sequencing
243866 + 0 read1
241092 + 0 read2
447722 + 0 properly paired (92.32% : N/A)
482402 + 0 with itself and mate mapped
2556 + 0 singletons (0.53% : N/A)
31940 + 0 with mate mapped to a different chr
27693 + 0 with mate mapped to a different chr (mapQ>=5)Thanks!
-
I have managed to solve the problem of the truncated file. After all, the reheading was not working because there were reads whose mate was mapping to a different chromosome/scaffold and that this wasn't present in the new header.
Best
Kostas
-
Hi kostas alexiou, thank you for the update, glad you were able to solve the problem!
Please sign in to leave a comment.
4 comments