annostat 1.0.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.
- annostat-1.0.0/LICENSE +21 -0
- annostat-1.0.0/PKG-INFO +539 -0
- annostat-1.0.0/README.md +494 -0
- annostat-1.0.0/annostat/__init__.py +3 -0
- annostat-1.0.0/annostat/__main__.py +7 -0
- annostat-1.0.0/annostat/analysis.py +129 -0
- annostat-1.0.0/annostat/cli.py +890 -0
- annostat-1.0.0/annostat/cohort.py +196 -0
- annostat-1.0.0/annostat/comparison.py +545 -0
- annostat-1.0.0/annostat/filtering.py +69 -0
- annostat-1.0.0/annostat/models.py +61 -0
- annostat-1.0.0/annostat/ncbi.py +129 -0
- annostat-1.0.0/annostat/output.py +114 -0
- annostat-1.0.0/annostat/parsers.py +151 -0
- annostat-1.0.0/annostat/plots.py +358 -0
- annostat-1.0.0/annostat/qc.py +499 -0
- annostat-1.0.0/annostat/report.py +182 -0
- annostat-1.0.0/annostat/sequences.py +356 -0
- annostat-1.0.0/annostat/validation.py +532 -0
- annostat-1.0.0/annostat.egg-info/PKG-INFO +539 -0
- annostat-1.0.0/annostat.egg-info/SOURCES.txt +26 -0
- annostat-1.0.0/annostat.egg-info/dependency_links.txt +1 -0
- annostat-1.0.0/annostat.egg-info/entry_points.txt +2 -0
- annostat-1.0.0/annostat.egg-info/top_level.txt +1 -0
- annostat-1.0.0/pyproject.toml +35 -0
- annostat-1.0.0/setup.cfg +4 -0
- annostat-1.0.0/tests/test_annostat.py +840 -0
- annostat-1.0.0/tests/test_validation.py +430 -0
annostat-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Annostat 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.
|
annostat-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,539 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: annostat
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Analyze bacterial genome annotations from GFF3 and FASTA files
|
|
5
|
+
License: MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2026 Annostat contributors
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
Project-URL: Repository, https://github.com/Karudhoru/annostat
|
|
28
|
+
Project-URL: Issues, https://github.com/Karudhoru/annostat/issues
|
|
29
|
+
Keywords: bioinformatics,genome-annotation,gff3,fasta,quality-control
|
|
30
|
+
Classifier: Development Status :: 4 - Beta
|
|
31
|
+
Classifier: Environment :: Console
|
|
32
|
+
Classifier: Intended Audience :: Science/Research
|
|
33
|
+
Classifier: Operating System :: OS Independent
|
|
34
|
+
Classifier: Programming Language :: Python :: 3
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
40
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
41
|
+
Requires-Python: >=3.10
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
License-File: LICENSE
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
|
|
46
|
+
# Annostat
|
|
47
|
+
|
|
48
|
+
**Annostat** analyzes bacterial genome annotations from matching GFF3 and FASTA
|
|
49
|
+
files. Local analysis uses only the Python standard library and supports multi-record FASTA files.
|
|
50
|
+
|
|
51
|
+
## Features
|
|
52
|
+
|
|
53
|
+
- Counts CDS, RNA types, all feature types, hypothetical proteins, gene annotations,
|
|
54
|
+
and CDS with COG categories
|
|
55
|
+
- Exports a compact feature overview as CSV or TSV
|
|
56
|
+
- Extracts every CDS on the correct strand as nucleotide and amino-acid multi-FASTA
|
|
57
|
+
- Calculates codon usage percentages, start-codon counts, and individual COG category counts
|
|
58
|
+
- Reports GC content, coding density, CDS overlaps and containment, pseudogenes,
|
|
59
|
+
partial features, structural-RNA completeness, frame issues, and ambiguous bases
|
|
60
|
+
- Supports optional CDS exports filtered by length, COG annotation, and
|
|
61
|
+
hypothetical-protein status without changing the complete analysis
|
|
62
|
+
- Builds a self-contained offline HTML report with provenance and performance timings
|
|
63
|
+
- Saves three focused, dependency-free SVG charts for COG categories, CDS lengths,
|
|
64
|
+
and table-aware start codons; the COG chart is omitted when the source has no
|
|
65
|
+
COG data
|
|
66
|
+
- Streams CDS processing and FASTA generation to reduce runtime and peak memory
|
|
67
|
+
- Compares two or more local or NCBI-hosted annotations using normalized genome,
|
|
68
|
+
annotation-completeness, COG, start-codon, and QC profiles
|
|
69
|
+
- Reports pairwise Jensen-Shannon profile distances and exact gene-symbol/COG-ID
|
|
70
|
+
overlap without presenting annotation labels as inferred orthologs
|
|
71
|
+
- Downloads versioned RefSeq or GenBank assemblies through the official NCBI
|
|
72
|
+
Datasets command-line tool when network connectivity is requested
|
|
73
|
+
- Separates deterministic FASTA/GFF3 validation from biological inspection, with
|
|
74
|
+
stable rule IDs, severity levels, schema/ruleset versions, and source citations
|
|
75
|
+
- Records SHA-256 hashes for reproducibility and writes canonical JSON plus TSV
|
|
76
|
+
validation results suitable for CI pipelines
|
|
77
|
+
- Correctly joins repeated-ID multipart CDS features in biological order on both
|
|
78
|
+
strands and validates phase continuity before translation
|
|
79
|
+
- Supports NCBI prokaryotic translation tables 4, 11, and 25, automatically
|
|
80
|
+
selecting a consistent CDS or `region` `transl_table` declaration when present
|
|
81
|
+
- Applies position-specific NCBI `transl_except` annotations for selenocysteine,
|
|
82
|
+
pyrrolysine, explicitly annotated termination codons, and `OTHER` residues
|
|
83
|
+
represented conservatively as `X`
|
|
84
|
+
- Aggregates completed inspections into a script-free cohort HTML report,
|
|
85
|
+
normalized TSV matrix, and machine-readable JSON
|
|
86
|
+
|
|
87
|
+
## Required and optional components
|
|
88
|
+
|
|
89
|
+
| Component | Status | Purpose |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| Python 3.10 or newer | Required | Runs Annostat and its test suite |
|
|
92
|
+
| Genome FASTA (`.fna`, `.fa`, or `.fasta`) | Required | Supplies the genome sequences |
|
|
93
|
+
| Matching GFF3 annotation (`.gff` or `.gff3`) | Required | Supplies feature coordinates and annotations |
|
|
94
|
+
| Matching FASTA/GFF3 sequence identifiers | Required | Connects every annotated feature to its sequence |
|
|
95
|
+
| NCBI Datasets CLI | Optional | Downloads GCF/GCA assemblies for `fetch` or `compare --reference` |
|
|
96
|
+
| Internet connection | Optional | Needed only when downloading NCBI data |
|
|
97
|
+
|
|
98
|
+
No third-party Python package is required for local analysis, report generation,
|
|
99
|
+
tables, FASTA exports, or SVG plots.
|
|
100
|
+
|
|
101
|
+
## Core functionality
|
|
102
|
+
|
|
103
|
+
Annostat provides the following core analysis outputs:
|
|
104
|
+
|
|
105
|
+
- Counts CDS, RNA features by type, hypothetical CDS, CDS with gene names, CDS
|
|
106
|
+
with COG categories, and other feature types.
|
|
107
|
+
- Writes a CSV or TSV feature overview containing ID, type, start, stop, gene,
|
|
108
|
+
product, and strand, with missing values left empty.
|
|
109
|
+
- Exports all CDS as nucleotide and translated amino-acid multi-FASTA files.
|
|
110
|
+
- Calculates pooled codon usage percentages, start-codon counts, and detailed
|
|
111
|
+
COG-category statistics, including multi-category assignments.
|
|
112
|
+
- Generates at least two meaningful scientific plots; a normal run produces CDS
|
|
113
|
+
length, start-codon, and—when available—COG-category SVG figures.
|
|
114
|
+
- Provides an `argparse` command-line interface and modular Python structure with
|
|
115
|
+
documented functions, classes, and methods.
|
|
116
|
+
|
|
117
|
+
Filtering, quality control, HTML reports, performance profiling, comparative
|
|
118
|
+
analysis, cohort summaries, and NCBI connectivity extend the core workflow.
|
|
119
|
+
|
|
120
|
+
## Input assumptions and scope
|
|
121
|
+
|
|
122
|
+
- GFF3 records must contain nine tab-separated fields with 1-based inclusive
|
|
123
|
+
coordinates. The FASTA identifier is the first whitespace-delimited header token.
|
|
124
|
+
- CDS strand and phase are honored. Circular-origin CDS coordinates extending past
|
|
125
|
+
the sequence length are supported when a `region` feature declares
|
|
126
|
+
`Is_circular=true`.
|
|
127
|
+
- Repeated CDS IDs are interpreted as one multipart biological feature. Segments
|
|
128
|
+
must use the same sequence ID, strand, and Parent; phase continuity is checked,
|
|
129
|
+
and segments are joined in biological order before translation.
|
|
130
|
+
- COG coverage describes categories actually present in the annotation source. An
|
|
131
|
+
annotation with no COG category fields is reported as unavailable, not as 0%.
|
|
132
|
+
- Annostat uses the consistent CDS or `region` `transl_table` declared in GFF3.
|
|
133
|
+
When the annotation declares no table, it falls back to bacterial table 11. `--genetic-code` is an
|
|
134
|
+
explicit override for annotations without that metadata; an override that
|
|
135
|
+
conflicts with a declared table is rejected instead of silently mistranslating
|
|
136
|
+
CDS features. Annostat never guesses a genetic code from sequence composition.
|
|
137
|
+
|
|
138
|
+
## Installation
|
|
139
|
+
|
|
140
|
+
Annostat requires Python 3.10 or newer and has no third-party runtime
|
|
141
|
+
dependencies. Clone the repository and create an isolated environment.
|
|
142
|
+
|
|
143
|
+
Linux or WSL:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
git clone https://github.com/Karudhoru/annostat.git
|
|
147
|
+
cd annostat
|
|
148
|
+
python3 -m venv .venv
|
|
149
|
+
source .venv/bin/activate
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Windows PowerShell:
|
|
153
|
+
|
|
154
|
+
```powershell
|
|
155
|
+
git clone https://github.com/Karudhoru/annostat.git
|
|
156
|
+
Set-Location annostat
|
|
157
|
+
py -3 -m venv .venv
|
|
158
|
+
.\.venv\Scripts\Activate.ps1
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Install the current release from the checkout and verify the executable:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
python -m pip install .
|
|
165
|
+
annostat --version
|
|
166
|
+
annostat --help
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Expected version output:
|
|
170
|
+
|
|
171
|
+
```text
|
|
172
|
+
Annostat 1.0.0
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Contributors should use `python -m pip install -e .` so source changes take
|
|
176
|
+
effect without reinstalling. If the executable is unavailable, the equivalent
|
|
177
|
+
module form is `python -m annostat`.
|
|
178
|
+
|
|
179
|
+
## Quick-start guide
|
|
180
|
+
|
|
181
|
+
### 1. Check the inputs
|
|
182
|
+
|
|
183
|
+
Confirm that you have one genome FASTA and its matching GFF3 annotation. Sequence
|
|
184
|
+
IDs must agree—for example, a FASTA record named `chromosome` must be referenced
|
|
185
|
+
as `chromosome` in the first GFF3 column.
|
|
186
|
+
|
|
187
|
+
### 2. Validate the paired files
|
|
188
|
+
|
|
189
|
+
Run deterministic integrity checks before biological interpretation:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
annostat validate \
|
|
193
|
+
-f data/GCF_000007145.1.fna \
|
|
194
|
+
-g data/GCF_000007145.1.gff3 \
|
|
195
|
+
-o validation
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Example output for the included dataset:
|
|
199
|
+
|
|
200
|
+
```text
|
|
201
|
+
Annostat 1.0.0 | annotation validation PASS
|
|
202
|
+
Errors 0
|
|
203
|
+
Warnings 0
|
|
204
|
+
Findings 0
|
|
205
|
+
Files written 2
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
The command writes `validation.json` and `validation.tsv`. Exit status `0` means
|
|
209
|
+
no structural errors were found; status `1` means the configured threshold was
|
|
210
|
+
reached. Use `--fail-on warning` for strict CI, or `--fail-on never` when the
|
|
211
|
+
report should never stop a pipeline. A validation pass means the paired files are
|
|
212
|
+
internally interpretable; it does not prove that every biological annotation is
|
|
213
|
+
correct.
|
|
214
|
+
|
|
215
|
+
### 3. Inspect one annotation
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
annostat inspect \
|
|
219
|
+
-f data/GCF_000007145.1.fna \
|
|
220
|
+
-g data/GCF_000007145.1.gff3 \
|
|
221
|
+
-o results \
|
|
222
|
+
--table-format tsv
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Here `-f` selects the required FASTA, `-g` selects the required GFF3, and `-o`
|
|
226
|
+
chooses the output directory. Add `--table-format tsv` when a TSV overview is
|
|
227
|
+
preferred over CSV. The original command without the `inspect` word remains a
|
|
228
|
+
backward-compatible alias. Translation-table selection is automatic when the
|
|
229
|
+
GFF3 CDS or `region` rows contain `transl_table`; otherwise table 11 is used.
|
|
230
|
+
The included example produces a 5,076,188 bp analysis with 4,295 CDS. For a local
|
|
231
|
+
annotation without translation-table metadata, select a supported table explicitly
|
|
232
|
+
with `--genetic-code 4`, `--genetic-code 11`, or `--genetic-code 25`.
|
|
233
|
+
|
|
234
|
+
### 4. Review the result package
|
|
235
|
+
|
|
236
|
+
Open `results/report.html` in a browser first. Then use:
|
|
237
|
+
|
|
238
|
+
- `summary.json` for the complete machine-readable summary;
|
|
239
|
+
- `tables/` for feature, codon, COG, start-codon, and QC data;
|
|
240
|
+
- `sequences/` for nucleotide and protein CDS FASTA files; and
|
|
241
|
+
- `plots/` for editable SVG figures.
|
|
242
|
+
|
|
243
|
+
### 5. Summarize a cohort
|
|
244
|
+
|
|
245
|
+
After inspecting several genomes into separate result directories, list those
|
|
246
|
+
directories explicitly or pass their common parent directory:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
annostat summarize results/sample-a results/sample-b -o cohort
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
The output contains `cohort.html`, `cohort.tsv`, and `cohort.json`. Samples are
|
|
253
|
+
ordered deterministically. Missing source-dependent values such as COG coverage
|
|
254
|
+
remain `NA`/`null`, never biological zero. Multiple source Annostat versions are
|
|
255
|
+
retained and flagged in the report.
|
|
256
|
+
|
|
257
|
+
## Common workflows
|
|
258
|
+
|
|
259
|
+
The following sections show filtered exports, comparative analysis, NCBI
|
|
260
|
+
references, performance profiling, and complete output descriptions.
|
|
261
|
+
|
|
262
|
+
Without installing, module execution remains available from the repository root:
|
|
263
|
+
`python -m annostat --help`.
|
|
264
|
+
|
|
265
|
+
Use `--table-format tsv` for a tab-separated feature overview. Add `--profile`
|
|
266
|
+
to measure peak Python memory and print per-stage timings.
|
|
267
|
+
|
|
268
|
+
### Filtered CDS exports
|
|
269
|
+
|
|
270
|
+
Filters create an additional `filtered/` directory while retaining every normal
|
|
271
|
+
analysis file. Criteria are combined, so a CDS must satisfy all enabled options:
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
annostat \
|
|
275
|
+
-f genome.fna \
|
|
276
|
+
-g annotations.gff3 \
|
|
277
|
+
-o results \
|
|
278
|
+
--min-cds-length 300 \
|
|
279
|
+
--require-cog \
|
|
280
|
+
--exclude-hypothetical
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Available criteria are `--min-cds-length`, `--max-cds-length`, `--require-cog`,
|
|
284
|
+
and `--exclude-hypothetical`.
|
|
285
|
+
|
|
286
|
+
### Comparative analysis
|
|
287
|
+
|
|
288
|
+
Compare two or more labelled local genomes with repeatable `--genome` options:
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
annostat compare \
|
|
292
|
+
--genome genome-a data/GCF_000007145.1.fna data/GCF_000007145.1.gff3 \
|
|
293
|
+
--genome genome-b data/GCF_001050915.2.fna data/GCF_001050915.2.gff3 \
|
|
294
|
+
--output comparison
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Each genome is structurally validated and independently uses its declared
|
|
298
|
+
`transl_table` or the table-11 fallback. For an annotation without
|
|
299
|
+
`transl_table`, a per-genome override uses
|
|
300
|
+
the same label supplied to `--genome` (or the reference accession):
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
annostat compare \
|
|
304
|
+
--genome sr1 sr1.fna sr1.gff3 \
|
|
305
|
+
--genome ecoli ecoli.fna ecoli.gff3 \
|
|
306
|
+
--genetic-code sr1 25 \
|
|
307
|
+
--output comparison
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
The comparison package is intentionally compact:
|
|
311
|
+
|
|
312
|
+
```text
|
|
313
|
+
comparison/
|
|
314
|
+
|-- comparison.html
|
|
315
|
+
|-- comparison.json
|
|
316
|
+
|-- tables/
|
|
317
|
+
| |-- dataset_metrics.tsv
|
|
318
|
+
| `-- pairwise_comparisons.tsv
|
|
319
|
+
`-- plots/
|
|
320
|
+
|-- dataset_overview.svg
|
|
321
|
+
`-- cog_comparison.svg (only when every input supplies COG categories)
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
`dataset_metrics.tsv` provides raw genome/feature counts together with GC,
|
|
325
|
+
coding density, CDS per Mb, annotation coverage, start-codon usage, and QC
|
|
326
|
+
warnings. `pairwise_comparisons.tsv` contains metric deltas, percentage deltas,
|
|
327
|
+
Jensen-Shannon distances for COG and start-codon profiles, and Jaccard overlap
|
|
328
|
+
for exact gene symbols and explicit COG identifiers.
|
|
329
|
+
|
|
330
|
+
For two datasets, the COG figure shows percentage-point differences. For three
|
|
331
|
+
or more datasets, it becomes a dataset-by-category heatmap. Exact gene-symbol
|
|
332
|
+
overlap describes annotation labels only; it is not orthology, ANI, phylogeny,
|
|
333
|
+
or a core/accessory pangenome analysis.
|
|
334
|
+
|
|
335
|
+
### Compare against external NCBI data
|
|
336
|
+
|
|
337
|
+
NCBI access is optional and uses NCBI's maintained `datasets` executable. Follow
|
|
338
|
+
the official [installation instructions](https://www.ncbi.nlm.nih.gov/datasets/docs/v2/command-line-tools/download-and-install/),
|
|
339
|
+
then add an external reference directly to a local comparison:
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
annostat compare \
|
|
343
|
+
--genome local-sample sample.fna sample.gff3 \
|
|
344
|
+
--reference GCF_000007145.1 \
|
|
345
|
+
--output comparison
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
`--reference` is repeatable, so a comparison may contain only external
|
|
349
|
+
assemblies or any mixture of local and NCBI inputs. Annostat downloads genome
|
|
350
|
+
FASTA, GFF3, and assembly metadata under `comparison/external_inputs/`, then
|
|
351
|
+
runs every input through the same comparison engine:
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
annostat compare \
|
|
355
|
+
--reference GCF_000007145.1 \
|
|
356
|
+
--reference GCF_001050915.2 \
|
|
357
|
+
--output comparison
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
The report identifies organisms and whether each pair belongs to the same or
|
|
361
|
+
different species when the input metadata makes that determination possible.
|
|
362
|
+
It never assumes that labelled datasets are strains. NCBI assembly names,
|
|
363
|
+
taxonomy identifiers, annotation providers, and release metadata are retained
|
|
364
|
+
in `comparison.json`. Versioned GCF/GCA accessions in the HTML provenance table
|
|
365
|
+
link to their NCBI Datasets assembly pages.
|
|
366
|
+
|
|
367
|
+
COG results are source-dependent. Bakta annotations commonly include COG
|
|
368
|
+
categories, while current NCBI RefSeq GFF3 packages may not. When a source does
|
|
369
|
+
not supply COG fields, Annostat reports COG coverage and pairwise COG statistics
|
|
370
|
+
as `Not available` and omits the COG comparison plot; missing data is never
|
|
371
|
+
presented as biological zero coverage.
|
|
372
|
+
|
|
373
|
+
For users who only need the source files, the standalone downloader remains
|
|
374
|
+
available:
|
|
375
|
+
|
|
376
|
+
```bash
|
|
377
|
+
annostat fetch GCF_000007145.1 GCF_001050915.2 --output ncbi_data
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
The `NCBI_API_KEY` environment variable is honored by the official client. Local
|
|
381
|
+
analysis never requires a network connection, and Annostat does not transmit
|
|
382
|
+
local FASTA or GFF3 files.
|
|
383
|
+
|
|
384
|
+
The output directory contains:
|
|
385
|
+
|
|
386
|
+
```text
|
|
387
|
+
results/
|
|
388
|
+
├── report.html
|
|
389
|
+
├── summary.json
|
|
390
|
+
├── tables/
|
|
391
|
+
│ ├── features.csv (or features.tsv)
|
|
392
|
+
│ ├── codon_usage.csv
|
|
393
|
+
│ ├── start_codons.csv
|
|
394
|
+
│ ├── cog_categories.csv
|
|
395
|
+
│ └── annotation_issues.csv
|
|
396
|
+
├── validation/
|
|
397
|
+
│ ├── validation.json
|
|
398
|
+
│ └── validation.tsv
|
|
399
|
+
├── sequences/
|
|
400
|
+
│ ├── cds_nucleotide.fasta
|
|
401
|
+
│ └── cds_protein.fasta
|
|
402
|
+
└── plots/
|
|
403
|
+
├── cog_categories.svg (when COG categories are available)
|
|
404
|
+
├── cds_lengths.svg
|
|
405
|
+
└── start_codons.svg
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
When filters are active, `filtered/` additionally contains the selected feature
|
|
409
|
+
table and paired nucleotide/protein FASTA files.
|
|
410
|
+
|
|
411
|
+
`report.html` works without a server or internet connection and embeds the SVG
|
|
412
|
+
figures directly. The separate SVG files remain available for editing and use in
|
|
413
|
+
documents. Codon usage remains available as the required percentage table; a
|
|
414
|
+
dense 64-codon heatmap is intentionally not generated by default.
|
|
415
|
+
|
|
416
|
+
`annotation_issues.csv` is a review aid rather than an automatic pass/fail
|
|
417
|
+
verdict. Short CDS overlaps are common in compact bacterial genomes, so ordinary
|
|
418
|
+
overlaps and adjacent duplicate labels are informational. Containment, incomplete
|
|
419
|
+
frames, missing structural RNA classes, internal stops, and ambiguous bases are
|
|
420
|
+
reported as warnings that merit inspection in their biological context.
|
|
421
|
+
|
|
422
|
+
## Validation versus inspection
|
|
423
|
+
|
|
424
|
+
`annostat validate` answers whether the files can be interpreted consistently:
|
|
425
|
+
GFF3 syntax, FASTA symbols, matching sequence IDs, coordinate bounds, Parent/ID
|
|
426
|
+
relationships, multipart-feature consistency, CDS phase continuity, and valid,
|
|
427
|
+
consistent CDS translation-table declarations. These checks are deterministic
|
|
428
|
+
and may safely control a CI exit status.
|
|
429
|
+
|
|
430
|
+
`annostat inspect` first requires structural validation to pass, then reports
|
|
431
|
+
biological review candidates such as internal stops, missing terminal codons,
|
|
432
|
+
ambiguous CDS bases, overlaps, partial features, pseudogenes, duplicated adjacent
|
|
433
|
+
labels, and structural-RNA coverage. These findings are context-dependent and do
|
|
434
|
+
not automatically make an annotation invalid. Boundary-specific partial markers
|
|
435
|
+
suppress only the affected start- or stop-codon assumption. Explicit `pseudo`,
|
|
436
|
+
`transl_except`, and `exception` annotations suppress checks whose assumptions do
|
|
437
|
+
not apply.
|
|
438
|
+
|
|
439
|
+
Every validation result embeds its rule definitions, rationale, source URL,
|
|
440
|
+
ruleset version, schema version, Annostat version, and input SHA-256 hashes. JSON
|
|
441
|
+
and TSV findings use canonical ordering and contain no timestamp, so repeated runs
|
|
442
|
+
on identical paths and bytes produce byte-identical validation artifacts. A
|
|
443
|
+
`scientific_fingerprint` in both validation and inspection JSON excludes file
|
|
444
|
+
paths and performance timings, allowing scientific results to be compared across
|
|
445
|
+
machines and output directories.
|
|
446
|
+
|
|
447
|
+
## Testing and verification
|
|
448
|
+
|
|
449
|
+
Run compilation and all automated tests with the interpreter used to install
|
|
450
|
+
Annostat:
|
|
451
|
+
|
|
452
|
+
```bash
|
|
453
|
+
python -m compileall -q annostat tests
|
|
454
|
+
python -m unittest discover -v
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
For a final end-to-end check, analyze one supplied genome and confirm that
|
|
458
|
+
`results/report.html`, `results/summary.json`, the tables, FASTA exports, and SVG
|
|
459
|
+
plots are created:
|
|
460
|
+
|
|
461
|
+
```bash
|
|
462
|
+
annostat inspect \
|
|
463
|
+
-f data/GCF_000007145.1.fna \
|
|
464
|
+
-g data/GCF_000007145.1.gff3 \
|
|
465
|
+
-o results \
|
|
466
|
+
--table-format tsv
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
## Example run
|
|
470
|
+
|
|
471
|
+
```bash
|
|
472
|
+
annostat inspect \
|
|
473
|
+
-f data/GCF_000007145.1.fna \
|
|
474
|
+
-g data/GCF_000007145.1.gff3 \
|
|
475
|
+
-o results \
|
|
476
|
+
--table-format tsv
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
Example output:
|
|
480
|
+
|
|
481
|
+
```text
|
|
482
|
+
Annostat 1.0.0 | bacterial genome annotation analysis
|
|
483
|
+
FASTA: /path/to/annostat/data/GCF_000007145.1.fna
|
|
484
|
+
GFF3: /path/to/annostat/data/GCF_000007145.1.gff3
|
|
485
|
+
|
|
486
|
+
[1/5] Reading GFF3 annotations and FASTA sequences
|
|
487
|
+
[2/5] Streaming, translating, and writing CDS sequences
|
|
488
|
+
[3/5] Calculating statistics and writing analysis tables
|
|
489
|
+
[4/5] Rendering scientific visualizations
|
|
490
|
+
[5/5] Building the offline HTML report
|
|
491
|
+
|
|
492
|
+
Analysis summary
|
|
493
|
+
--------------------------------------------------------
|
|
494
|
+
Genome size 5,076,188 bp
|
|
495
|
+
Sequences 1 (1 circular)
|
|
496
|
+
Features 4,498
|
|
497
|
+
CDS 4,295
|
|
498
|
+
RNA features 181
|
|
499
|
+
Genome GC 65.07%
|
|
500
|
+
Coding density 85.33%
|
|
501
|
+
Hypothetical CDS 619 (14.41%)
|
|
502
|
+
COG-annotated CDS 2,881 (67.08%)
|
|
503
|
+
Recognized starts 4,294 (99.98%)
|
|
504
|
+
QC review 1 warning, 872 informational findings
|
|
505
|
+
--------------------------------------------------------
|
|
506
|
+
Output /path/to/annostat/results
|
|
507
|
+
Files written 14
|
|
508
|
+
Completed in 0.56 seconds
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
Runtime depends on the input size and system. The supplied bacterial genome
|
|
512
|
+
typically completes in under a second on a modern desktop. Use `--profile` when
|
|
513
|
+
you need measured stage timings and peak-memory information; profiling itself
|
|
514
|
+
adds overhead and should not be used for speed benchmarks.
|
|
515
|
+
|
|
516
|
+
## Scientific basis
|
|
517
|
+
|
|
518
|
+
The QC checks follow the internal-consistency emphasis of the
|
|
519
|
+
[NCBI Prokaryotic Genome Annotation Standards](https://www.ncbi.nlm.nih.gov/refseq/annotation_prok/standards/)
|
|
520
|
+
and the attribute conventions in the
|
|
521
|
+
[NCBI GFF3 documentation](https://www.ncbi.nlm.nih.gov/datasets/docs/v2/reference-docs/file-formats/annotation-files/about-ncbi-gff3/).
|
|
522
|
+
FASTA validation accepts the NCBI/IUPAC nucleotide alphabet, and translation
|
|
523
|
+
tables and initiator codons follow the
|
|
524
|
+
[NCBI Genetic Codes](https://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi).
|
|
525
|
+
The report treats overlaps as review candidates because overlapping genes are
|
|
526
|
+
common in compact bacterial genomes. Translation uses the bacterial code and
|
|
527
|
+
alternative-start behavior described by
|
|
528
|
+
[Prodigal](https://pmc.ncbi.nlm.nih.gov/articles/PMC2848648/). The project remains
|
|
529
|
+
an annotation-analysis tool rather than a replacement for comprehensive
|
|
530
|
+
annotation pipelines such as
|
|
531
|
+
[Bakta](https://pmc.ncbi.nlm.nih.gov/articles/PMC8743544/) or
|
|
532
|
+
[Prokka](https://pubmed.ncbi.nlm.nih.gov/24642063/).
|
|
533
|
+
|
|
534
|
+
Comparative profiles are normalized to avoid treating larger genomes as
|
|
535
|
+
automatically enriched. Full ortholog and pangenome inference remains the domain
|
|
536
|
+
of tools such as [Panaroo](https://pmc.ncbi.nlm.nih.gov/articles/PMC7376924/),
|
|
537
|
+
while sequence-level average nucleotide identity should be calculated by a
|
|
538
|
+
specialized implementation such as
|
|
539
|
+
[FastANI](https://pmc.ncbi.nlm.nih.gov/articles/PMC6269478/).
|