codonyat 0.1.0__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.
codonyat-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 codonyat contributors
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,140 @@
1
+ Metadata-Version: 2.4
2
+ Name: codonyat
3
+ Version: 0.1.0
4
+ Summary: codon-yat — A codon-aware amino acid variant typer from SAM alignments of viral NGS data.
5
+ Author-email: Marc Noguera Julian <info@treetopunder.com>
6
+ Project-URL: Source, https://github.com/mnoguera/aa_caller
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: Other/Proprietary License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: biopython>=1.79
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest; extra == "dev"
16
+ Requires-Dist: ruff; extra == "dev"
17
+ Dynamic: license-file
18
+
19
+ # codonyat
20
+
21
+ codon-yat — A codon-aware amino acid variant typer from SAM alignments of viral NGS data.
22
+
23
+ A standalone Python package that performs amino acid variant calling, including:
24
+
25
+ - SAM parsing that honors amplicon labels and strand orientation.
26
+ - Ratio balancing, entropy tracking, and TSV/XML exporters mirroring the legacy Perl outputs.
27
+ - Configurable CLI flags for strand ratio bounds and entropy sensitivity.
28
+
29
+ - Works directly on viral genomic datasets generated by high-throughput NGS pipelines and relies on protein-level annotations so you can derive amino-acid variants without reimplementing parsing logic.
30
+
31
+ ## Highlights
32
+
33
+ - Produces consistent TSV/XML diagnostics while adding Python objects (`SamContainer`, `FullReference`, etc.) that downstream tooling can import.
34
+ - Validates every input file before parsing to surface malformed SAM/FASTA/amplicon data early.
35
+ - Logs per-position entropy and strand balance for easier debugging in CI or local runs.
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ pip install .
41
+ ```
42
+
43
+ Or publish the package (e.g., via `twine`/PyPI) and install it like any other dependency.
44
+
45
+ ## CLI usage
46
+
47
+ Once installed, the `codonyat` entry point is available:
48
+
49
+ ```bash
50
+ codonyat /path/to/sample.sam /path/to/reference.fasta /path/to/amplicons.tsv
51
+ ```
52
+
53
+ Supply `--ratio-upper`, `--ratio-lower`, and `--entropy-threshold` to tune the balancing heuristics.
54
+
55
+ The CLI writes `[sam-file].tsv` (columns: FILE, REFERENCE, PROTEIN, VARIANT, POSITION, FREQ, FWCOV, RVCOV, TOTALCOV, RATIO) and `[sam-file].xml` (per-position `<Depth>`, `<FwCover>`, `<RvCover>`, `<Variants>`).
56
+
57
+ ## Package API
58
+
59
+ Import `aa_caller` to reuse the core objects:
60
+
61
+ ```python
62
+ from aa_caller import SamContainer, FullReference, parse_amplicons
63
+ ```
64
+
65
+ The `SamContainer` constructor still accepts `ratio_upper`, `ratio_lower`, and `entropy_threshold` so you can reuse the balancing logic in scripts.
66
+
67
+ ### Python wrapper
68
+
69
+ Use `call_variants` to run the full pipeline from Python without touching the CLI. It validates the inputs, builds the `SamContainer`, and writes the TSV/XML artifacts while returning a `VariantCallResult` you can inspect.
70
+
71
+ ```python
72
+ from pathlib import Path
73
+
74
+ from aa_caller import call_variants
75
+
76
+ result = call_variants(
77
+ sam_path=Path("reads.sam"),
78
+ reference_path=Path("reference.fasta"),
79
+ amplicons_path=Path("amps.tsv"),
80
+ ratio_upper=3.2,
81
+ )
82
+
83
+ print(result.csv_path, result.xml_path)
84
+ print(result.container.variants.keys())
85
+ ```
86
+
87
+ If you already have an `argparse.Namespace` or mapping of the CLI arguments, `call_variants_from_args` adapts them directly.
88
+
89
+ ```python
90
+ from argparse import Namespace
91
+
92
+ args = Namespace(
93
+ sam_file="reads.sam",
94
+ reference_file="reference.fasta",
95
+ amplicons_file="amps.tsv",
96
+ ratio_upper=3.2,
97
+ )
98
+
99
+ call_variants_from_args(args)
100
+ ```
101
+
102
+ ### CLI wrapper
103
+
104
+ This repository installs a lightweight runner at `codonyat-runner` that exposes the same entry arguments as `call_variants_from_args`. Use it when you prefer a small CLI shim over the full `codonyat` entry point:
105
+
106
+ ```bash
107
+ codonyat-runner reads.sam reference.fasta amps.tsv --ratio-upper 3.1 --csv-path results.tsv
108
+ ```
109
+
110
+ ## Development
111
+
112
+ Install the repository with the optional dev tooling so your local environment matches CI:
113
+
114
+ ```bash
115
+ pip install --upgrade pip
116
+ pip install -e .[dev]
117
+ ```
118
+
119
+ Now you can run the same checks that land in [.github/workflows/python-tests.yml](.github/workflows/python-tests.yml#L1-L27):
120
+
121
+ ```bash
122
+ ruff check .
123
+ python -m pytest
124
+ ```
125
+
126
+ The workflow installs `pytest` and `ruff`, runs the linter, and then executes the pytest suite on every push/PR against `main`.
127
+
128
+ ## Testing
129
+
130
+ Run the upstream validation helpers with `pytest`:
131
+
132
+ ```bash
133
+ python -m pytest
134
+ ```
135
+
136
+ Keep the code tidy with `ruff` before committing:
137
+
138
+ ```bash
139
+ ruff check .
140
+ ```
@@ -0,0 +1,122 @@
1
+ # codonyat
2
+
3
+ codon-yat — A codon-aware amino acid variant typer from SAM alignments of viral NGS data.
4
+
5
+ A standalone Python package that performs amino acid variant calling, including:
6
+
7
+ - SAM parsing that honors amplicon labels and strand orientation.
8
+ - Ratio balancing, entropy tracking, and TSV/XML exporters mirroring the legacy Perl outputs.
9
+ - Configurable CLI flags for strand ratio bounds and entropy sensitivity.
10
+
11
+ - Works directly on viral genomic datasets generated by high-throughput NGS pipelines and relies on protein-level annotations so you can derive amino-acid variants without reimplementing parsing logic.
12
+
13
+ ## Highlights
14
+
15
+ - Produces consistent TSV/XML diagnostics while adding Python objects (`SamContainer`, `FullReference`, etc.) that downstream tooling can import.
16
+ - Validates every input file before parsing to surface malformed SAM/FASTA/amplicon data early.
17
+ - Logs per-position entropy and strand balance for easier debugging in CI or local runs.
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install .
23
+ ```
24
+
25
+ Or publish the package (e.g., via `twine`/PyPI) and install it like any other dependency.
26
+
27
+ ## CLI usage
28
+
29
+ Once installed, the `codonyat` entry point is available:
30
+
31
+ ```bash
32
+ codonyat /path/to/sample.sam /path/to/reference.fasta /path/to/amplicons.tsv
33
+ ```
34
+
35
+ Supply `--ratio-upper`, `--ratio-lower`, and `--entropy-threshold` to tune the balancing heuristics.
36
+
37
+ The CLI writes `[sam-file].tsv` (columns: FILE, REFERENCE, PROTEIN, VARIANT, POSITION, FREQ, FWCOV, RVCOV, TOTALCOV, RATIO) and `[sam-file].xml` (per-position `<Depth>`, `<FwCover>`, `<RvCover>`, `<Variants>`).
38
+
39
+ ## Package API
40
+
41
+ Import `aa_caller` to reuse the core objects:
42
+
43
+ ```python
44
+ from aa_caller import SamContainer, FullReference, parse_amplicons
45
+ ```
46
+
47
+ The `SamContainer` constructor still accepts `ratio_upper`, `ratio_lower`, and `entropy_threshold` so you can reuse the balancing logic in scripts.
48
+
49
+ ### Python wrapper
50
+
51
+ Use `call_variants` to run the full pipeline from Python without touching the CLI. It validates the inputs, builds the `SamContainer`, and writes the TSV/XML artifacts while returning a `VariantCallResult` you can inspect.
52
+
53
+ ```python
54
+ from pathlib import Path
55
+
56
+ from aa_caller import call_variants
57
+
58
+ result = call_variants(
59
+ sam_path=Path("reads.sam"),
60
+ reference_path=Path("reference.fasta"),
61
+ amplicons_path=Path("amps.tsv"),
62
+ ratio_upper=3.2,
63
+ )
64
+
65
+ print(result.csv_path, result.xml_path)
66
+ print(result.container.variants.keys())
67
+ ```
68
+
69
+ If you already have an `argparse.Namespace` or mapping of the CLI arguments, `call_variants_from_args` adapts them directly.
70
+
71
+ ```python
72
+ from argparse import Namespace
73
+
74
+ args = Namespace(
75
+ sam_file="reads.sam",
76
+ reference_file="reference.fasta",
77
+ amplicons_file="amps.tsv",
78
+ ratio_upper=3.2,
79
+ )
80
+
81
+ call_variants_from_args(args)
82
+ ```
83
+
84
+ ### CLI wrapper
85
+
86
+ This repository installs a lightweight runner at `codonyat-runner` that exposes the same entry arguments as `call_variants_from_args`. Use it when you prefer a small CLI shim over the full `codonyat` entry point:
87
+
88
+ ```bash
89
+ codonyat-runner reads.sam reference.fasta amps.tsv --ratio-upper 3.1 --csv-path results.tsv
90
+ ```
91
+
92
+ ## Development
93
+
94
+ Install the repository with the optional dev tooling so your local environment matches CI:
95
+
96
+ ```bash
97
+ pip install --upgrade pip
98
+ pip install -e .[dev]
99
+ ```
100
+
101
+ Now you can run the same checks that land in [.github/workflows/python-tests.yml](.github/workflows/python-tests.yml#L1-L27):
102
+
103
+ ```bash
104
+ ruff check .
105
+ python -m pytest
106
+ ```
107
+
108
+ The workflow installs `pytest` and `ruff`, runs the linter, and then executes the pytest suite on every push/PR against `main`.
109
+
110
+ ## Testing
111
+
112
+ Run the upstream validation helpers with `pytest`:
113
+
114
+ ```bash
115
+ python -m pytest
116
+ ```
117
+
118
+ Keep the code tidy with `ruff` before committing:
119
+
120
+ ```bash
121
+ ruff check .
122
+ ```
@@ -0,0 +1,16 @@
1
+ """Light wrapper to expose the RT variant caller as a package."""
2
+
3
+ from .app import main, FullReference, SamContainer, SamEntry, parse_amplicons
4
+ from .runner import VariantCallResult, call_variants, call_variants_from_args, runner_cli
5
+
6
+ __all__ = [
7
+ "call_variants",
8
+ "call_variants_from_args",
9
+ "runner_cli",
10
+ "VariantCallResult",
11
+ "main",
12
+ "FullReference",
13
+ "SamContainer",
14
+ "SamEntry",
15
+ "parse_amplicons",
16
+ ]
@@ -0,0 +1,4 @@
1
+ from .app import main
2
+
3
+ if __name__ == "__main__":
4
+ main()