From c810117a644f0ae52fd723580b5de2d18c258206 Mon Sep 17 00:00:00 2001 From: clintval Date: Wed, 16 Nov 2022 12:28:42 -0800 Subject: [PATCH 1/3] chore: bump htsjdk to 3.0.3 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index c802a5878..cfae5e653 100644 --- a/build.sbt +++ b/build.sbt @@ -128,7 +128,7 @@ lazy val root = Project(id="fgbio", base=file(".")) "org.scala-lang.modules" %% "scala-xml" % "2.1.0", "com.fulcrumgenomics" %% "commons" % "1.4.0", "com.fulcrumgenomics" %% "sopt" % "1.1.0", - "com.github.samtools" % "htsjdk" % "2.24.1-26-ga38c78d-SNAPSHOT" excludeAll(htsjdkExcludes: _*), + "com.github.samtools" % "htsjdk" % "3.0.3" excludeAll(htsjdkExcludes: _*), "org.apache.commons" % "commons-math3" % "3.6.1", "com.beachape" %% "enumeratum" % "1.7.0", "com.intel.gkl" % "gkl" % "0.8.8", From 585db089c63cf08c0f671e488f82af8a6733ae30 Mon Sep 17 00:00:00 2001 From: clintval Date: Wed, 16 Nov 2022 12:47:38 -0800 Subject: [PATCH 2/3] fix: update JointVariantContextIterator to use locatable ordering --- .../vcf/JointVariantContextIterator.scala | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/scala/com/fulcrumgenomics/vcf/JointVariantContextIterator.scala b/src/main/scala/com/fulcrumgenomics/vcf/JointVariantContextIterator.scala index 90e0518bc..e5e27c375 100644 --- a/src/main/scala/com/fulcrumgenomics/vcf/JointVariantContextIterator.scala +++ b/src/main/scala/com/fulcrumgenomics/vcf/JointVariantContextIterator.scala @@ -24,6 +24,7 @@ package com.fulcrumgenomics.vcf +import com.fulcrumgenomics.coord.LocatableOrdering import com.fulcrumgenomics.fasta.SequenceDictionary import htsjdk.variant.variantcontext.{VariantContext, VariantContextComparator} @@ -55,13 +56,12 @@ class JointVariantContextIterator private(iters: Seq[Iterator[VariantContext]], dictOrComp: Either[SequenceDictionary, VariantContextComparator] ) extends Iterator[Seq[Option[VariantContext]]] { - import com.fulcrumgenomics.fasta.Converters.ToSAMSequenceDictionary if (iters.isEmpty) throw new IllegalArgumentException("No iterators given") private val iterators = iters.map(_.buffered) - private val comparator = dictOrComp match { - case Left(dict) => new VariantContextComparator(dict.asSam) + private val ordering = dictOrComp match { + case Left(dict) => LocatableOrdering(dict) case Right(comp) => comp } @@ -69,12 +69,12 @@ extends Iterator[Seq[Option[VariantContext]]] { def next(): Seq[Option[VariantContext]] = { val minCtx = iterators.filter(_.nonEmpty).map(_.head).sortWith { - case (left: VariantContext, right: VariantContext) => comparator.compare(left, right) < 0 + case (left: VariantContext, right: VariantContext) => ordering.compare(left, right) < 0 }.head // TODO: could use a TreeSet to store the iterators, examine the head of each iterator, then pop the iterator with the min, // and add that iterator back in. - iterators.zipWithIndex.map { case(iter, idx) => - if (iter.isEmpty || this.comparator.compare(minCtx, iter.head) != 0) None + iterators.map { iter => + if (iter.isEmpty || ordering.compare(minCtx, iter.head) != 0) None else Some(iter.next()) } } From ade04c63700ca616045454e280a5e75ec8cde31b Mon Sep 17 00:00:00 2001 From: clintval Date: Wed, 16 Nov 2022 14:35:54 -0800 Subject: [PATCH 3/3] fix!: remove VariantContextComparator entrypoint to JointVariantContextIterator --- .../vcf/JointVariantContextIterator.scala | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/main/scala/com/fulcrumgenomics/vcf/JointVariantContextIterator.scala b/src/main/scala/com/fulcrumgenomics/vcf/JointVariantContextIterator.scala index e5e27c375..b38bc23a1 100644 --- a/src/main/scala/com/fulcrumgenomics/vcf/JointVariantContextIterator.scala +++ b/src/main/scala/com/fulcrumgenomics/vcf/JointVariantContextIterator.scala @@ -32,19 +32,14 @@ object JointVariantContextIterator { def apply(iters: Seq[Iterator[VariantContext]], dict: SequenceDictionary ): JointVariantContextIterator = { - new JointVariantContextIterator( - iters=iters, - dictOrComp = Left(dict) - ) + new JointVariantContextIterator(iters = iters, dict = dict) } + @deprecated("VariantContextComparator will no longer compare variant contexts on location alone.") def apply(iters: Seq[Iterator[VariantContext]], comp: VariantContextComparator ): JointVariantContextIterator = { - new JointVariantContextIterator( - iters=iters, - dictOrComp = Right(comp) - ) + throw new NotImplementedError("VariantContextComparator class can no longer order variant contexts on location alone.") } } @@ -52,18 +47,13 @@ object JointVariantContextIterator { * Iterates over multiple variant context iterators such that we return a list of contexts for the union of sites * across the iterators. If samples is given, we subset each variant context to just that sample. */ -class JointVariantContextIterator private(iters: Seq[Iterator[VariantContext]], - dictOrComp: Either[SequenceDictionary, VariantContextComparator] - ) +class JointVariantContextIterator private(iters: Seq[Iterator[VariantContext]], dict: SequenceDictionary) extends Iterator[Seq[Option[VariantContext]]] { if (iters.isEmpty) throw new IllegalArgumentException("No iterators given") private val iterators = iters.map(_.buffered) - private val ordering = dictOrComp match { - case Left(dict) => LocatableOrdering(dict) - case Right(comp) => comp - } + private val ordering = LocatableOrdering(dict) def hasNext: Boolean = iterators.exists(_.nonEmpty)