deamtools 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. deamtools-0.1.1/.gitignore +21 -0
  2. deamtools-0.1.1/LICENSE +21 -0
  3. deamtools-0.1.1/PKG-INFO +181 -0
  4. deamtools-0.1.1/README.md +138 -0
  5. deamtools-0.1.1/pyproject.toml +106 -0
  6. deamtools-0.1.1/src/deamtools/__main__.py +5 -0
  7. deamtools-0.1.1/src/deamtools/align/__init__.py +6 -0
  8. deamtools-0.1.1/src/deamtools/align/align.py +368 -0
  9. deamtools-0.1.1/src/deamtools/align/index.py +144 -0
  10. deamtools-0.1.1/src/deamtools/cli/__init__.py +0 -0
  11. deamtools-0.1.1/src/deamtools/cli/main.py +1162 -0
  12. deamtools-0.1.1/src/deamtools/footprint/__init__.py +5 -0
  13. deamtools-0.1.1/src/deamtools/footprint/footprint.py +182 -0
  14. deamtools-0.1.1/src/deamtools/motif/__init__.py +9 -0
  15. deamtools-0.1.1/src/deamtools/motif/match.py +258 -0
  16. deamtools-0.1.1/src/deamtools/preprocessing/__init__.py +0 -0
  17. deamtools-0.1.1/src/deamtools/preprocessing/bam2bw.py +451 -0
  18. deamtools-0.1.1/src/deamtools/preprocessing/bam2fragment.py +232 -0
  19. deamtools-0.1.1/src/deamtools/preprocessing/fragment2bw.py +0 -0
  20. deamtools-0.1.1/src/deamtools/qc/__init__.py +5 -0
  21. deamtools-0.1.1/src/deamtools/qc/qc.py +910 -0
  22. deamtools-0.1.1/src/deamtools/seq2edit/__init__.py +19 -0
  23. deamtools-0.1.1/src/deamtools/seq2edit/dataset.py +59 -0
  24. deamtools-0.1.1/src/deamtools/seq2edit/model.py +306 -0
  25. deamtools-0.1.1/src/deamtools/seq2edit/train.py +253 -0
  26. deamtools-0.1.1/src/deamtools/utils/__init__.py +16 -0
  27. deamtools-0.1.1/src/deamtools/utils/_logging.py +11 -0
  28. deamtools-0.1.1/src/deamtools/utils/chromosome.py +46 -0
  29. deamtools-0.1.1/src/deamtools/utils/regions.py +120 -0
  30. deamtools-0.1.1/src/deamtools/utils/version.py +18 -0
  31. deamtools-0.1.1/tests/test_align.py +279 -0
  32. deamtools-0.1.1/tests/test_bam2bw.py +559 -0
  33. deamtools-0.1.1/tests/test_bam2fragment.py +322 -0
  34. deamtools-0.1.1/tests/test_footprint.py +116 -0
  35. deamtools-0.1.1/tests/test_index.py +144 -0
  36. deamtools-0.1.1/tests/test_matching.py +123 -0
  37. deamtools-0.1.1/tests/test_qc.py +292 -0
  38. deamtools-0.1.1/tests/test_seq2edit.py +189 -0
@@ -0,0 +1,21 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .eggs/
7
+ *.egg
8
+ # uv's project environment. uv.lock IS committed — it pins the dev environment.
9
+ .venv/
10
+ .pytest_cache/
11
+ .mypy_cache/
12
+ .ruff_cache/
13
+ docs/_build/
14
+ *.bam
15
+ *.bai
16
+ *.bw
17
+ *.fa
18
+ *.fai
19
+
20
+ # /export-generated transcripts (claude-code local command output)
21
+ *-local-command-caveat*.txt
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Zhijian Li
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,181 @@
1
+ Metadata-Version: 2.5
2
+ Name: deamtools
3
+ Version: 0.1.1
4
+ Summary: A Python command-line toolkit for deamination-based chromatin signal analysis.
5
+ Project-URL: Homepage, https://github.com/lzj1769/deamTools
6
+ Project-URL: Repository, https://github.com/lzj1769/deamTools
7
+ Project-URL: Issues, https://github.com/lzj1769/deamTools/issues
8
+ Project-URL: Documentation, https://lzj1769.github.io/deamTools
9
+ Author: Zhijian Li
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Keywords: accessibility,bioinformatics,chromatin,command-line,deamination,epigenomics,footprinting,genomics
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
22
+ Requires-Python: >=3.12
23
+ Requires-Dist: logomaker>=0.8
24
+ Requires-Dist: matplotlib>=3.8
25
+ Requires-Dist: moods-python==1.9.4.1
26
+ Requires-Dist: numpy>=1.26
27
+ Requires-Dist: pandas>=2.2
28
+ Requires-Dist: pybigwig>=0.3.22
29
+ Requires-Dist: pysam>=0.22
30
+ Provides-Extra: dev
31
+ Requires-Dist: black>=24.0; extra == 'dev'
32
+ Requires-Dist: mypy>=1.10; extra == 'dev'
33
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
34
+ Requires-Dist: pytest>=8.0; extra == 'dev'
35
+ Requires-Dist: ruff>=0.5.0; extra == 'dev'
36
+ Provides-Extra: docs
37
+ Requires-Dist: myst-parser>=2; extra == 'docs'
38
+ Requires-Dist: sphinx-rtd-theme>=2; extra == 'docs'
39
+ Requires-Dist: sphinx>=7; extra == 'docs'
40
+ Provides-Extra: seq2edit
41
+ Requires-Dist: torch>=2.0; extra == 'seq2edit'
42
+ Description-Content-Type: text/markdown
43
+
44
+ # DeamTools
45
+
46
+ A Python command-line toolkit for deaminase-based chromatin accessibility analysis.
47
+
48
+ DeamTools quantifies cytosine deamination (C→T) events in aligned sequencing reads and converts them into BigWig coverage tracks for genome-browser visualisation and downstream signal analysis. It is designed for deaminase-based assays — such as CHEESE-seq, DamID variants, or any method that uses a deaminase to mark accessible chromatin — where single-base C→T editing events serve as the accessibility signal.
49
+
50
+ ## How it works
51
+
52
+ For each aligned read, DeamTools scans reference cytosine positions covered by the read and records positions where a C→T (forward strand) or G→A (reverse strand) conversion is observed. These per-base editing counts are accumulated genome-wide and written as a BigWig file.
53
+
54
+ ## Installation
55
+
56
+ **Requirements:** Python ≥ 3.12, `samtools` (for indexing BAM/FASTA files).
57
+
58
+ ```bash
59
+ git clone https://github.com/lzj1769/deamTools.git
60
+ cd deamTools
61
+ pip install .
62
+ ```
63
+
64
+ For development (adds pytest, ruff, black, mypy):
65
+
66
+ ```bash
67
+ pip install -e ".[dev]"
68
+ ```
69
+
70
+ ## Quick start
71
+
72
+ ```bash
73
+ # 1. Sort and index your BAM file
74
+ samtools sort -o sample.sorted.bam sample.bam
75
+ samtools index sample.sorted.bam
76
+
77
+ # 2. Index the reference FASTA
78
+ samtools faidx hg38.fa
79
+
80
+ # 3. Convert to BigWig
81
+ deamtools bam2bw \
82
+ --bam sample.sorted.bam \
83
+ --fasta hg38.fa \
84
+ --out_dir results \
85
+ --out_name sample
86
+ ```
87
+
88
+ ## Commands
89
+
90
+ ### Global options
91
+
92
+ ```
93
+ deamtools [--version] [--log_level LEVEL] <command>
94
+ ```
95
+
96
+ | Option | Default | Description |
97
+ |---|---|---|
98
+ | `--version` | — | Print version and exit |
99
+ | `--log_level` | `INFO` | Verbosity: `DEBUG`, `INFO`, `WARNING`, or `ERROR` |
100
+
101
+ ---
102
+
103
+ ### `bam2bw` — BAM to BigWig
104
+
105
+ Convert a coordinate-sorted BAM file to a per-base BigWig track of C→T deamination counts.
106
+
107
+ ```
108
+ deamtools bam2bw --bam FILE --fasta FILE --out_dir DIR --out_name NAME [options]
109
+ ```
110
+
111
+ #### Required arguments
112
+
113
+ | Argument | Description |
114
+ |---|---|
115
+ | `--bam FILE` | Coordinate-sorted BAM file. Must be indexed (`.bai`). |
116
+ | `--fasta FILE` | Reference FASTA file. Must be indexed with `samtools faidx` (`.fai`). |
117
+ | `--out_dir DIR` | Output directory. Created automatically if it does not exist. |
118
+ | `--out_name NAME` | Base name (without extension) for the output. Writes `<out_dir>/<out_name>.bw`. |
119
+
120
+ #### Optional arguments
121
+
122
+ | Argument | Default | Description |
123
+ |---|---|---|
124
+ | `--chrom_sizes FILE` | *(from BAM header)* | Tab-delimited chromosome sizes file (`chrom\tsize`). If omitted, sizes are inferred from the BAM header. |
125
+ | `--regions FILE` | *(whole genome)* | BED file of regions to restrict analysis to. Overlapping intervals are merged automatically. |
126
+ | `--extend_size INT` | `0` | Symmetrically extend each detected editing site by INT base pairs before writing to the BigWig. Useful for smoothing sparse signals or defining accessible windows around editing events. |
127
+ | `--min_mapq INT` | `20` | Minimum read mapping quality. Reads below this threshold are skipped. |
128
+ | `--min_baseq INT` | `20` | Minimum base quality at a position. Bases below this threshold are not counted. |
129
+ | `--threads INT` | `1` | Number of threads for parallel chromosome processing. |
130
+
131
+ Reads that are unmapped, duplicate, QC-failed, secondary, or supplementary are always excluded regardless of quality thresholds.
132
+
133
+ #### Examples
134
+
135
+ ```bash
136
+ # Whole-genome run with default quality thresholds
137
+ deamtools bam2bw \
138
+ --bam sample.bam \
139
+ --fasta hg38.fa \
140
+ --out_dir results \
141
+ --out_name sample
142
+
143
+ # Restrict to peaks, use stricter filters, run on 4 threads
144
+ deamtools bam2bw \
145
+ --bam sample.bam \
146
+ --fasta hg38.fa \
147
+ --regions peaks.bed \
148
+ --min_mapq 30 \
149
+ --min_baseq 30 \
150
+ --threads 4 \
151
+ --out_dir results \
152
+ --out_name sample_peaks
153
+
154
+ # Extend each editing site by 50 bp in both directions
155
+ deamtools bam2bw \
156
+ --bam sample.bam \
157
+ --fasta hg38.fa \
158
+ --extend_size 50 \
159
+ --out_dir results \
160
+ --out_name sample_extended
161
+
162
+ # Provide an explicit chromosome sizes file and enable debug logging
163
+ deamtools --log_level DEBUG bam2bw \
164
+ --bam sample.bam \
165
+ --fasta hg38.fa \
166
+ --chrom_sizes hg38.chrom.sizes \
167
+ --out_dir results \
168
+ --out_name sample
169
+ ```
170
+
171
+ ## Running tests
172
+
173
+ ```bash
174
+ pytest # run all tests
175
+ pytest -v # verbose output
176
+ pytest tests/test_bam2bw.py # run a specific test file
177
+ ```
178
+
179
+ ## License
180
+
181
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,138 @@
1
+ # DeamTools
2
+
3
+ A Python command-line toolkit for deaminase-based chromatin accessibility analysis.
4
+
5
+ DeamTools quantifies cytosine deamination (C→T) events in aligned sequencing reads and converts them into BigWig coverage tracks for genome-browser visualisation and downstream signal analysis. It is designed for deaminase-based assays — such as CHEESE-seq, DamID variants, or any method that uses a deaminase to mark accessible chromatin — where single-base C→T editing events serve as the accessibility signal.
6
+
7
+ ## How it works
8
+
9
+ For each aligned read, DeamTools scans reference cytosine positions covered by the read and records positions where a C→T (forward strand) or G→A (reverse strand) conversion is observed. These per-base editing counts are accumulated genome-wide and written as a BigWig file.
10
+
11
+ ## Installation
12
+
13
+ **Requirements:** Python ≥ 3.12, `samtools` (for indexing BAM/FASTA files).
14
+
15
+ ```bash
16
+ git clone https://github.com/lzj1769/deamTools.git
17
+ cd deamTools
18
+ pip install .
19
+ ```
20
+
21
+ For development (adds pytest, ruff, black, mypy):
22
+
23
+ ```bash
24
+ pip install -e ".[dev]"
25
+ ```
26
+
27
+ ## Quick start
28
+
29
+ ```bash
30
+ # 1. Sort and index your BAM file
31
+ samtools sort -o sample.sorted.bam sample.bam
32
+ samtools index sample.sorted.bam
33
+
34
+ # 2. Index the reference FASTA
35
+ samtools faidx hg38.fa
36
+
37
+ # 3. Convert to BigWig
38
+ deamtools bam2bw \
39
+ --bam sample.sorted.bam \
40
+ --fasta hg38.fa \
41
+ --out_dir results \
42
+ --out_name sample
43
+ ```
44
+
45
+ ## Commands
46
+
47
+ ### Global options
48
+
49
+ ```
50
+ deamtools [--version] [--log_level LEVEL] <command>
51
+ ```
52
+
53
+ | Option | Default | Description |
54
+ |---|---|---|
55
+ | `--version` | — | Print version and exit |
56
+ | `--log_level` | `INFO` | Verbosity: `DEBUG`, `INFO`, `WARNING`, or `ERROR` |
57
+
58
+ ---
59
+
60
+ ### `bam2bw` — BAM to BigWig
61
+
62
+ Convert a coordinate-sorted BAM file to a per-base BigWig track of C→T deamination counts.
63
+
64
+ ```
65
+ deamtools bam2bw --bam FILE --fasta FILE --out_dir DIR --out_name NAME [options]
66
+ ```
67
+
68
+ #### Required arguments
69
+
70
+ | Argument | Description |
71
+ |---|---|
72
+ | `--bam FILE` | Coordinate-sorted BAM file. Must be indexed (`.bai`). |
73
+ | `--fasta FILE` | Reference FASTA file. Must be indexed with `samtools faidx` (`.fai`). |
74
+ | `--out_dir DIR` | Output directory. Created automatically if it does not exist. |
75
+ | `--out_name NAME` | Base name (without extension) for the output. Writes `<out_dir>/<out_name>.bw`. |
76
+
77
+ #### Optional arguments
78
+
79
+ | Argument | Default | Description |
80
+ |---|---|---|
81
+ | `--chrom_sizes FILE` | *(from BAM header)* | Tab-delimited chromosome sizes file (`chrom\tsize`). If omitted, sizes are inferred from the BAM header. |
82
+ | `--regions FILE` | *(whole genome)* | BED file of regions to restrict analysis to. Overlapping intervals are merged automatically. |
83
+ | `--extend_size INT` | `0` | Symmetrically extend each detected editing site by INT base pairs before writing to the BigWig. Useful for smoothing sparse signals or defining accessible windows around editing events. |
84
+ | `--min_mapq INT` | `20` | Minimum read mapping quality. Reads below this threshold are skipped. |
85
+ | `--min_baseq INT` | `20` | Minimum base quality at a position. Bases below this threshold are not counted. |
86
+ | `--threads INT` | `1` | Number of threads for parallel chromosome processing. |
87
+
88
+ Reads that are unmapped, duplicate, QC-failed, secondary, or supplementary are always excluded regardless of quality thresholds.
89
+
90
+ #### Examples
91
+
92
+ ```bash
93
+ # Whole-genome run with default quality thresholds
94
+ deamtools bam2bw \
95
+ --bam sample.bam \
96
+ --fasta hg38.fa \
97
+ --out_dir results \
98
+ --out_name sample
99
+
100
+ # Restrict to peaks, use stricter filters, run on 4 threads
101
+ deamtools bam2bw \
102
+ --bam sample.bam \
103
+ --fasta hg38.fa \
104
+ --regions peaks.bed \
105
+ --min_mapq 30 \
106
+ --min_baseq 30 \
107
+ --threads 4 \
108
+ --out_dir results \
109
+ --out_name sample_peaks
110
+
111
+ # Extend each editing site by 50 bp in both directions
112
+ deamtools bam2bw \
113
+ --bam sample.bam \
114
+ --fasta hg38.fa \
115
+ --extend_size 50 \
116
+ --out_dir results \
117
+ --out_name sample_extended
118
+
119
+ # Provide an explicit chromosome sizes file and enable debug logging
120
+ deamtools --log_level DEBUG bam2bw \
121
+ --bam sample.bam \
122
+ --fasta hg38.fa \
123
+ --chrom_sizes hg38.chrom.sizes \
124
+ --out_dir results \
125
+ --out_name sample
126
+ ```
127
+
128
+ ## Running tests
129
+
130
+ ```bash
131
+ pytest # run all tests
132
+ pytest -v # verbose output
133
+ pytest tests/test_bam2bw.py # run a specific test file
134
+ ```
135
+
136
+ ## License
137
+
138
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,106 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.25.0"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "deamtools"
7
+ version = "0.1.1"
8
+ description = "A Python command-line toolkit for deamination-based chromatin signal analysis."
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "Zhijian Li" }
14
+ ]
15
+ keywords = [
16
+ "genomics",
17
+ "epigenomics",
18
+ "chromatin",
19
+ "accessibility",
20
+ "deamination",
21
+ "footprinting",
22
+ "bioinformatics",
23
+ "command-line",
24
+ ]
25
+ classifiers = [
26
+ "Development Status :: 3 - Alpha",
27
+ "Intended Audience :: Science/Research",
28
+ "License :: OSI Approved :: MIT License",
29
+ "Programming Language :: Python :: 3",
30
+ "Programming Language :: Python :: 3.12",
31
+ "Programming Language :: Python :: 3.13",
32
+ "Topic :: Scientific/Engineering :: Bio-Informatics",
33
+ "Environment :: Console",
34
+ "Operating System :: OS Independent",
35
+ ]
36
+
37
+ dependencies = [
38
+ "numpy>=1.26",
39
+ "pandas>=2.2",
40
+ "matplotlib>=3.8",
41
+ "logomaker>=0.8",
42
+ "pysam>=0.22",
43
+ "pyBigWig>=0.3.22",
44
+ "MOODS-python==1.9.4.1",
45
+ ]
46
+
47
+ [project.optional-dependencies]
48
+ seq2edit = [
49
+ "torch>=2.0",
50
+ ]
51
+ dev = [
52
+ "pytest>=8.0",
53
+ "pytest-cov>=5.0",
54
+ "ruff>=0.5.0",
55
+ "black>=24.0",
56
+ "mypy>=1.10",
57
+ ]
58
+ docs = [
59
+ "sphinx>=7",
60
+ "myst-parser>=2",
61
+ "sphinx-rtd-theme>=2",
62
+ ]
63
+
64
+ [project.scripts]
65
+ deamtools = "deamtools.cli.main:main"
66
+
67
+ [project.urls]
68
+ Homepage = "https://github.com/lzj1769/deamTools"
69
+ Repository = "https://github.com/lzj1769/deamTools"
70
+ Issues = "https://github.com/lzj1769/deamTools/issues"
71
+ Documentation = "https://lzj1769.github.io/deamTools"
72
+
73
+ [tool.hatch.build.targets.wheel]
74
+ packages = ["src/deamtools"]
75
+
76
+ [tool.hatch.build.targets.sdist]
77
+ include = [
78
+ "/src",
79
+ "/tests",
80
+ "/README.md",
81
+ "/LICENSE",
82
+ "/pyproject.toml",
83
+ ]
84
+
85
+ [tool.black]
86
+ line-length = 88
87
+ target-version = ["py312"]
88
+
89
+ [tool.ruff]
90
+ line-length = 88
91
+ target-version = "py312"
92
+
93
+ [tool.ruff.lint]
94
+ select = ["E", "F", "I", "UP", "B"]
95
+
96
+ [tool.pytest.ini_options]
97
+ minversion = "8.0"
98
+ testpaths = ["tests"]
99
+ pythonpath = ["src"]
100
+ addopts = "-q"
101
+
102
+ [tool.mypy]
103
+ python_version = "3.12"
104
+ warn_unused_configs = true
105
+ disallow_untyped_defs = false
106
+ ignore_missing_imports = true
@@ -0,0 +1,5 @@
1
+ from deamtools.cli.main import main
2
+
3
+
4
+ if __name__ == "__main__":
5
+ raise SystemExit(main())
@@ -0,0 +1,6 @@
1
+ """Deamination-aware alignment using a bwa-meth-style strategy."""
2
+
3
+ from deamtools.align.align import run_align
4
+ from deamtools.align.index import run_index
5
+
6
+ __all__ = ["run_align", "run_index"]