This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Merging bam files with GATK

Good afternoon, I'm trying to merge two bam files, one mapped and another unmapped, with gatk (MergeBamAlignment) but I keep having this error all the time:

Inappropriate call if not paired read

Does anybody know why? I found this post (https://gatkforums.broadinstitute.org/gatk/discussion/12259/mergebamalignment-problem) where the user have the same type of problem, but changing the alignment solves it but unluckily I can't do that. When I run ValidateSamFile from Picard, I don't have any errors for both bam files.

Any help is appreaciate it! Thanks in advance!

gatk bam merge

is there a java error stackrace associated with this error ?

This is the whole message:

WARNING 2020-05-11 02:35:49 SamAlignmentMerger  Exception merging bam alignment - attempting to sort aligned reads and try again: Inappropriate call if not paired read

And then I get this:

Exception in thread "main" java.lang.IllegalStateException: Inappropriate call if not paired read
    at htsjdk.samtools.SAMRecord.requireReadPaired(SAMRecord.java:893)
    at htsjdk.samtools.SAMRecord.getProperPairFlag(SAMRecord.java:901)
    at picard.sam.AbstractAlignmentMerger.setValuesFromAlignment(AbstractAlignmentMerger.java:839)
    at picard.sam.AbstractAlignmentMerger.transferAlignmentInfoToFragment(AbstractAlignmentMerger.java:666)
    at picard.sam.AbstractAlignmentMerger.transferAlignmentInfoToPairedRead(AbstractAlignmentMerger.java:739)
    at picard.sam.AbstractAlignmentMerger.mergeAlignment(AbstractAlignmentMerger.java:467)
    at picard.sam.SamAlignmentMerger.mergeAlignment(SamAlignmentMerger.java:186)
    at picard.sam.MergeBamAlignment.doWork(MergeBamAlignment.java:358)
    at picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:305)
    at picard.cmdline.PicardCommandLine.instanceMain(PicardCommandLine.java:103)
    at picard.cmdline.PicardCommandLine.main(PicardCommandLine.java:113)

Yes, I sorted the data of both files by queryname using Picard

1 answer

My guess is that you have some sam records with the sam flag PROPER_PAIR WITHOUT the flag PAIRED_READ.

Test my hypothesis with :

samtools view -b -f 2 src/test/resources/S1.bam |  samtools view  -F 1

the output of a valid BAM should be empty

I redid all the pipeline and now it worked! Thanks for your help, I imagine I was quite tired yesterday night and I did some type of mistake

Log in to answer this question.