genomeblocks.bedpe

Table of contents

  1. Pair
  2. read_bedpe(filename, *, min_score=None, max_distance=None, verbose=True) -> list[Pair]
  3. pair_to_bed(loci, bedpe, *, r=0, either=True, both=False, min_score=None, max_distance=None, verbose=True) -> list[Pair]
  4. pairs_to_frame(pairs) -> pandas.DataFrame
  5. pairs_to_bedpe(pairs, filename) -> None

Pair

@dataclass
class Pair:
    chrom1: str; start1: int; end1: int
    chrom2: str; start2: int; end2: int
    name: str = ""
    score: float = 0.0
    strand1: str = "."
    strand2: str = "."
    extra_fields: tuple = ()

    # properties
    mid1 -> int        # (start1 + end1) // 2
    mid2 -> int        # (start2 + end2) // 2
    distance -> int    # |mid2 - mid1| for intra-chrom; float('inf') otherwise

read_bedpe(filename, *, min_score=None, max_distance=None, verbose=True) -> list[Pair]

Parser. Filters applied in-read if provided.


pair_to_bed(loci, bedpe, *, r=0, either=True, both=False, min_score=None, max_distance=None, verbose=True) -> list[Pair]

Equivalent to bedtools pairtoBed. Also attached as Loci.pair_to_bed(...).

Arguments:

Arg Meaning
loci Loci (or single Locus) to intersect against.
bedpe Path to a BEDPE file or a pre-loaded list[Pair].
r Slop radius per anchor before the overlap test.
either Keep pair if ≥ 1 anchor overlaps (default True).
both Require both anchors overlap (default False).
min_score, max_distance In-read filters (passed to read_bedpe).

pairs_to_frame(pairs) -> pandas.DataFrame

Columns: chrom1, start1, end1, chrom2, start2, end2, name, score, strand1, strand2.


pairs_to_bedpe(pairs, filename) -> None

Writes TSV BEDPE (10 or more columns when extra_fields is set).


Copyright © 2024–2026 Umut Berkay Altintas. MIT Licensed.

This site uses Just the Docs, a documentation theme for Jekyll.