hyphaeon-core 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.
Files changed (29) hide show
  1. hyphaeon_core-0.1.0/LICENSE +21 -0
  2. hyphaeon_core-0.1.0/PKG-INFO +51 -0
  3. hyphaeon_core-0.1.0/README.md +23 -0
  4. hyphaeon_core-0.1.0/pyproject.toml +43 -0
  5. hyphaeon_core-0.1.0/setup.cfg +4 -0
  6. hyphaeon_core-0.1.0/src/aeon_core/__init__.py +51 -0
  7. hyphaeon_core-0.1.0/src/aeon_core/_progress.py +81 -0
  8. hyphaeon_core-0.1.0/src/aeon_core/dataset.py +1128 -0
  9. hyphaeon_core-0.1.0/src/aeon_core/inference.py +200 -0
  10. hyphaeon_core-0.1.0/src/aeon_core/io.py +49 -0
  11. hyphaeon_core-0.1.0/src/aeon_core/model.py +758 -0
  12. hyphaeon_core-0.1.0/src/aeon_core/splits.py +214 -0
  13. hyphaeon_core-0.1.0/src/aeon_core/stats.py +84 -0
  14. hyphaeon_core-0.1.0/src/aeon_core/temporal.py +192 -0
  15. hyphaeon_core-0.1.0/src/aeon_core/weights.py +285 -0
  16. hyphaeon_core-0.1.0/src/hyphaeon_core.egg-info/PKG-INFO +51 -0
  17. hyphaeon_core-0.1.0/src/hyphaeon_core.egg-info/SOURCES.txt +27 -0
  18. hyphaeon_core-0.1.0/src/hyphaeon_core.egg-info/dependency_links.txt +1 -0
  19. hyphaeon_core-0.1.0/src/hyphaeon_core.egg-info/requires.txt +13 -0
  20. hyphaeon_core-0.1.0/src/hyphaeon_core.egg-info/top_level.txt +1 -0
  21. hyphaeon_core-0.1.0/tests/test_dataset.py +143 -0
  22. hyphaeon_core-0.1.0/tests/test_imports.py +28 -0
  23. hyphaeon_core-0.1.0/tests/test_load_alignment.py +135 -0
  24. hyphaeon_core-0.1.0/tests/test_model.py +56 -0
  25. hyphaeon_core-0.1.0/tests/test_parsing.py +162 -0
  26. hyphaeon_core-0.1.0/tests/test_splits.py +92 -0
  27. hyphaeon_core-0.1.0/tests/test_stats.py +188 -0
  28. hyphaeon_core-0.1.0/tests/test_temporal.py +79 -0
  29. hyphaeon_core-0.1.0/tests/test_weights.py +248 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sergei L. Kosakovsky Pond and HyphAeon 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,51 @@
1
+ Metadata-Version: 2.4
2
+ Name: hyphaeon-core
3
+ Version: 0.1.0
4
+ Summary: Aeon-Core: Shared bioinformatics infrastructure for Aeon-family packages
5
+ Author-email: "Sergei L. Kosakovsky Pond" <spond@temple.edu>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/veg/HyphAeon
8
+ Project-URL: Bug Tracker, https://github.com/veg/HyphAeon/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: torch>=2.0.0
17
+ Requires-Dist: biopython>=1.80
18
+ Requires-Dist: numpy>=1.22.0
19
+ Requires-Dist: scipy>=1.9.0
20
+ Requires-Dist: pandas>=1.5.0
21
+ Requires-Dist: huggingface-hub>=0.20.0
22
+ Requires-Dist: safetensors>=0.4.0
23
+ Provides-Extra: tn93
24
+ Requires-Dist: tn93>=1.2.0; extra == "tn93"
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=7.0; extra == "dev"
27
+ Dynamic: license-file
28
+
29
+ # aeon-core
30
+
31
+ Shared infrastructure for the HyphAeon family of packages (HyphAeon, ChronAeon).
32
+
33
+ Contains the `PhyloAxialTransformer` foundation model, pretrained weight resolution (HuggingFace Hub), and core utilities for alignment processing, inference, spectral splits, temporal parsing, I/O, and statistics.
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ pip install hyphaeon-core
39
+ ```
40
+
41
+ ## Components
42
+
43
+ - **`model`** — `PhyloAxialTransformer`, `BustedMultiTaskHead`, `decode_soft_ordinal_lrt`
44
+ - **`weights`** — Weight resolution from HuggingFace Hub (`datamonkey/hyphaeon`), safetensors loading
45
+ - **`inference`** — Device management, adaptive batch sizing, model loading, alignment preparation
46
+ - **`dataset`** — Alignment parsing, TN93 distance matrices, tree handling, MDS coordinates
47
+ - **`splits`** — Cross-taxa attention extraction, fused affinity matrices
48
+ - **`temporal`** — Date parsing utilities (`parse_date_to_decimal`, `extract_date_from_string`)
49
+ - **`io`** — JSON/CSV writers, directory helpers
50
+ - **`stats`** — LRT p-value computation, Benjamini-Hochberg, Cauchy combination
51
+ - **`_progress`** — `ChunkProgress` progress bar utility
@@ -0,0 +1,23 @@
1
+ # aeon-core
2
+
3
+ Shared infrastructure for the HyphAeon family of packages (HyphAeon, ChronAeon).
4
+
5
+ Contains the `PhyloAxialTransformer` foundation model, pretrained weight resolution (HuggingFace Hub), and core utilities for alignment processing, inference, spectral splits, temporal parsing, I/O, and statistics.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install hyphaeon-core
11
+ ```
12
+
13
+ ## Components
14
+
15
+ - **`model`** — `PhyloAxialTransformer`, `BustedMultiTaskHead`, `decode_soft_ordinal_lrt`
16
+ - **`weights`** — Weight resolution from HuggingFace Hub (`datamonkey/hyphaeon`), safetensors loading
17
+ - **`inference`** — Device management, adaptive batch sizing, model loading, alignment preparation
18
+ - **`dataset`** — Alignment parsing, TN93 distance matrices, tree handling, MDS coordinates
19
+ - **`splits`** — Cross-taxa attention extraction, fused affinity matrices
20
+ - **`temporal`** — Date parsing utilities (`parse_date_to_decimal`, `extract_date_from_string`)
21
+ - **`io`** — JSON/CSV writers, directory helpers
22
+ - **`stats`** — LRT p-value computation, Benjamini-Hochberg, Cauchy combination
23
+ - **`_progress`** — `ChunkProgress` progress bar utility
@@ -0,0 +1,43 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "hyphaeon-core"
7
+ version = "0.1.0"
8
+ authors = [
9
+ { name="Sergei L. Kosakovsky Pond", email="spond@temple.edu" },
10
+ ]
11
+ description = "Aeon-Core: Shared bioinformatics infrastructure for Aeon-family packages"
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+ license = { text = "MIT" }
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Topic :: Scientific/Engineering :: Bio-Informatics",
20
+ ]
21
+ dependencies = [
22
+ "torch>=2.0.0",
23
+ "biopython>=1.80",
24
+ "numpy>=1.22.0",
25
+ "scipy>=1.9.0",
26
+ "pandas>=1.5.0",
27
+ "huggingface-hub>=0.20.0",
28
+ "safetensors>=0.4.0",
29
+ ]
30
+
31
+ [project.optional-dependencies]
32
+ tn93 = ["tn93>=1.2.0"]
33
+ dev = ["pytest>=7.0"]
34
+
35
+ [tool.setuptools.packages.find]
36
+ where = ["src"]
37
+
38
+ [tool.pytest.ini_options]
39
+ testpaths = ["tests"]
40
+
41
+ [project.urls]
42
+ "Homepage" = "https://github.com/veg/HyphAeon"
43
+ "Bug Tracker" = "https://github.com/veg/HyphAeon/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,51 @@
1
+ """
2
+ Aeon-Core: Shared model and bioinformatics infrastructure for Aeon-family packages.
3
+ """
4
+
5
+ from .model import PhyloAxialTransformer, BustedMultiTaskHead, decode_soft_ordinal_lrt
6
+ from .weights import (
7
+ resolve_weights_path, load_arch_config, load_weights,
8
+ load_model_config, list_available_variants, print_available_variants, get_variant_filename,
9
+ HF_REPO_ID, DEFAULT_VARIANT, CACHE_DIR,
10
+ )
11
+ from .inference import (
12
+ get_device, get_device_memory_budget,
13
+ get_live_available_memory, compute_live_adaptive_chunk_sizes,
14
+ compute_adaptive_safe_batch_size,
15
+ load_model, prepare_alignment,
16
+ )
17
+ from .splits import (
18
+ extract_cross_taxa_attentions_and_embeddings,
19
+ compute_fused_affinity_matrix,
20
+ )
21
+ from .dataset import (
22
+ GENETIC_CODE, CODON_TO_AA, AA_MAP,
23
+ get_codon_token, get_aa_token,
24
+ parse_alignment_sequences,
25
+ compute_tn93_distance_matrix,
26
+ compute_tn93_cross_distance_matrix,
27
+ parse_beast_xml,
28
+ extract_tree_from_string_or_file,
29
+ has_nonzero_branch_lengths,
30
+ estimate_tree_branch_lengths_hyphy,
31
+ enforce_nonzero_branch_lengths,
32
+ compute_fast_dist_matrix,
33
+ compute_mds_coordinates,
34
+ downsample_taxa_faith_pd,
35
+ prune_identical_sequences,
36
+ load_alignment_and_tree,
37
+ )
38
+ from .temporal import (
39
+ parse_date_to_decimal,
40
+ parse_dates_from_auspice_json,
41
+ extract_date_from_string,
42
+ )
43
+ from .io import ensure_parent_directory, write_json, write_csv, format_pq
44
+ from .stats import (
45
+ pvals_from_lrt_meme,
46
+ pvals_from_lrt_self_liang,
47
+ benjamini_hochberg,
48
+ cauchy_combination_p,
49
+ )
50
+
51
+ __version__ = "0.1.0"
@@ -0,0 +1,81 @@
1
+ """
2
+ Shared live progress bar for model-running subcommands.
3
+
4
+ A single reusable carriage-return progress bar lifted faithfully from the
5
+ filter baseline/re-eval bars (filter.py) and the DMS bar (epistasis.py). Every
6
+ per-chunk inference loop that just needs the plain "codon x/n, %, rate,
7
+ elapsed, ETA" bar should construct a ``ChunkProgress`` and call ``.update()``
8
+ per chunk and ``.finish()`` at the end.
9
+
10
+ The richer DMS-specific bar (adds mut/s + running mean plasticity Phi) stays
11
+ in ``run_insilico_selection_dms`` as-is; this generic helper covers the plain
12
+ inference loops (predict, busted single-file, disease, phenotype/epistasis
13
+ attribution).
14
+
15
+ TTY vs non-TTY behaviour mirrors the DMS bar:
16
+ * on a TTY it rewrites a single line via carriage-return + clear-to-EOL;
17
+ * otherwise it prints a fresh (flushed) line so progress is visible under
18
+ SLURM logs / pipes.
19
+ """
20
+
21
+ import sys
22
+ import time
23
+
24
+
25
+ class ChunkProgress:
26
+ """Reusable per-chunk live progress bar.
27
+
28
+ Parameters
29
+ ----------
30
+ total : int
31
+ Total number of units to process (e.g. number of variable codons).
32
+ label : str
33
+ Bracketed label shown at the start of the bar, e.g. ``"Predict"``.
34
+ unit : str
35
+ Unit name printed in the bar (default ``"codon"``).
36
+ enabled : bool
37
+ When False, all methods are no-ops (mirrors the ``progress`` flag).
38
+ """
39
+
40
+ def __init__(self, total, label, unit="codon", enabled=True):
41
+ self.total = int(total)
42
+ self.label = label
43
+ self.unit = unit
44
+ self.enabled = bool(enabled)
45
+ self.t_start = time.time()
46
+ self.is_tty = sys.stdout.isatty()
47
+
48
+ def update(self, done):
49
+ """Report ``done`` units completed; throttled to >=0.5s or completion."""
50
+ if not self.enabled:
51
+ return
52
+ now = time.time()
53
+ # Throttle refreshes to avoid flooding logs; always emit on completion.
54
+ last = getattr(self, "_last_update", None)
55
+ if last is not None and done < self.total and (now - last) < 0.5:
56
+ return
57
+ self._last_update = now
58
+
59
+ done = int(done)
60
+ pct = (done / max(1, self.total)) * 100.0
61
+ elapsed = now - self.t_start
62
+ rate = done / max(1e-3, elapsed)
63
+ eta = (self.total - done) / max(1e-3, rate)
64
+ line = (
65
+ f"[{self.label}] {self.unit} {done:5d}/{self.total:5d} "
66
+ f"({pct:5.1f}%) | {rate:6.1f} {self.unit}/s | "
67
+ f"Elapsed: {elapsed:5.1f}s | ETA: {eta:5.1f}s"
68
+ )
69
+ if self.is_tty:
70
+ sys.stdout.write("\r\033[K" + line)
71
+ sys.stdout.flush()
72
+ else:
73
+ print(line, flush=True)
74
+
75
+ def finish(self):
76
+ """Emit the trailing newline on a TTY so the bar line is not overwritten."""
77
+ if not self.enabled:
78
+ return
79
+ if self.is_tty:
80
+ sys.stdout.write("\n")
81
+ sys.stdout.flush()