Skip to content

mecfs_bio.build_system.task.pipes.drop_palindromes_pipe

Drop strand-ambiguous (palindromic) SNVs.

Classes:

DropPalindromesPipe

Bases: DataProcessingPipe

Methods:

Attributes:

ea_col instance-attribute

ea_col: str

nea_col instance-attribute

nea_col: str

process

process(x: LazyFrame) -> narwhals.LazyFrame
Source code in mecfs_bio/build_system/task/pipes/drop_palindromes_pipe.py
def process(self, x: narwhals.LazyFrame) -> narwhals.LazyFrame:
    is_palindromic = narwhals.any_horizontal(
        (
            (narwhals.col(self.ea_col) == ea) & (narwhals.col(self.nea_col) == nea)
            for ea, nea in _PALINDROME_PAIRS
        ),
        ignore_nulls=True,
    )
    return x.filter(~is_palindromic)