countmut 0.2.0__tar.gz → 0.2.3__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 (50) hide show
  1. {countmut-0.2.0/countmut.egg-info → countmut-0.2.3}/PKG-INFO +24 -7
  2. {countmut-0.2.0 → countmut-0.2.3}/README.md +23 -6
  3. {countmut-0.2.0 → countmut-0.2.3}/backend/countmut_core.c +139 -200
  4. {countmut-0.2.0 → countmut-0.2.3}/backend/countmut_core.h +22 -7
  5. {countmut-0.2.0 → countmut-0.2.3}/backend/countmut_core_main.c +10 -0
  6. {countmut-0.2.0 → countmut-0.2.3}/backend/countmut_expr.c +148 -36
  7. {countmut-0.2.0 → countmut-0.2.3}/backend/countmut_expr.h +26 -11
  8. countmut-0.2.3/countmut/_core/countmut_core +0 -0
  9. {countmut-0.2.0 → countmut-0.2.3}/countmut/backend.py +2 -0
  10. {countmut-0.2.0 → countmut-0.2.3}/countmut/cli.py +16 -1
  11. {countmut-0.2.0 → countmut-0.2.3}/countmut/model.py +1 -0
  12. {countmut-0.2.0 → countmut-0.2.3/countmut.egg-info}/PKG-INFO +24 -7
  13. {countmut-0.2.0 → countmut-0.2.3}/countmut.egg-info/SOURCES.txt +1 -0
  14. {countmut-0.2.0 → countmut-0.2.3}/pyproject.toml +1 -1
  15. countmut-0.2.3/tests/test_router.py +229 -0
  16. countmut-0.2.0/countmut/_core/countmut_core +0 -0
  17. {countmut-0.2.0 → countmut-0.2.3}/LICENSE +0 -0
  18. {countmut-0.2.0 → countmut-0.2.3}/MANIFEST.in +0 -0
  19. {countmut-0.2.0 → countmut-0.2.3}/backend/Makefile +0 -0
  20. {countmut-0.2.0 → countmut-0.2.3}/backend/bedidx.c +0 -0
  21. {countmut-0.2.0 → countmut-0.2.3}/backend/bgzf.c +0 -0
  22. {countmut-0.2.0 → countmut-0.2.3}/backend/bgzf.h +0 -0
  23. {countmut-0.2.0 → countmut-0.2.3}/backend/faidx.c +0 -0
  24. {countmut-0.2.0 → countmut-0.2.3}/backend/faidx.h +0 -0
  25. {countmut-0.2.0 → countmut-0.2.3}/backend/hts.c +0 -0
  26. {countmut-0.2.0 → countmut-0.2.3}/backend/hts.h +0 -0
  27. {countmut-0.2.0 → countmut-0.2.3}/backend/ketopt.h +0 -0
  28. {countmut-0.2.0 → countmut-0.2.3}/backend/khash.h +0 -0
  29. {countmut-0.2.0 → countmut-0.2.3}/backend/kseq.h +0 -0
  30. {countmut-0.2.0 → countmut-0.2.3}/backend/ksort.h +0 -0
  31. {countmut-0.2.0 → countmut-0.2.3}/backend/kstdint.h +0 -0
  32. {countmut-0.2.0 → countmut-0.2.3}/backend/kstring.h +0 -0
  33. {countmut-0.2.0 → countmut-0.2.3}/backend/razf.c +0 -0
  34. {countmut-0.2.0 → countmut-0.2.3}/backend/razf.h +0 -0
  35. {countmut-0.2.0 → countmut-0.2.3}/backend/sam.c +0 -0
  36. {countmut-0.2.0 → countmut-0.2.3}/backend/sam.h +0 -0
  37. {countmut-0.2.0 → countmut-0.2.3}/countmut/__init__.py +0 -0
  38. {countmut-0.2.0 → countmut-0.2.3}/countmut/bam_tags.py +0 -0
  39. {countmut-0.2.0 → countmut-0.2.3}/countmut/core.py +0 -0
  40. {countmut-0.2.0 → countmut-0.2.3}/countmut/utils.py +0 -0
  41. {countmut-0.2.0 → countmut-0.2.3}/countmut.egg-info/dependency_links.txt +0 -0
  42. {countmut-0.2.0 → countmut-0.2.3}/countmut.egg-info/entry_points.txt +0 -0
  43. {countmut-0.2.0 → countmut-0.2.3}/countmut.egg-info/requires.txt +0 -0
  44. {countmut-0.2.0 → countmut-0.2.3}/countmut.egg-info/top_level.txt +0 -0
  45. {countmut-0.2.0 → countmut-0.2.3}/setup.cfg +0 -0
  46. {countmut-0.2.0 → countmut-0.2.3}/tests/test_cli.py +0 -0
  47. {countmut-0.2.0 → countmut-0.2.3}/tests/test_core.py +0 -0
  48. {countmut-0.2.0 → countmut-0.2.3}/tests/test_correctness.py +0 -0
  49. {countmut-0.2.0 → countmut-0.2.3}/tests/test_unified.py +0 -0
  50. {countmut-0.2.0 → countmut-0.2.3}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: countmut
3
- Version: 0.2.0
3
+ Version: 0.2.3
4
4
  Summary: Unified ultra-fast strand-aware mutation counter (C backend + samtools-style -e/-p filters)
5
5
  Author-email: Ye Chang <yech1990@gmail.com>
6
6
  License-Expression: MIT
@@ -99,6 +99,22 @@ countmut -i x -r ref -o out -e "[NM] <= 3 and not (flag.dup ~= 0) and flag.read1
99
99
  countmut -i x -r ref -o out -p "depth >= 5 and g >= 2"
100
100
  ```
101
101
 
102
+ **`-e` is also a group router.** A bare boolean expression is a filter
103
+ (`true` → count, `nil`/`false` → drop), but an expression that returns an
104
+ integer `0..3` routes each kept base into that **group**; `true` routes to
105
+ group 0. Anything else drops the base (with a stderr warning). The split
106
+ shows up in `--output-format` templates as per-group cells `{a.0}` … `{n.3}`
107
+ (plain `{a}` stays the total over all groups):
108
+
109
+ ```bash
110
+ # bisulfite A->G, 2-group router: group 1 = high-conversion bases, group 0 =
111
+ # everything else that passes the hard NS gate (low quality / read-end trim)
112
+ countmut -i x -r ref -o out \
113
+ -e "([NS] <= 1) and (([Yf] >= 1 and [Zf] <= 3 and bq >= 20 and qpos >= 2 and qlen - qpos > 2) and 1 or 0)" \
114
+ --output-format "{chrom}\t{pos+1}\t{strand}\t{motif}\t{a.0}\t{a.1}\t{g.0}\t{g.1}" \
115
+ --motif-pad 15 --fmt-header "chrom\tpos\tstrand\tmotif\tu0\tu1\tm0\tm1"
116
+ ```
117
+
102
118
  Most filters use roughly ten variables — `mapq`, `bq` (base quality), `flags`,
103
119
  `qpos` (position in the read), `dist5`/`dist3` (distance to the read ends),
104
120
  `base`/`ref`, `tag('XX')`, and `rname`. A couple of things are worth knowing.
@@ -116,10 +132,11 @@ reference in [`docs/expression_reference.md`](docs/expression_reference.md).
116
132
  ## Output format
117
133
 
118
134
  `--output-format` takes a **row template**: literal text plus `{expr}`
119
- placeholders evaluated per site over the site values (`pos`, `ref`, `depth`,
120
- `a c g t n`, `ins del ref_skip fail`). Placeholders run real Lua, so you can
121
- compute cells — a conversion ratio is just `{t}/({c}+{t})` — and `round(x, n)`
122
- and `int(x)` are helpers for formatting:
135
+ placeholders evaluated per site over the site values (`chrom`, `pos`,
136
+ `strand`, `motif`, `ref`, `depth`, `a c g t n`, `ins del ref_skip fail`, and
137
+ per-group counts `a.0` … `n.3` whenever `-e` routes into groups). Placeholders
138
+ run real Lua, so you can compute cells — a conversion ratio is just
139
+ `{t}/({c}+{t})` — and `round(x, n)` and `int(x)` are helpers for formatting:
123
140
 
124
141
  ```bash
125
142
  countmut -i x -r ref -o out \
@@ -138,8 +155,8 @@ Two BAM-walking strategies live in the C core and emit identical output, so
138
155
  the engine choice only affects speed (`--engine auto` uses the pileup walk for
139
156
  the per-position counting). The options are few: input/reference/output,
140
157
  `--region`, `--threads/-t`, `--engine`, `--strandless`, `--count-indels`,
141
- `--vcf` (+ `--min-depth`/`--min-allele-support`), `-e`/`-p`, and
142
- `--output-format`/`--fmt-header`.
158
+ `--vcf` (+ `--min-depth`/`--min-allele-support`), `-e`/`-p`, `--motif-pad`,
159
+ and `--output-format`/`--fmt-header`.
143
160
 
144
161
  ## Input formats
145
162
 
@@ -62,6 +62,22 @@ countmut -i x -r ref -o out -e "[NM] <= 3 and not (flag.dup ~= 0) and flag.read1
62
62
  countmut -i x -r ref -o out -p "depth >= 5 and g >= 2"
63
63
  ```
64
64
 
65
+ **`-e` is also a group router.** A bare boolean expression is a filter
66
+ (`true` → count, `nil`/`false` → drop), but an expression that returns an
67
+ integer `0..3` routes each kept base into that **group**; `true` routes to
68
+ group 0. Anything else drops the base (with a stderr warning). The split
69
+ shows up in `--output-format` templates as per-group cells `{a.0}` … `{n.3}`
70
+ (plain `{a}` stays the total over all groups):
71
+
72
+ ```bash
73
+ # bisulfite A->G, 2-group router: group 1 = high-conversion bases, group 0 =
74
+ # everything else that passes the hard NS gate (low quality / read-end trim)
75
+ countmut -i x -r ref -o out \
76
+ -e "([NS] <= 1) and (([Yf] >= 1 and [Zf] <= 3 and bq >= 20 and qpos >= 2 and qlen - qpos > 2) and 1 or 0)" \
77
+ --output-format "{chrom}\t{pos+1}\t{strand}\t{motif}\t{a.0}\t{a.1}\t{g.0}\t{g.1}" \
78
+ --motif-pad 15 --fmt-header "chrom\tpos\tstrand\tmotif\tu0\tu1\tm0\tm1"
79
+ ```
80
+
65
81
  Most filters use roughly ten variables — `mapq`, `bq` (base quality), `flags`,
66
82
  `qpos` (position in the read), `dist5`/`dist3` (distance to the read ends),
67
83
  `base`/`ref`, `tag('XX')`, and `rname`. A couple of things are worth knowing.
@@ -79,10 +95,11 @@ reference in [`docs/expression_reference.md`](docs/expression_reference.md).
79
95
  ## Output format
80
96
 
81
97
  `--output-format` takes a **row template**: literal text plus `{expr}`
82
- placeholders evaluated per site over the site values (`pos`, `ref`, `depth`,
83
- `a c g t n`, `ins del ref_skip fail`). Placeholders run real Lua, so you can
84
- compute cells — a conversion ratio is just `{t}/({c}+{t})` — and `round(x, n)`
85
- and `int(x)` are helpers for formatting:
98
+ placeholders evaluated per site over the site values (`chrom`, `pos`,
99
+ `strand`, `motif`, `ref`, `depth`, `a c g t n`, `ins del ref_skip fail`, and
100
+ per-group counts `a.0` … `n.3` whenever `-e` routes into groups). Placeholders
101
+ run real Lua, so you can compute cells — a conversion ratio is just
102
+ `{t}/({c}+{t})` — and `round(x, n)` and `int(x)` are helpers for formatting:
86
103
 
87
104
  ```bash
88
105
  countmut -i x -r ref -o out \
@@ -101,8 +118,8 @@ Two BAM-walking strategies live in the C core and emit identical output, so
101
118
  the engine choice only affects speed (`--engine auto` uses the pileup walk for
102
119
  the per-position counting). The options are few: input/reference/output,
103
120
  `--region`, `--threads/-t`, `--engine`, `--strandless`, `--count-indels`,
104
- `--vcf` (+ `--min-depth`/`--min-allele-support`), `-e`/`-p`, and
105
- `--output-format`/`--fmt-header`.
121
+ `--vcf` (+ `--min-depth`/`--min-allele-support`), `-e`/`-p`, `--motif-pad`,
122
+ and `--output-format`/`--fmt-header`.
106
123
 
107
124
  ## Input formats
108
125