Skip to content

Commit 87f8f0b

Browse files
mwiewiorclaude
andcommitted
feat: Add cluster, complement, subtract to LazyFrame .pb namespace
These range operations were added in #311 but were missing from the Polars LazyFrame .pb extension namespace (polars_ext.py). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ec4304f commit 87f8f0b

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

polars_bio/polars_ext.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,67 @@ def coverage(
259259
self._ldf, other_df, cols1=cols1, cols2=cols2, suffixes=suffixes
260260
)
261261

262+
def cluster(
263+
self,
264+
min_dist: int = 0,
265+
cols: Union[list[str], None] = ["chrom", "start", "end"],
266+
) -> pl.LazyFrame:
267+
"""
268+
!!! note
269+
Alias for [cluster](api.md#polars_bio.cluster)
270+
271+
Note:
272+
Coordinate system is determined from DataFrame metadata.
273+
Set metadata using: `df.config_meta.set(coordinate_system_zero_based=True)`
274+
"""
275+
return pb.cluster(
276+
self._ldf,
277+
min_dist=min_dist,
278+
cols=cols,
279+
)
280+
281+
def complement(
282+
self,
283+
view_df: Optional[pl.LazyFrame] = None,
284+
cols: Union[list[str], None] = ["chrom", "start", "end"],
285+
view_cols: Union[list[str], None] = None,
286+
) -> pl.LazyFrame:
287+
"""
288+
!!! note
289+
Alias for [complement](api.md#polars_bio.complement)
290+
291+
Note:
292+
Coordinate system is determined from DataFrame metadata.
293+
Set metadata using: `df.config_meta.set(coordinate_system_zero_based=True)`
294+
"""
295+
return pb.complement(
296+
self._ldf,
297+
view_df=view_df,
298+
cols=cols,
299+
view_cols=view_cols,
300+
)
301+
302+
def subtract(
303+
self,
304+
other_df: pl.LazyFrame,
305+
cols1: Union[list[str], None] = ["chrom", "start", "end"],
306+
cols2: Union[list[str], None] = ["chrom", "start", "end"],
307+
) -> pl.LazyFrame:
308+
"""
309+
!!! note
310+
Alias for [subtract](api.md#polars_bio.subtract)
311+
312+
Note:
313+
Coordinate system is determined from DataFrame metadata.
314+
Set metadata using: `df.config_meta.set(coordinate_system_zero_based=True)`
315+
"""
316+
return pb.subtract(
317+
self._ldf,
318+
other_df,
319+
cols1=cols1,
320+
cols2=cols2,
321+
)
322+
262323
def sink_vcf(self, path: str) -> None:
263324
"""
264325
Streaming write LazyFrame to VCF format.

0 commit comments

Comments
 (0)