End-Motifs

class finaletoolkit.frag.EndMotifFreqs(kmer_frequencies, k, quality_threshold=20)[source]

Genome-wide 5’ end-motif k-mer frequencies (Zhou et al., 2023).

Parameters:
class finaletoolkit.frag.EndMotifsIntervals(intervals, k, quality_threshold=20)[source]

Interval-stratified 5’ end-motif k-mer counts.

Parameters:
finaletoolkit.frag.region_end_motifs(input_file, contig, start, stop, refseq_file, k=4, fraction_low=50, fraction_high=None, both_strands=True, negative_strand=False, output_file=None, quality_threshold=20, verbose=False)[source]

Count 5’ end-motif k-mers for fragments in a region.

Parameters:
  • input_file (str) – BAM/CRAM/fragment input.

  • contig (str) – Contig name.

  • start (int) – 0-based start coordinate.

  • stop (int) – 1-based stop coordinate.

  • refseq_file (str or Path) – Reference the input was aligned to.

  • k (int, optional) – End-motif k-mer length (default 4).

  • fraction_low (int, optional) – Minimum/maximum fragment length.

  • fraction_high (int, optional) – Minimum/maximum fragment length.

  • both_strands (bool, optional) – Use 5’ ends of both mates; if False only the forward end is used unless negative_strand is set.

  • negative_strand (bool, optional) – With both_strands=False, use only negative-strand 5’ ends.

  • output_file (str, optional) – Ignored (kept for signature compatibility).

  • quality_threshold (int, optional) – Minimum mapping quality (default 20).

  • verbose (bool or int, optional) – Print timing.

Returns:

Mapping of k-mer to count (all 4**k k-mers present).

Return type:

dict

finaletoolkit.frag.end_motifs(input_file, refseq_file, k=4, min_length=50, max_length=None, both_strands=True, negative_strand=False, output_file=None, quality_threshold=30, workers=1, verbose=False, fraction_low=None, fraction_high=None)[source]

Compute genome-wide 5’ end-motif frequencies (Zhou et al., 2023).

Parameters:
  • input_file (str) – BAM/CRAM/fragment input.

  • refseq_file (str or Path) – Reference genome (.2bit or FASTA).

  • k (int, optional) – End-motif k-mer length (default 4).

  • min_length (int, optional) – Fragment-length filter (default min 50).

  • max_length (int, optional) – Fragment-length filter (default min 50).

  • both_strands (bool, optional) – Use both mates’ 5’ ends (default True).

  • negative_strand (bool, optional) – With both_strands=False, use only negative-strand ends.

  • output_file (str, optional) – TSV/CSV output path.

  • quality_threshold (int, optional) – Minimum mapping quality (default 30).

  • workers (int, optional) – Worker-process count (default 1).

  • verbose (bool or int, optional) – Print progress/timing.

  • fraction_low (int, optional) – Deprecated aliases for min_length/max_length.

  • fraction_high (int, optional) – Deprecated aliases for min_length/max_length.

Returns:

Normalized genome-wide end-motif frequencies.

Return type:

EndMotifFreqs

finaletoolkit.frag.interval_end_motifs(input_file, refseq_file, intervals, k=4, min_length=50, max_length=None, both_strands=True, negative_strand=False, output_file=None, quality_threshold=30, workers=1, verbose=False, fraction_low=None, fraction_high=None)[source]

Compute interval-stratified 5’ end-motif frequencies.

Parameters:
  • input_file (str) – BAM/CRAM/fragment input.

  • refseq_file (str or Path) – Reference genome.

  • intervals (str or list of tuple) – BED path or list of (chrom, start, stop, name) tuples.

  • k (int, optional) – End-motif k-mer length (default 4).

  • min_length (int, optional) – Fragment-length filter.

  • max_length (int, optional) – Fragment-length filter.

  • both_strands (bool, optional) – Use both mates’ 5’ ends (default True).

  • negative_strand (bool, optional) – With both_strands=False, use only negative-strand ends.

  • output_file (str, optional) – TSV/CSV output path.

  • quality_threshold (int, optional) – Minimum mapping quality (default 30).

  • workers (int, optional) – Worker-process count (default 1).

  • verbose (bool or int, optional) – Print progress/timing.

  • fraction_low (int, optional) – Deprecated aliases for min_length/max_length.

  • fraction_high (int, optional) – Deprecated aliases for min_length/max_length.

Returns:

Per-interval end-motif counts.

Return type:

EndMotifsIntervals