-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bump htsjdk to 3.0.3 #884
Bump htsjdk to 3.0.3 #884
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,57 +24,47 @@ | |
|
||
package com.fulcrumgenomics.vcf | ||
|
||
import com.fulcrumgenomics.coord.LocatableOrdering | ||
import com.fulcrumgenomics.fasta.SequenceDictionary | ||
import htsjdk.variant.variantcontext.{VariantContext, VariantContextComparator} | ||
|
||
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.") | ||
} | ||
} | ||
|
||
/** | ||
* 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]]] { | ||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The class Searching the codebase, this was the only improper use of the new class (and unit tests were failing). |
||
case Right(comp) => comp | ||
} | ||
private val ordering = LocatableOrdering(dict) | ||
|
||
def hasNext: Boolean = iterators.exists(_.nonEmpty) | ||
|
||
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 => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable |
||
if (iter.isEmpty || ordering.compare(minCtx, iter.head) != 0) None | ||
else Some(iter.next()) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entrypoint was never used in this codebase. And it is no longer possible to use
VariantContextComparator
since it compares variants beyond location alone (source). Seems like my only option is deprecation and raising an exception.