Hello
I am trying to merge unmapped and mapped bam files. I merged the bam files using the picard tool (https://gatk.broadinstitute.org/hc/en-us/articles/360036883871-MergeBamAlignment-Picard).
I checked the merged bam using ValidateSamFile command (https://gatk.broadinstitute.org/hc/en-us/articles/360036854731-ValidateSamFile-Picard-) and it showed the below errors:
Error Type Count
ERROR:MATES_ARE_SAME_END 5496
ERROR:MISMATCH_FLAG_MATE_NEG_STRAND 5478
ERROR:MISMATCH_MATE_CIGAR_STRING 3238
I tried to fix the errors in the merged bam file by FixMateInformation command (https://gatk.broadinstitute.org/hc/en-us/articles/360036713471-FixMateInformation-Picard) and it showed the following:
INFO 2021-09-14 14:14:12 FixMateInformation Sorting input into queryname order.
INFO 2021-09-14 14:40:23 FixMateInformation Sorting by queryname complete.
INFO 2021-09-14 14:40:23 FixMateInformation Output will be sorted by coordinate
INFO 2021-09-14 14:40:23 FixMateInformation Traversing query name sorted records and fixing up mate pair information.
[Tue Sep 14 14:40:23 CEST 2021] picard.sam.FixMateInformation done. Elapsed time: 26.19 minutes.
Runtime.totalMemory()=1571524608
To get help, see http://broadinstitute.github.io/picard/index.html#GettingHelp
Exception in thread "main" htsjdk.samtools.SAMException: Found two records that are paired, not supplementary, and first of the pair
at htsjdk.samtools.SamPairUtil$SetMateInfoIterator.advance(SamPairUtil.java:424)
at htsjdk.samtools.SamPairUtil$SetMateInfoIterator.next(SamPairUtil.java:470)
at htsjdk.samtools.SamPairUtil$SetMateInfoIterator.next(SamPairUtil.java:359)
at picard.sam.FixMateInformation.doWork(FixMateInformation.java:206)
at picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:208)
at picard.cmdline.PicardCommandLine.instanceMain(PicardCommandLine.java:95)
at picard.cmdline.PicardCommandLine.main(PicardCommandLine.java:105)
From the above error, there seems to be 2 primary reads with the same name but are both marked "first in pair". How to fix this error in the merged bam file?. Please advice.
Thanks