Repository navigation
Conversation
Hoeze
force-pushed
the
feat/variant-matcher
branch
from
October 17, 2026 14:08
1509023 to
d7ab3b6
Compare
Hoeze
force-pushed
the
feat/variant-matcher
branch
from
October 17, 2026 16:22
d7ab3b6 to
8ee6a2d
Compare
SingleVariantMatcher and MultiVariantsMatcher turned their inputs into polars frames, joined them with polars-bio, and turned the rows back into Interval and Variant objects. They differed only in how they iterated, and MultiVariantsMatcher ignored variant_batch_size. vcf_file duplicated variants=scan_vcf_variants(path), which keeps more columns. scan_variant_pairs(intervals, variants) replaces both matchers, BaseVariantMatcher, intervals_to_polars, variants_to_polars and overlap_variants. It takes an intervals DataFrame and a variants DataFrame or LazyFrame. It returns the pairs as a LazyFrame, so a large VCF streams through the overlap join. The pairs keep all columns of both frames, so interval_attrs is gone. A null strand in the intervals gives the strand ".", as a missing strand column. The pairs use the names interval_idx and variant_idx and the prefix variant_. So an interval column named interval_idx or starting with variant_ gives a ValueError, and so does a variant column named idx or variant_idx. No code returns Interval objects with metadata any more, so Interval.attrs is gone. An Interval has only chrom, start, end and strand. BREAKING CHANGE: SingleVariantMatcher, MultiVariantsMatcher, BaseVariantMatcher, intervals_to_polars, variants_to_polars and overlap_variants are gone. Use scan_variant_pairs(intervals, variants) with variants=scan_vcf_variants(path) instead of vcf_file, and pl.DataFrame(objects) for a list of Interval or Variant objects. Build the objects from pairs.iter_rows(named=True) instead of iterating over a matcher, and use collect_batches(chunk_size=n) instead of variant_batch_size. Select the columns of intervals instead of passing interval_attrs. Interval.attrs is gone.
Hoeze
force-pushed
the
feat/variant-matcher
branch
from
October 17, 2026 17:19
8ee6a2d to
93fd41c
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tl;dr: One function,
scan_variant_pairs(intervals, variants), replacesSingleVariantMatcher,MultiVariantsMatcher,BaseVariantMatcherand the converters. It takes polars frames and returns the pairs as a LazyFrame.Interval.attrsis gone.The matchers turned their inputs into polars frames, joined them with polars-bio, and turned the rows back into Interval and Variant objects.
SingleVariantMatcherandMultiVariantsMatcherdiffered only in how they iterated, andMultiVariantsMatcherignoredvariant_batch_size.vcf_fileduplicatedvariants=scan_vcf_variants(path), which keeps more columns.BaseVariantMatcherwas public, but iterating over it raised NotImplementedError.scan_variant_pairs(intervals: pl.DataFrame, variants: pl.DataFrame | pl.LazyFrame) -> pl.LazyFramekeeps the polars-bio overlap join. polars-bio holds the intervals in memory and streams the variants through the join. The pairs have the columns of the oldpairs(): the interval columns under their own names,interval_idx, the variant columns with the prefixvariant_, andvariant_idx. They come in no fixed order, and.collect().sort("variant_idx", "interval_idx")gives the oldpairs().sink_parquetwrites the pairs to a file, andcollect_batches(chunk_size=n)yields batches ofnpairs.The pairs keep all columns of both frames, so
interval_attrsis gone: to keep fewer columns, select them first. A null strand in the intervals gives the strand".", the same as a missing strand column. Before,pairs()kept the null, and the iteration raised a TypeError. The pairs use the namesinterval_idxandvariant_idxand the prefixvariant_. So an interval column namedinterval_idxor starting withvariant_gives a ValueError. A variant column namedidxorvariant_idxgives a ValueError too, where it gave an unclear polars error before.scan_variant_pairsraises a TypeError for inputs that are not polars frames, and the TypeError for a path asvariantspoints toscan_vcf_variants.The Interval and Variant inputs,
intervals_to_polars,variants_to_polars, the publicoverlap_variants,iter_pairs,iter_batchesanditer_by_intervalare gone. Interval and Variant are dataclasses, sopl.DataFrame(intervals)andpl.DataFrame(variants)build the frames from objects. A loop overpairs.iter_rows(named=True)builds Interval and Variant objects, and MIGRATING.md shows it. A later PR adds a batch API that yields the ref and alt sequences of the pairs.No code returns Interval objects with metadata any more, so
Interval.attrsis gone. An Interval has onlychrom,start,endandstrand.The README, the API page and MIGRATING.md describe
scan_variant_pairs. The kipoiseq section of MIGRATING.md describes the final state forSingleVariantMatcher,MultiVariantsMatcherandvcf_file.BREAKING CHANGE:
SingleVariantMatcher,MultiVariantsMatcher,BaseVariantMatcher,intervals_to_polars,variants_to_polarsandoverlap_variantsare gone. Usescan_variant_pairs(intervals, variants)withvariants=scan_vcf_variants(path)instead ofvcf_file, andpl.DataFrame(objects)for a list of Interval or Variant objects. The pairs are a LazyFrame in no fixed order: sort them for the order ofpairs(). Build the objects frompairs.iter_rows(named=True)instead of iterating over a matcher, and usecollect_batches(chunk_size=n)instead ofvariant_batch_size. Select the columns ofintervalsinstead of passinginterval_attrs. A variants column namedidxorvariant_idxraises a ValueError.Interval.attrsis gone.feat(dataclasses)!: drop Interval.attrs