From bcb5577b7ecf265da9bead987d398501a8889988 Mon Sep 17 00:00:00 2001 From: Nils Homer Date: Fri, 18 Aug 2023 14:58:35 -0700 Subject: [PATCH] bugfix: ZipperBams should fail if there any remaining mapped reads (#929) --- .../scala/com/fulcrumgenomics/bam/ZipperBams.scala | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/scala/com/fulcrumgenomics/bam/ZipperBams.scala b/src/main/scala/com/fulcrumgenomics/bam/ZipperBams.scala index 6910e50cc..e618fcf7a 100644 --- a/src/main/scala/com/fulcrumgenomics/bam/ZipperBams.scala +++ b/src/main/scala/com/fulcrumgenomics/bam/ZipperBams.scala @@ -241,6 +241,16 @@ class ZipperBams } out.close() + + // There really should be no more mapped reads! + if (mappedIter.hasNext) { + throw new IllegalStateException( + """Error: processed all unmapped reads but there are mapped reads remaining to be read. + |Please ensure the unmapped and mapped reads have the same set of read names in the same + |order, and reads with the same name are consecutive (grouped) in each input""".stripMargin + ) + } + unmappedSource.safelyClose() mappedSource.safelyClose() }