aksha 0.2.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 (81) hide show
  1. aksha-0.2.1/LICENSE +21 -0
  2. aksha-0.2.1/MANIFEST.in +6 -0
  3. aksha-0.2.1/PKG-INFO +106 -0
  4. aksha-0.2.1/aksha/__init__.py +27 -0
  5. aksha-0.2.1/aksha/_launcher.py +143 -0
  6. aksha-0.2.1/aksha/gpu_profile_cache.py +475 -0
  7. aksha-0.2.1/aksha/hmm_databases.json +293 -0
  8. aksha-0.2.1/aksha/initialize.py +920 -0
  9. aksha-0.2.1/aksha/jackhmmer.py +54 -0
  10. aksha-0.2.1/aksha/main.py +172 -0
  11. aksha-0.2.1/aksha/nucsearch.py +213 -0
  12. aksha-0.2.1/aksha/phmmer.py +54 -0
  13. aksha-0.2.1/aksha/rp16.py +290 -0
  14. aksha-0.2.1/aksha/scan.py +273 -0
  15. aksha-0.2.1/aksha/search.py +5070 -0
  16. aksha-0.2.1/aksha.egg-info/PKG-INFO +106 -0
  17. aksha-0.2.1/aksha.egg-info/SOURCES.txt +79 -0
  18. aksha-0.2.1/aksha.egg-info/dependency_links.txt +1 -0
  19. aksha-0.2.1/aksha.egg-info/entry_points.txt +2 -0
  20. aksha-0.2.1/aksha.egg-info/requires.txt +8 -0
  21. aksha-0.2.1/aksha.egg-info/top_level.txt +1 -0
  22. aksha-0.2.1/docs/database-setup.md +87 -0
  23. aksha-0.2.1/native/README.md +27 -0
  24. aksha-0.2.1/native/cpu/avx512_tail.h +71 -0
  25. aksha-0.2.1/native/cpu/forward4_avx512.cpp +1817 -0
  26. aksha-0.2.1/native/cuda/README.md +23 -0
  27. aksha-0.2.1/native/cuda/backward_domain_cuda.cu +2302 -0
  28. aksha-0.2.1/native/cuda/backward_domain_cuda.h +396 -0
  29. aksha-0.2.1/native/cuda/bias_cuda.cu +895 -0
  30. aksha-0.2.1/native/cuda/bias_cuda.h +190 -0
  31. aksha-0.2.1/native/cuda/continuation_journal.h +681 -0
  32. aksha-0.2.1/native/cuda/domain_rescore_cuda.cu +3013 -0
  33. aksha-0.2.1/native/cuda/domain_rescore_cuda.h +290 -0
  34. aksha-0.2.1/native/cuda/f3_threshold.cc +240 -0
  35. aksha-0.2.1/native/cuda/f3_threshold.h +96 -0
  36. aksha-0.2.1/native/cuda/forward_cuda.cu +2946 -0
  37. aksha-0.2.1/native/cuda/forward_cuda.h +551 -0
  38. aksha-0.2.1/native/cuda/postfilter_cuda.cu +4307 -0
  39. aksha-0.2.1/native/cuda/postfilter_cuda.h +528 -0
  40. aksha-0.2.1/native/cuda/ssv_cuda.cu +5094 -0
  41. aksha-0.2.1/native/cuda/ssv_cuda.h +654 -0
  42. aksha-0.2.1/native/patches/pyhmmer-0.12.0-avx512-tail.patch +213 -0
  43. aksha-0.2.1/native/patches/pyhmmer-0.12.0-compact-domains.patch +1288 -0
  44. aksha-0.2.1/native/patches/pyhmmer-0.12.0-intrarow-release.patch +185 -0
  45. aksha-0.2.1/native/patches/pyhmmer-0.12.0-plan7gpu.patch +349 -0
  46. aksha-0.2.1/native/patches/pyhmmer-0.12.0-simple-regions.patch +353 -0
  47. aksha-0.2.1/native/python/plan7_gpu/__init__.py +31 -0
  48. aksha-0.2.1/native/python/plan7_gpu/_abi.py +67 -0
  49. aksha-0.2.1/native/python/plan7_gpu/_fingerprint.py +64 -0
  50. aksha-0.2.1/native/python/plan7_gpu/_mandatory_seed.py +456 -0
  51. aksha-0.2.1/native/python/plan7_gpu/_native.pyx +11346 -0
  52. aksha-0.2.1/native/python/plan7_gpu/_pipeline.pyx +14471 -0
  53. aksha-0.2.1/native/python/plan7_gpu/_private_tuning.py +73 -0
  54. aksha-0.2.1/native/python/plan7_gpu/_telemetry.py +1216 -0
  55. aksha-0.2.1/native/python/plan7_gpu/adapter.py +2576 -0
  56. aksha-0.2.1/native/python/plan7_gpu/astra_search.py +1462 -0
  57. aksha-0.2.1/native/python/plan7_gpu/pressed_manifest.py +793 -0
  58. aksha-0.2.1/native/python/plan7_gpu/telemetry_report.py +789 -0
  59. aksha-0.2.1/pyproject.toml +44 -0
  60. aksha-0.2.1/readme.md +80 -0
  61. aksha-0.2.1/release/BUILD.md +108 -0
  62. aksha-0.2.1/release/INSTALL.md +57 -0
  63. aksha-0.2.1/release/PUBLISH.md +23 -0
  64. aksha-0.2.1/release/THIRD_PARTY_NOTICES.md +20 -0
  65. aksha-0.2.1/release/build-requirements.txt +7 -0
  66. aksha-0.2.1/release/build.py +259 -0
  67. aksha-0.2.1/release/bundle.py +226 -0
  68. aksha-0.2.1/release/install_smoke.py +140 -0
  69. aksha-0.2.1/release/migrate_sources.py +103 -0
  70. aksha-0.2.1/release/prepare.py +164 -0
  71. aksha-0.2.1/release/runtime-pyproject.toml.in +23 -0
  72. aksha-0.2.1/release/scheduler_fix_bundle.py +160 -0
  73. aksha-0.2.1/release/source-lock.json +36 -0
  74. aksha-0.2.1/release/source-migration.json +275 -0
  75. aksha-0.2.1/setup.cfg +4 -0
  76. aksha-0.2.1/tests/__init__.py +1 -0
  77. aksha-0.2.1/tests/test_continuation_format.py +98 -0
  78. aksha-0.2.1/tests/test_cpu_allocator_launcher.py +274 -0
  79. aksha-0.2.1/tests/test_cpu_stream_profiles.py +253 -0
  80. aksha-0.2.1/tests/test_gpu_profile_cache.py +402 -0
  81. aksha-0.2.1/tests/test_gpu_search.py +6190 -0
aksha-0.2.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Jacob West-Roberts
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,6 @@
1
+ recursive-include native *.py *.pyx *.pxd *.h *.hpp *.cc *.cpp *.cu *.patch *.md
2
+ recursive-include release *.py *.json *.md *.txt *.in
3
+ recursive-include tests *.py
4
+ include docs/database-setup.md
5
+ prune docs/development
6
+ global-exclude __pycache__ *.py[cod] *.so *.o *.a
aksha-0.2.1/PKG-INFO ADDED
@@ -0,0 +1,106 @@
1
+ Metadata-Version: 2.4
2
+ Name: aksha
3
+ Version: 0.2.1
4
+ Summary: Scalable HMM-based sequence search and retrieval
5
+ Author: Jacob West-Roberts
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/jwestrob/aksha
8
+ Project-URL: Issues, https://github.com/jwestrob/aksha/issues
9
+ Keywords: hmm,hmmer,pyhmmer,bioinformatics,sequence-search,genomics,metagenomics
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
15
+ Requires-Python: <3.13,>=3.12
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: aksha-runtime==0.1.1
19
+ Requires-Dist: pandas>=2.0.0
20
+ Requires-Dist: tqdm>=4.65.0
21
+ Requires-Dist: requests>=2.28.0
22
+ Requires-Dist: platformdirs>=3.0.0
23
+ Provides-Extra: gpu
24
+ Requires-Dist: aksha-cuda12==0.1.1; extra == "gpu"
25
+ Dynamic: license-file
26
+
27
+ # Aksha
28
+
29
+ **Fast HMM-based annotation for genomes and metagenomes.**
30
+
31
+ Aksha accelerates HMM-based sequence searches so you can spend more time on
32
+ biology and less time waiting for annotations. Built on [HMMER](http://hmmer.org/)
33
+ and [PyHMMER](https://pyhmmer.readthedocs.io/), it combines fast CPU searches,
34
+ optional NVIDIA GPU acceleration, database management and sequence retrieval
35
+ in one command-line tool.
36
+
37
+ Aksha outperformed MetaCerberus 1.4 in our Pfam benchmarks on both CPU and GPU.
38
+
39
+ <details>
40
+ <summary>Benchmark results and comparison conditions</summary>
41
+
42
+ The recorded PLM2_5 workload contained 300,186 proteins and 27,481 Pfam models.
43
+
44
+ | Tool / configuration | Physical CPU cores | Pfam runtime | Speedup over MetaCerberus |
45
+ | --- | ---: | ---: | ---: |
46
+ | MetaCerberus 1.4, CPU | 64 | 11m 34s | — |
47
+ | Aksha, CPU | 64 | 4m 46s | 2.43× |
48
+ | Aksha, 1 H200 GPU + CPU | 64 host cores | 3m 39s | 3.17× |
49
+
50
+ Aksha's CPU and GPU outputs matched exactly in these runs. Both CPU-only
51
+ runs used 64 physical cores on the same Xeon 6787P machine. The GPU run used
52
+ one H200 plus 64 physical Xeon Platinum 8480+ host cores on a separate node.
53
+ Core counts are allocated physical cores, not CPU sockets or SMT threads.
54
+ MetaCerberus timing covers its HMM search/filter/parse pipeline, not
55
+ additional reporting; its thresholds and output rules differ, so this is a
56
+ workflow comparison, not identical-work benchmarking. Measurements predate
57
+ wheel packaging. [CPU evidence](https://github.com/jwestrob/aksha/blob/main/docs/development/CPU_PRODUCTION_INTEGRATION.md)
58
+ and [GPU evidence](https://github.com/jwestrob/aksha/blob/main/docs/development/GPU_PRODUCTION_INTEGRATION.md).
59
+
60
+ </details>
61
+
62
+ ## More than a fast search
63
+
64
+ - Search proteins or nucleotide sequences using supported databases or your own HMMs.
65
+ - Download and manage databases such as Pfam and KOfam from the same tool.
66
+ - Use a database's recommended cutoffs, or choose your own score and E-value thresholds.
67
+ - Export tabular results and optionally retrieve matching sequences for downstream analysis.
68
+
69
+ ## Installation
70
+
71
+ The PyPI release is being prepared. Once published:
72
+
73
+ ```bash
74
+ python -m pip install aksha
75
+ # With optional GPU support:
76
+ python -m pip install 'aksha[gpu]'
77
+ ```
78
+
79
+ Currently supported: Linux x86-64 with Python 3.12. GPU use requires a
80
+ compatible NVIDIA GPU and driver. ARM, macOS and Windows are not yet supported.
81
+ See the [installation guide](https://github.com/jwestrob/aksha/blob/main/release/INSTALL.md)
82
+ for hardware requirements, local-wheel installation and GPU setup.
83
+
84
+ ## Quick start
85
+
86
+ Download the Pfam protein-family database, then search your protein sequences:
87
+
88
+ ```bash
89
+ aksha initialize --hmms PFAM
90
+ aksha search --prot_in proteins.faa --installed_hmms PFAM --cut_ga --outdir results
91
+ ```
92
+
93
+ Results are written to `results/`. The example uses Pfam's built-in score
94
+ thresholds. You can also supply your own models with `--hmm_in` instead of
95
+ `--installed_hmms`. Run `aksha --help` or `aksha search --help` for more options.
96
+
97
+ The [database setup guide](https://github.com/jwestrob/aksha/blob/main/docs/database-setup.md)
98
+ explains available databases, storage locations and reusing existing files.
99
+ For source builds, see the [maintainer guide](https://github.com/jwestrob/aksha/blob/main/release/BUILD.md).
100
+
101
+ ## License
102
+
103
+ Aksha's original code is MIT-licensed; third-party components retain their own
104
+ licenses. See the [application license](https://github.com/jwestrob/aksha/blob/main/LICENSE),
105
+ [native-code license](https://github.com/jwestrob/aksha/blob/main/native/README.md)
106
+ and [third-party notices](https://github.com/jwestrob/aksha/blob/main/release/THIRD_PARTY_NOTICES.md).
@@ -0,0 +1,27 @@
1
+ # aksha/__init__.py
2
+
3
+ def main():
4
+ import argparse
5
+
6
+ parser = argparse.ArgumentParser(description='Aksha: A suite of sequence analysis tools.')
7
+ parser.add_argument('command', choices=['search', 'initialize', 'nucsearch', 'phmmer', 'jackhmmer'],
8
+ help='Subcommand to run')
9
+
10
+ # Parse only the first argument to determine the command
11
+ args, remaining_args = parser.parse_known_args()
12
+
13
+ if args.command == 'search':
14
+ from . import search
15
+ search.main(remaining_args)
16
+ elif args.command == 'initialize':
17
+ from . import initialize
18
+ initialize.main(remaining_args)
19
+ elif args.command == 'nucsearch':
20
+ from . import nucsearch
21
+ nucsearch.main(remaining_args)
22
+ elif args.command == 'phmmer':
23
+ from . import phmmer
24
+ phmmer.main(remaining_args)
25
+ elif args.command == 'jackhmmer':
26
+ from . import jackhmmer
27
+ jackhmmer.main(remaining_args)
@@ -0,0 +1,143 @@
1
+ """Minimal console launcher for Aksha's high-thread allocator policy.
2
+
3
+ This module must remain free of imports from :mod:`aksha.main`, PyHMMER, or
4
+ other allocation-heavy runtime modules. The console entry point can then set
5
+ the glibc arena limit and replace itself with a fresh interpreter before any
6
+ of those modules are imported. Programmatic/library entry points bypass this
7
+ module and retain their existing behavior.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import os
13
+ import sys
14
+
15
+
16
+ _GLIBC_ARENA_ENV = "MALLOC_ARENA_MAX"
17
+ _ASTRA_ARENA_ENV = "ASTRA_CPU_MALLOC_ARENA_MAX"
18
+ _REEXEC_SENTINEL_ENV = "_ASTRA_CPU_ALLOCATOR_REEXEC"
19
+ _DEFAULT_ARENA_MAX = 24
20
+ _MINIMUM_AUTO_THREADS = 64
21
+ _MAXIMUM_ARENA_MAX = (1 << 31) - 1
22
+
23
+
24
+ def _is_linux_glibc() -> bool:
25
+ """Return whether the current interpreter uses glibc on Linux."""
26
+ if not sys.platform.startswith("linux"):
27
+ return False
28
+ try:
29
+ version = os.confstr("CS_GNU_LIBC_VERSION")
30
+ except (AttributeError, OSError, ValueError):
31
+ return False
32
+ return isinstance(version, str) and version.startswith("glibc ")
33
+
34
+
35
+ def _requested_threads(arguments: tuple[str, ...]) -> int | None:
36
+ """Return the CLI worker count, or ``None`` for malformed input.
37
+
38
+ Aksha's parser owns diagnostics for malformed ``--threads`` arguments.
39
+ The launcher simply declines to re-exec in that case so it cannot mask the
40
+ existing command-line error or alter its ordering.
41
+ """
42
+ value = "1"
43
+ index = 0
44
+ while index < len(arguments):
45
+ argument = arguments[index]
46
+ if argument == "--threads":
47
+ index += 1
48
+ if index >= len(arguments):
49
+ return None
50
+ value = arguments[index]
51
+ elif argument.startswith("--threads="):
52
+ value = argument.partition("=")[2]
53
+ index += 1
54
+ try:
55
+ return int(value)
56
+ except ValueError:
57
+ return None
58
+
59
+
60
+ def _is_high_thread_search(arguments: tuple[str, ...]) -> bool:
61
+ """Return whether raw arguments select a search with at least 64 threads.
62
+
63
+ The allocator policy applies before Aksha can resolve CPU versus GPU
64
+ execution. Both routes run high-thread HMMER continuations and have
65
+ independently retained the 24-arena setting.
66
+ """
67
+ if not arguments or arguments[0] != "search":
68
+ return False
69
+ threads = _requested_threads(arguments[1:])
70
+ return threads is not None and threads >= _MINIMUM_AUTO_THREADS
71
+
72
+
73
+ def _arena_max(environment: dict[str, str]) -> int | None:
74
+ """Parse the Aksha-specific arena control.
75
+
76
+ Zero is an explicit opt-out. A standard ``MALLOC_ARENA_MAX`` value is
77
+ handled by the caller before this parser and always takes precedence.
78
+ """
79
+ value = environment.get(_ASTRA_ARENA_ENV)
80
+ if value is None:
81
+ return _DEFAULT_ARENA_MAX
82
+ if value == "0":
83
+ return None
84
+ if (
85
+ not value
86
+ or not value.isascii()
87
+ or not value.isdigit()
88
+ or value[0] == "0"
89
+ ):
90
+ raise ValueError(
91
+ f"{_ASTRA_ARENA_ENV} must be 0 or a canonical positive integer"
92
+ )
93
+ parsed = int(value)
94
+ if parsed > _MAXIMUM_ARENA_MAX:
95
+ raise ValueError(
96
+ f"{_ASTRA_ARENA_ENV} must be at most {_MAXIMUM_ARENA_MAX}"
97
+ )
98
+ return parsed
99
+
100
+
101
+ def _reexec_environment(
102
+ arguments: tuple[str, ...], environment: dict[str, str]
103
+ ) -> dict[str, str] | None:
104
+ """Return the environment for a required allocator re-exec, if any."""
105
+ # The standard glibc setting is entirely user-owned, including an empty or
106
+ # otherwise unusual value. Never reinterpret or overwrite it.
107
+ if _GLIBC_ARENA_ENV in environment:
108
+ return None
109
+ if _REEXEC_SENTINEL_ENV in environment:
110
+ return None
111
+ if not _is_high_thread_search(arguments) or not _is_linux_glibc():
112
+ return None
113
+ arena_max = _arena_max(environment)
114
+ if arena_max is None:
115
+ return None
116
+ updated = environment.copy()
117
+ updated[_GLIBC_ARENA_ENV] = str(arena_max)
118
+ updated[_REEXEC_SENTINEL_ENV] = "1"
119
+ return updated
120
+
121
+
122
+ def _dispatch() -> object:
123
+ """Import and run the existing CLI only after allocator routing."""
124
+ from .main import main as astra_main
125
+
126
+ return astra_main()
127
+
128
+
129
+ def main() -> object:
130
+ """Run the Aksha console command with the high-thread arena policy."""
131
+ arguments = tuple(sys.argv[1:])
132
+ try:
133
+ environment = _reexec_environment(arguments, dict(os.environ))
134
+ except ValueError as error:
135
+ raise SystemExit(str(error)) from None
136
+ if environment is not None:
137
+ os.execvpe(
138
+ sys.executable,
139
+ [sys.executable, "-m", "aksha.main", *arguments],
140
+ environment,
141
+ )
142
+ raise RuntimeError("os.execvpe returned unexpectedly")
143
+ return _dispatch()