APR Detector
High-throughput pipeline for detecting A-phased repeats (APRs) in genomes with configurable spacing around the DNA helical pitch, symmetry-aware filtering, TpA dinucleotide handling, and multi-format export (TSV/GFF3/BED).
Authors
- Hamza Mohammed (mohammed-hamza@uiowa.edu; hamzamohammed1445@gmail.com), University of Iowa
- Josep Comeron, PhD (josep-comeron@uiowa.edu), University of Iowa
What it does
- Reads FASTA, cleans/validates sequences, and finds A/T-rich tracts.
- Chains tracts whose centers fall within
pitch +/- spacing_window(pitch defaults to 10.5 bp, set with-p). - Computes optional metrics per APR: mean spacing, spacing variance, and phase coherence (Q).
- Filters by tract count, spacing window, symmetry, TA policy, and optional metric thresholds.
- Exports TSV by default plus optional GFF3/BED; filenames use
_APRs(for exampleChr10_APRs.tsvorChr10_20260101_120000_APRs.tsv).
Models (presets)
Model names are case-insensitive; suffixes only apply to Model1/Model2. Override any preset with flags.
Model1: Homopolymer mode. Tracts may be pure A or pure T; APRs can mix them.Model1a: Pure A only. TpA spacer filtering applies only in heteropolymer mode, so it has no effect here.Model1b: Pure T only.
Model2: Heteropolymer mode (A/T tracts; homopolymer runs included).Model2a: Heteropolymer-only (drops pure A or pure T); TpA spacers allowed.Model2b: Symmetry-focused heteropolymer (symmetry forced toonly).
Model3: Uses Cer et al., 2013 TpA-restart approach. Symmetry flags and suffixes are ignored; selectingModel3is enough.
Model flow
flowchart TD
A[Select model] --> M1[Model1]
A --> M2[Model2]
A --> M3[Model3]
M1 --> M1a[Model1a]
M1 --> M1b[Model1b]
M2 --> M2a[Model2a]
M2 --> M2b[Model2b]
subgraph Standard[Standard APR pipeline]
S1[Read and clean sequence] --> S2[Find A and T tracts]
S2 --> S3[Apply symmetry mode]
S3 --> S4[Group tracts into APRs]
S4 --> S5[Compute metrics and export]
end
subgraph TAPath[Model 3 Pipeline]
T1[Scan AT runs] --> T2[Find tract centers]
T2 --> T3[Build APRs with fixed spacing]
T3 --> T4[Export APRs]
end
M1 -->|homopolymer mixed| Standard
M1a -->|A only tracts| Standard
M1b -->|T only tracts| Standard
M2 -->|heteropolymer| Standard
M2a -->|mixed A and T only| Standard
M2b -->|symmetry focused| Standard
M3 -->TAPath
CLI flags (short)
-i FASTA file (positional alternative: first argument)
-o Output directory (positional alternative: second argument)
-l Minimum tract length (default 4)
-t Minimum tracts per APR (default 3; can be set as low as 2)
-w Allowed deviation around pitch (default 0.5; min/max = pitch +/- window)
-p Helical pitch in bp (default 10.5; used for spacing window and phase coherence)
-n 0=remove, 1=keep (default), 2=error
-y 1=include, 0=exclude, 2=only (ignored for Model3)
-m 1=merge overlapping/contained APRs (default), 0=keep separate
-ta 1=allow TA inside tracts (default), 0=reject such tracts
-csv Also write APRs to CSV (optional path override)
-tracts Write candidate tracts to CSV (pre-APR filtering; can be large)
-tracts-tsv Write candidate tracts to TSV (pre-APR filtering; can be large)
-u Optional max mean spacing filter (bp)
-v Optional max spacing variance filter (bp^2)
-q Optional min phase coherence filter (0-1)
-s 1=forward only (default), 2=both strands
-c Worker count for multiprocessing (default 1)
-g Also write GFF3
-b Also write BED
-nt Omit timestamps in filenames
Metrics (reported in TSV, used for optional filtering)
- Mean spacing (mu): Arithmetic mean of inter-tract center spacings.
- Spacing variance (sigma^2): Sample variance of the spacings (consistency of spacing). No default cutoff; set
-vto filter. - Phase coherence (Q):
Q = 1 - r_bar / Rmax, where each residualr_iis the distance from a spacing to the nearest multiple of the pitch.Rmaxdefaults topitch/2unless overridden inScoringConfig.PHASE_RMAX.- A small epsilon protects division when residuals vanish; Q is clamped to [0,1].
- Set
-qto require a minimum phase coherence.
Spacing window & pitch
- Effective spacing bounds are
pitch - spacing_windowtopitch + spacing_window, echoed in logs and TSV headers. - The window is not hard-coded to 10.5; adjust
-pto shift the target pitch and-wto widen/narrow tolerance.
Outputs
- TSV (default): Parameter header on the first line with flag-style labels; columns include
Mean_spacing,Spacing_variance, andPhase_Coherence. - CSV (optional with -csv): Same APR content as TSV, comma-separated.
- GFF3 (optional): Feature type
APR; attributes include tract count, tract sequences, composition, and metrics when available. - BED6 (optional): Name
APR_<n>, score equals tract count. - Output stems use
_APRsbefore the extension (for example_APRs.tsv,_APRs.gff,_APRs.bed). - Tracts CSV/TSV (optional with -tracts and -tracts-tsv): All candidate tracts prior to APR spacing filters; includes positions, strand, sequence, symmetry flag, and mode settings. Warning: can be very large on whole genomes; consider per-chromosome runs, stricter tract settings (higher
-l, symmetry-only, hetero-only), ample disk space, or compression.
Install (pip)
pip install apr-detector
CLI
apr-detector Model2 \
-i /path/to/genome.fasta \
-o output/ \
-l 4 -t 3 -w 0.5 -p 10.5 \
-c 8 -g -b
Quick start
python scripts/main.py Model2 \
-i /path/to/genome.fasta \
-o output/ \
-l 4 -t 3 -w 0.5 -p 10.5 \
-c 8 -g -b
Testing
python -m pip install -e .[test]
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python -m pytest
Tests read tests/data/S_cerevisiae_chr1.fasta and use the first 20,000 bases by default.
Set APR_TEST_MAX_BASES to control the prefix length (use 0 to read the full file).
Python version
Tested with Python 3.9-3.12.
Configuration notes
- Defaults live in
apr_detector/config/config.py(APRConfig) andapr_detector/core/scoring.py(ScoringConfig); both validate on startup. - Minimum tracts per APR default to 3; values below 2 are rejected (at least one spacing is required).
- Ambiguous handling affects tract discovery only.
- TA inside tracts is controlled with
-ta; TpA spacer filtering applies only in heteropolymer mode. - Case-insensitive model names allow flexible CLI input (for example
model2b,MODEL1A).
Repository layout
apr_detector/cli.py- CLI entry point; orchestrates ingestion, detection, and export.apr_detector/core/- tract discovery (tract.py), APR grouping (detector.py), scoring (scoring.py), and utilities.apr_detector/config/config.py- central defaults and validation.scripts/main.py- source wrapper for local runs.output/- example outputs for reference.
Support
- Hamza Mohammed - mohammed-hamza@uiowa.edu / hamzamohammed1445@gmail.com
- Josep Comeron, PhD - josep-comeron@uiowa.edu
Metadata
Release files for apr-detector 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| apr_detector-0.1.0.tar.gz | 100.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| apr_detector-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 134.0 kB
Release files / apr_detector-0.1.0.tar.gz
| Download URL | apr_detector-0.1.0.tar.gz |
|---|---|
| Size | 100.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
28f24792b028c0999ae756fa2a73939baa09ea0b89e02fc1e75069acfe461455
|
|
BLAKE2b-256 checksum How to use checksums |
84bc5a545e91c115f9e2bc6e4400a69b15d5d31000013d10d7abf67cda44bac7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.3
|
Release files / apr_detector-0.1.0-py3-none-any.whl
| Download URL | apr_detector-0.1.0-py3-none-any.whl |
|---|---|
| Size | 33.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
617a4d1b969ddeeec4bb404d5c11599306af4930ad317ab26e72c858e43e64c9
|
|
BLAKE2b-256 checksum How to use checksums |
595042bb2e9d4821868f3e01c7df3271b60cd08f5f3a1f66486b1def1f178489
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.3
|
Security for apr-detector 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.