Body: <p>I doing the alignment of samples following the GATK pipeline, and doing the MergeBamAlignment,like this:</p>
  <pre><code>MergeBamAlignment \
    -ALIGNED $path/file.unsorted.bam \
    -UNMAPPED $path/file.unmapped.bam \
    -O $path/file.merged.bam \
    -R $references/GRCh38.primary_assembly.genome.fa \
    -SO coordinate \
    -TMP_DIR $path/tmp/
  </code></pre>
  <p>I got this error:</p>
  <pre><code>Exception in thread &quot;main&quot; java.lang.IllegalArgumentException: Do not use this function to merge dictionaries with different sequences in them. Sequences must be in the same order as well. Found [] and [chr1, chr2, chr3, chr4, chr5, chr6, chr7, chr8, chr9, chr10, chr11, chr12, chr13, chr14, chr15, chr16, chr17, chr18, chr19, chr20, chr21, chr22, chrX, chrY, chrM, GL000008.2, GL000009.2, GL000194.1, GL000195.1, GL000205.2, GL000208.1, GL000213.1, GL000214.1, GL000216.2, GL000218.1, GL000219.1, GL000220.1, GL000221.1, GL000224.1, GL000225.1, GL000226.1, KI270302.1, KI270303.1, KI270304.1, KI270305.1, KI270310.1, KI270311.1, KI270312.1, KI270315.1, KI270316.1, KI270317.1, KI270320.1, KI270322.1, KI270329.1, KI270330.1, KI270333.1, KI270334.1, KI270335.1, KI270336.1, KI270337.1, KI270338.1, KI270340.1, KI270362.1, KI270363.1, KI270364.1, KI270366.1, KI270371.1, KI270372.1, KI270373.1, KI270374.1, KI270375.1, KI270376.1, KI270378.1, KI270379.1, KI270381.1, KI270382.1, KI270383.1, KI270384.1, KI270385.1, KI270386.1, KI270387.1, KI270388.1, KI270389.1, KI270390.1, KI270391.1, KI270392.1, KI270393.1, KI270394.1, KI270395.1, KI270396.1, KI270411.1, KI270412.1, KI270414.1, KI270417.1, KI270418.1, KI270419.1, KI270420.1, KI270422.1, KI270423.1, KI270424.1, KI270425.1, KI270429.1, KI270435.1, KI270438.1, KI270442.1, KI270448.1, KI270465.1, KI270466.1, KI270467.1, KI270468.1, KI270507.1, KI270508.1, KI270509.1, KI270510.1, KI270511.1, KI270512.1, KI270515.1, KI270516.1, KI270517.1, KI270518.1, KI270519.1, KI270521.1, KI270522.1, KI270528.1, KI270529.1, KI270530.1, KI270538.1, KI270539.1, KI270544.1, KI270548.1, KI270579.1, KI270580.1, KI270581.1, KI270582.1, KI270583.1, KI270584.1, KI270587.1, KI270588.1, KI270589.1, KI270590.1, KI270591.1, KI270593.1, KI270706.1, KI270707.1, KI270708.1, KI270709.1, KI270710.1, KI270711.1, KI270712.1, KI270713.1, KI270714.1, KI270715.1, KI270716.1, KI270717.1, KI270718.1, KI270719.1, KI270720.1, KI270721.1, KI270722.1, KI270723.1, KI270724.1, KI270725.1, KI270726.1, KI270727.1, KI270728.1, KI270729.1, KI270730.1, KI270731.1, KI270732.1, KI270733.1, KI270734.1, KI270735.1, KI270736.1, KI270737.1, KI270738.1, KI270739.1, KI270740.1, KI270741.1, KI270742.1, KI270743.1, KI270744.1, KI270745.1, KI270746.1, KI270747.1, KI270748.1, KI270749.1, KI270750.1, KI270751.1, KI270752.1, KI270753.1, KI270754.1, KI270755.1, KI270756.1, KI270757.1].
      at htsjdk.samtools.SAMSequenceDictionary.mergeDictionaries(SAMSequenceDictionary.java:340)
      at picard.sam.SamAlignmentMerger.getDictionaryForMergedBam(SamAlignmentMerger.java:197)
      at picard.sam.AbstractAlignmentMerger.mergeAlignment(AbstractAlignmentMerger.java:384)
      at picard.sam.SamAlignmentMerger.mergeAlignment(SamAlignmentMerger.java:181)
      at picard.sam.MergeBamAlignment.doWork(MergeBamAlignment.java:368)
      at picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:309)
      at picard.cmdline.PicardCommandLine.instanceMain(PicardCommandLine.java:103)
      at picard.cmdline.PicardCommandLine.main(PicardCommandLine.java:113)
  
  srun: error: compute-12: task 0: Exited with exit code 1
  </code></pre>
  <p>Before I also confirmed that the files that I'm trying to merge, are with the same reference sequences. So I don't understand what could be the problem.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-21T00:45:59.040Z
Comments.Text: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Comments.UserDisplayName: Community
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-21T00:49:43.130Z
Comments.Text: Welcome @RitaSoares. Firstly is this a human genome? Secondly, what have you done unto this point, ie. how did you create the different alignments, especially what were being used?
Comments.UserDisplayName: M__
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-23T06:14:46.663Z
Comments.Text: Not sure if this is related, but do you get the same error after sorting your aligned bam file? Also, just checking that you aligned the reads to the same reference ($references/GRCh38.primary_assembly.genome.fa)
Comments.UserDisplayName: jared_mamrot
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-23T14:29:29.110Z
Comments.Text: @jared_mamrot yes but i got a different error after sorting the aligned bam files, with SortSamSpark: "org.broadinstitute.hellbender.tools.spark.pipelines. SortSamSpark done. Elapsed time: 0.07 minutes.Runtime.totalMemory()=2854748160
  htsjdk.samtools.util.RuntimeEOFException: Premature EOF. Expected 4 but only received 0; BinaryCodec in readmode; streamed file (filename not available)". But according to this error that happend to me before, normally i put in the code of MergeBamAlignment the argument "SO coordinate"and  this corrects my problem but with this samples doesn't happen that.
Comments.UserDisplayName: Rita Soares
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-23T23:07:02.717Z
Comments.Text: Sounds to me like your sample might be corrupted/truncated. What does picard [ValidateSamFile](https://broadinstitute.github.io/picard/command-line-overview.html#ValidateSamFile) output for that sample?
Comments.UserDisplayName: jared_mamrot
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-08-28T14:44:42.580Z
Comments.Text: I also think that is the case... i will try to do ValidateSamFile to make sure. Thank for your answer
Comments.UserDisplayName: Rita Soares
Tags: <gatk><cancer>
Title: MergeBamAlignment error
ThreadText: # MergeBamAlignment error
  
  (Asked by: username_0 on 2023-08-20)
  
  I doing the alignment of samples following the GATK pipeline, and doing the MergeBamAlignment,like this:
  
  ```
  MergeBamAlignment \
    -ALIGNED $path/file.unsorted.bam \
    -UNMAPPED $path/file.unmapped.bam \
    -O $path/file.merged.bam \
    -R $references/GRCh38.primary_assembly.genome.fa \
    -SO coordinate \
    -TMP_DIR $path/tmp/
  
  ```
  
  I got this error:
  
  ```
  Exception in thread "main" java.lang.IllegalArgumentException: Do not use this function to merge dictionaries with different sequences in them. Sequences must be in the same order as well. Found [] and [chr1, chr2, chr3, chr4, chr5, chr6, chr7, chr8, chr9, chr10, chr11, chr12, chr13, chr14, chr15, chr16, chr17, chr18, chr19, chr20, chr21, chr22, chrX, chrY, chrM, GL000008.2, GL000009.2, GL000194.1, GL000195.1, GL000205.2, GL000208.1, GL000213.1, GL000214.1, GL000216.2, GL000218.1, GL000219.1, GL000220.1, GL000221.1, GL000224.1, GL000225.1, GL000226.1, KI270302.1, KI270303.1, KI270304.1, KI270305.1, KI270310.1, KI270311.1, KI270312.1, KI270315.1, KI270316.1, KI270317.1, KI270320.1, KI270322.1, KI270329.1, KI270330.1, KI270333.1, KI270334.1, KI270335.1, KI270336.1, KI270337.1, KI270338.1, KI270340.1, KI270362.1, KI270363.1, KI270364.1, KI270366.1, KI270371.1, KI270372.1, KI270373.1, KI270374.1, KI270375.1, KI270376.1, KI270378.1, KI270379.1, KI270381.1, KI270382.1, KI270383.1, KI270384.1, KI270385.1, KI270386.1, KI270387.1, KI270388.1, KI270389.1, KI270390.1, KI270391.1, KI270392.1, KI270393.1, KI270394.1, KI270395.1, KI270396.1, KI270411.1, KI270412.1, KI270414.1, KI270417.1, KI270418.1, KI270419.1, KI270420.1, KI270422.1, KI270423.1, KI270424.1, KI270425.1, KI270429.1, KI270435.1, KI270438.1, KI270442.1, KI270448.1, KI270465.1, KI270466.1, KI270467.1, KI270468.1, KI270507.1, KI270508.1, KI270509.1, KI270510.1, KI270511.1, KI270512.1, KI270515.1, KI270516.1, KI270517.1, KI270518.1, KI270519.1, KI270521.1, KI270522.1, KI270528.1, KI270529.1, KI270530.1, KI270538.1, KI270539.1, KI270544.1, KI270548.1, KI270579.1, KI270580.1, KI270581.1, KI270582.1, KI270583.1, KI270584.1, KI270587.1, KI270588.1, KI270589.1, KI270590.1, KI270591.1, KI270593.1, KI270706.1, KI270707.1, KI270708.1, KI270709.1, KI270710.1, KI270711.1, KI270712.1, KI270713.1, KI270714.1, KI270715.1, KI270716.1, KI270717.1, KI270718.1, KI270719.1, KI270720.1, KI270721.1, KI270722.1, KI270723.1, KI270724.1, KI270725.1, KI270726.1, KI270727.1, KI270728.1, KI270729.1, KI270730.1, KI270731.1, KI270732.1, KI270733.1, KI270734.1, KI270735.1, KI270736.1, KI270737.1, KI270738.1, KI270739.1, KI270740.1, KI270741.1, KI270742.1, KI270743.1, KI270744.1, KI270745.1, KI270746.1, KI270747.1, KI270748.1, KI270749.1, KI270750.1, KI270751.1, KI270752.1, KI270753.1, KI270754.1, KI270755.1, KI270756.1, KI270757.1].
      at htsjdk.samtools.SAMSequenceDictionary.mergeDictionaries(SAMSequenceDictionary.java:340)
      at picard.sam.SamAlignmentMerger.getDictionaryForMergedBam(SamAlignmentMerger.java:197)
      at picard.sam.AbstractAlignmentMerger.mergeAlignment(AbstractAlignmentMerger.java:384)
      at picard.sam.SamAlignmentMerger.mergeAlignment(SamAlignmentMerger.java:181)
      at picard.sam.MergeBamAlignment.doWork(MergeBamAlignment.java:368)
      at picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:309)
      at picard.cmdline.PicardCommandLine.instanceMain(PicardCommandLine.java:103)
      at picard.cmdline.PicardCommandLine.main(PicardCommandLine.java:113)
  
  srun: error: compute-12: task 0: Exited with exit code 1
  
  ```
  
  Before I also confirmed that the files that I'm trying to merge, are with the same reference sequences. So I don't understand what could be the problem.
  
  **Tags:** gatk, cancer
  
  > **Comments:**
  > **username_1**: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.  
  > **username_2**: Welcome @username_0. Firstly is this a human genome? Secondly, what have you done unto this point, ie. how did you create the different alignments, especially what were being used?  
  > **username_3**: Not sure if this is related, but do you get the same error after sorting your aligned bam file? Also, just checking that you aligned the reads to the same reference ($references/GRCh38.primary_assembly.genome.fa)  
  > **username_0**: @username_3 yes but i got a different error after sorting the aligned bam files, with SortSamSpark: "org.broadinstitute.hellbender.tools.spark.pipelines. SortSamSpark done. Elapsed time: 0.07 minutes.Runtime.totalMemory()=2854748160 htsjdk.samtools.util.RuntimeEOFException: Premature EOF. Expected 4 but only received 0; BinaryCodec in readmode; streamed file (filename not available)". But according to this error that happend to me before, normally i put in the code of MergeBamAlignment the argument "SO coordinate"and  this corrects my problem but with this samples doesn't happen that.  
  > **username_3**: Sounds to me like your sample might be corrupted/truncated. What does picard [ValidateSamFile](https://broadinstitute.github.io/picard/command-line-overview.html#ValidateSamFile) output for that sample?  
  > **username_0**: I also think that is the case... i will try to do ValidateSamFile to make sure. Thank for your answer  
  
  ---
  
  ## 0 answers
  
  