I use the next versions:
gatk 4.4.0.0
minimap2 2.26-r1175
samtools 1.19
I have a fastq file. And try to implement gatk MergeBamAlignment to generate a new bam-file:
java -jar gatk.jar FastqToSam --FASTQ .fastq --OUTPUT u.bam
--SAMPLE_NAME sample1 -RG readgroup -PL ILLUMINA
minimap2 -a hg38.fa .fastq -o A.sam
java -jar gatk.jar SortSam -I A.sam -O A.sort.bam -SO queryname
java -jar gatk.jar SortSam -I u.bam -O u.sort.bam -SO queryname
java -jar gatk.jar MergeBamAlignment -O m.bam -R hg38.fa -UNMAPPED_BAM u.bam -ALIGNED_BAM A.sort.bam
But I receive error on the output of MergeBamAlignment:
INFO 2023-12-21 19:20:41 SamAlignmentMerger Processing SAM file(s): [./myprogs/data/NR.Aligned.sort.bam]
[Thu Dec 21 19:20:42 2023] picard.sam.MergeBamAlignment done.
Elapsed time: 0.02 minutes.
Runtime.totalMemory()=486539264
To get help, see http://broadinstitute.github.io/picard/index.html#GettingHelp
java.lang.ArrayIndexOutOfBoundsException: Index 86 out of bounds for length 86
at htsjdk.samtools.util.SequenceUtil.calculateMdAndNmTags(SequenceUtil.java:990)
at picard.sam.AbstractAlignmentMerger.fixNmMdAndUq(AbstractAlignmentMerger.java:611)
at picard.sam.AbstractAlignmentMerger.mergeAlignment(AbstractAlignmentMerger.java:586)
at picard.sam.SamAlignmentMerger.mergeAlignment(SamAlignmentMerger.java:181)
at picard.sam.MergeBamAlignment.doWork(MergeBamAlignment.java:368)
at picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:289)
at org.broadinstitute.hellbender.cmdline.PicardCommandLineProgramExecutor.instanceMain(PicardCommandLineProgramExecutor.java:37)
at org.broadinstitute.hellbender.Main.runCommandLineProgram(Main.java:160)
at org.broadinstitute.hellbender.Main.mainEntry(Main.java:203)
at org.broadinstitute.hellbender.Main.main(Main.java:289)
I have diagnosed u.sort.bam and A.sam.bam with ValidateSamFile:
java -jar gatk.jar ValidateSamFile -I u.sort.bam -M SUMMARY -R hg38.fa
No errors found
[Thu Dec 21 00:32:34 2023] picard.sam.ValidateSamFile done. Elapsed time: 0.00 minutes.
Runtime.totalMemory()=234881024
Tool returned:
0
java -jar gatk.jar ValidateSamFile -I A.sort.bam -M SUMMARY -R hg38.fa
ERROR 2023-12-21 01:17:28 ValidateSamFile Requesting earlier reference sequence: 23 < 49
[Thu Dec 21 01:17:28 2023] picard.sam.ValidateSamFile done. Elapsed time: 0.18 minutes.
Runtime.totalMemory()=2113929216
To get help, see http://broadinstitute.github.io/picard/index.html#GettingHelp
Tool returned:
-1
I have done the same actions only with --MD
in minimap2. But the same errors occur. I would like to find out how to fix this problem. I use the latest versions of the programs. I have downloaded hg38.fa each one time, but it didn't change the situation. I acts in according with gatk's article 'Data pre-processing for variant discovery' : https://gatk.broadinstitute.org/hc/en-us/articles/360035535912-Data-pre-processing-for-variant-discovery