Entering edit mode
3.5 years ago
Frieda
▴
60
I am following the steps recommended by GATK to preprocess my data for human data.
java -jar picard.jar FastqToSam -F1 forward.fq.gz -F2 reverse.fq.gz -O unaligned.bam -SM HG001 -RG HG2YWAFX2.1
java -Xmx8G -jar picard.jar MarkIlluminaAdapters -I unaligned.bam -O markilluminaadapters.bam -M markilluminaadapters_metrics.txt
java -Xmx8G -jar picard.jar SamToFastq -I markilluminaadapters.bam -FASTQ interleaved.fq -CLIPPING_ATTRIBUTE XT -CLIPPING_ACTION 2 -INTERLEAVE true -NON_PF true
bwa index ref.fa
bwa mem -M -t 4 ref.fa interleaved.fq > aligned.sam
java -Xmx16G -jar picard.jar MergeBamAlignment \
-R ref.fa \
-UNMAPPED_BAM unaligned.bam \
-ALIGNED_BAM aligned.sam \
-O mergebamalignment.bam \
-CREATE_INDEX true \
-ADD_MATE_CIGAR true \
-CLIP_ADAPTERS false \
-CLIP_OVERLAPPING_READS true \
-INCLUDE_SECONDARY_ALIGNMENTS true \
-MAX_INSERTIONS_OR_DELETIONS -1 \
-PRIMARY_ALIGNMENT_STRATEGY MostDistant \
-ATTRIBUTES_TO_RETAIN XS
This workflow fails at the MergeBamAlignment step with the following error:
WARNING 2021-06-22 17:48:18 SamAlignmentMerger Exception merging bam alignment - attempting to sort aligned reads and try again: Inappropriate call if not paired read
INFO 2021-06-22 17:48:18 SamAlignmentMerger Finished reading 1348 total records from alignment SAM/BAM.
[Tue Jun 22 17:48:18 CEST 2021] picard.sam.MergeBamAlignment done. Elapsed time: 0.00 minutes.
Runtime.totalMemory()=500695040
To get help, see http://broadinstitute.github.io/picard/index.html#GettingHelp
Exception in thread "main" java.lang.IllegalStateException: Inappropriate call if not paired read
at htsjdk.samtools.SAMRecord.requireReadPaired(SAMRecord.java:899)
at htsjdk.samtools.SAMRecord.getProperPairFlag(SAMRecord.java:907)
at picard.sam.AbstractAlignmentMerger.setValuesFromAlignment(AbstractAlignmentMerger.java:973)
at picard.sam.AbstractAlignmentMerger.transferAlignmentInfoToFragment(AbstractAlignmentMerger.java:680)
at picard.sam.AbstractAlignmentMerger.transferAlignmentInfoToPairedRead(AbstractAlignmentMerger.java:752)
at picard.sam.AbstractAlignmentMerger.mergeAlignment(AbstractAlignmentMerger.java:481)
at picard.sam.SamAlignmentMerger.mergeAlignment(SamAlignmentMerger.java:186)
at picard.sam.MergeBamAlignment.doWork(MergeBamAlignment.java:368)
at picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:308)
at picard.cmdline.PicardCommandLine.instanceMain(PicardCommandLine.java:103)
at picard.cmdline.PicardCommandLine.main(PicardCommandLine.java:113)
I also checked the following:
- The ubam and bam file have the same number of reads. (To get number of reads:
samtools view -c bamfile
AND to get number of mapped reads:samtools view -c -F 260
) - I tried sorting the ubam and bam files using
SortSam
and then runningMergeBamAlignment
, butMergeBamAlignment
failed with the same exception.
Does anyone know why this exception occurs and how to avoid it?
Hi,
There is no need to add
broadinstitute
as a tag - that tag makes no sense. I've removed it, please don't re-add it.