agglovar 0.0.1.dev2__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. agglovar-0.0.1.dev2/LICENSE +7 -0
  2. agglovar-0.0.1.dev2/PKG-INFO +40 -0
  3. agglovar-0.0.1.dev2/README.md +21 -0
  4. agglovar-0.0.1.dev2/pyproject.toml +110 -0
  5. agglovar-0.0.1.dev2/setup.cfg +4 -0
  6. agglovar-0.0.1.dev2/src/agglovar/__init__.py +21 -0
  7. agglovar-0.0.1.dev2/src/agglovar/align/__init__.py +9 -0
  8. agglovar-0.0.1.dev2/src/agglovar/align/op.py +173 -0
  9. agglovar-0.0.1.dev2/src/agglovar/align/score.py +495 -0
  10. agglovar-0.0.1.dev2/src/agglovar/fa.py +109 -0
  11. agglovar-0.0.1.dev2/src/agglovar/io.py +50 -0
  12. agglovar-0.0.1.dev2/src/agglovar/join/__init__.py +13 -0
  13. agglovar-0.0.1.dev2/src/agglovar/join/config/__init__.py +36 -0
  14. agglovar-0.0.1.dev2/src/agglovar/join/config/parser.py +385 -0
  15. agglovar-0.0.1.dev2/src/agglovar/join/config/stage.py +792 -0
  16. agglovar-0.0.1.dev2/src/agglovar/join/config/strategy.py +244 -0
  17. agglovar-0.0.1.dev2/src/agglovar/join/multipair.py +145 -0
  18. agglovar-0.0.1.dev2/src/agglovar/join/om/__init__.py +16 -0
  19. agglovar-0.0.1.dev2/src/agglovar/join/pair.py +1344 -0
  20. agglovar-0.0.1.dev2/src/agglovar/kmer/__init__.py +12 -0
  21. agglovar-0.0.1.dev2/src/agglovar/kmer/plot.py +355 -0
  22. agglovar-0.0.1.dev2/src/agglovar/kmer/util.py +362 -0
  23. agglovar-0.0.1.dev2/src/agglovar/schema.py +30 -0
  24. agglovar-0.0.1.dev2/src/agglovar/seqmatch.py +328 -0
  25. agglovar-0.0.1.dev2/src/agglovar.egg-info/PKG-INFO +40 -0
  26. agglovar-0.0.1.dev2/src/agglovar.egg-info/SOURCES.txt +27 -0
  27. agglovar-0.0.1.dev2/src/agglovar.egg-info/dependency_links.txt +1 -0
  28. agglovar-0.0.1.dev2/src/agglovar.egg-info/requires.txt +11 -0
  29. agglovar-0.0.1.dev2/src/agglovar.egg-info/top_level.txt +1 -0
@@ -0,0 +1,7 @@
1
+ Copyright 2025 Peter A. Audano III
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ Metadata-Version: 2.4
2
+ Name: agglovar
3
+ Version: 0.0.1.dev2
4
+ Summary: Toolkit for fast genomic variant transformations and intersects
5
+ License-Expression: MIT
6
+ Requires-Python: >=3.12
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: polars>=1.33.1
10
+ Requires-Dist: biopython>=1.85
11
+ Requires-Dist: edlib>=1.3.9.post1
12
+ Requires-Dist: numpy>=2.3.0
13
+ Requires-Dist: ply>=3.11
14
+ Provides-Extra: plot
15
+ Requires-Dist: matplotlib>=3.10.3; extra == "plot"
16
+ Provides-Extra: all
17
+ Requires-Dist: agglovar[plot]; extra == "all"
18
+ Dynamic: license-file
19
+
20
+ # Agglovar toolkit for fast genomic variant transformations and intersects
21
+
22
+ Agglovar is a fast toolkit based on Polars to perform fast variant transformations and intersections between
23
+ callsets. It defines a standard schema for genomic variants based on Apache Arrow, which Polars uses natively. Whenever
24
+ possible, Aggolvar uses Parquet files to store data allowing it to preserve the schema and take advantage of both
25
+ columnar storage and pushdown optimizations for fast queries and transformations.
26
+
27
+ Agglovar replaces variant intersections in the SV-Pop library (https://github.com/EichlerLab/svpop).
28
+
29
+ The name Agglovar is a portmanteau of the latin word "agglomerare" (to gather) and "variant" (genomic variants).
30
+
31
+ ## Alpha release
32
+
33
+ Agglovar is under active development and a stable release is not yet available.
34
+
35
+
36
+ ## Installation
37
+
38
+ ```
39
+ pip install agglovar
40
+ ```
@@ -0,0 +1,21 @@
1
+ # Agglovar toolkit for fast genomic variant transformations and intersects
2
+
3
+ Agglovar is a fast toolkit based on Polars to perform fast variant transformations and intersections between
4
+ callsets. It defines a standard schema for genomic variants based on Apache Arrow, which Polars uses natively. Whenever
5
+ possible, Aggolvar uses Parquet files to store data allowing it to preserve the schema and take advantage of both
6
+ columnar storage and pushdown optimizations for fast queries and transformations.
7
+
8
+ Agglovar replaces variant intersections in the SV-Pop library (https://github.com/EichlerLab/svpop).
9
+
10
+ The name Agglovar is a portmanteau of the latin word "agglomerare" (to gather) and "variant" (genomic variants).
11
+
12
+ ## Alpha release
13
+
14
+ Agglovar is under active development and a stable release is not yet available.
15
+
16
+
17
+ ## Installation
18
+
19
+ ```
20
+ pip install agglovar
21
+ ```
@@ -0,0 +1,110 @@
1
+ [project]
2
+ name = "agglovar"
3
+ description = "Toolkit for fast genomic variant transformations and intersects"
4
+
5
+ license = "MIT"
6
+ license-files = ["LICENSE"]
7
+
8
+ dynamic = ["version"]
9
+
10
+ readme = "README.md"
11
+
12
+ requires-python = ">=3.12"
13
+ dependencies = [
14
+ "polars>=1.33.1",
15
+ "biopython>=1.85",
16
+ "edlib>=1.3.9.post1",
17
+ "numpy>=2.3.0",
18
+ "ply>=3.11",
19
+ ]
20
+
21
+ [agglovar.urls]
22
+ Homepage = "https://github.com/BeckLaboratory/agglovar"
23
+ #Documentation = "https://agglovar.readthedocs.io"
24
+ Repository = "https://github.com/BeckLaboratory/agglovar"
25
+ Issues = "https://github.com/BeckLaboratory/agglovar/issues"
26
+ Changelog = "https://github.com/BeckLaboratory/agglovar/blob/master/CHANGELOG.md"
27
+
28
+ keywords = [
29
+ "variant merging",
30
+ "variant intersect",
31
+ "bioinformatics",
32
+ "genomics"
33
+ ]
34
+
35
+ classifiers = [
36
+ "Development Status :: 4 - Beta",
37
+ "Intended Audience :: Science/Research",
38
+ "Topic :: Scientific/Engineering :: Bio-Informatics",
39
+ "Operating System :: OS Independent",
40
+ "Programming Language :: Python :: 3",
41
+ "Programming Language :: Python :: 3.12",
42
+ "Private :: Do Not Upload", # Temporary until published
43
+ ]
44
+
45
+ authors = [
46
+ {name = "Peter Audano", email = "peter.audano@jax.org"},
47
+ ]
48
+
49
+ maintainers = [
50
+ {name = "Peter Audano", email = "peter.audano@jax.org"}
51
+ ]
52
+
53
+ [dependency-groups]
54
+ dev = [
55
+ "flake8>=7.3.0",
56
+ "flake8-bugbear>=24.12.12",
57
+ "flake8-docstrings>=1.7.0",
58
+ "flake8-dunder-all>=0.5.0",
59
+ "flake8-mutable>=1.2.0",
60
+ "flake8-pyproject>=1.2.3",
61
+ "flake8-rst-docstrings>=0.3.1",
62
+ "ipython>=9.4.0",
63
+ "pylint>=3.3.7",
64
+ "pytest>=8.4.1",
65
+ "pytest-cov>=6.2.1",
66
+ "sphinx>=8.2.3",
67
+ "sphinx-autoapi>=3.6.0",
68
+ "sphinx-rtd-theme>=3.0.2",
69
+ "tox>=4.30.2",
70
+ "twine>=6.2.0",
71
+ ]
72
+
73
+ [project.optional-dependencies]
74
+ plot = [
75
+ "matplotlib>=3.10.3",
76
+ ]
77
+ all = [
78
+ "agglovar[plot]"
79
+ ]
80
+
81
+
82
+ [build-system]
83
+ requires = ["setuptools"]
84
+ build-backend = "setuptools.build_meta"
85
+
86
+ [tool.setuptools.packages.find]
87
+ where = ["src"]
88
+ include = ["agglovar"]
89
+ exclude = ["*__pycache__"]
90
+
91
+ [tool.setuptools.dynamic]
92
+ version = {attr = "agglovar.__version__"}
93
+
94
+
95
+ [tool.pytest.ini_options]
96
+ testpaths = [
97
+ "tests"
98
+ ]
99
+
100
+
101
+ [tool.pylint.'MESSAGES CONTROL']
102
+ max-line-length = 120
103
+
104
+ [tool.flake8]
105
+ max-line-length = 120
106
+ docstring-convention = "google"
107
+ per-file-ignores = [
108
+ "src/agglovar/join/config/parser.py: D200, D205, D212, D300, D403, D415"
109
+ ]
110
+ rst-roles = ["class", "meth", "const", "ref", "func"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,21 @@
1
+ """Agglovar: A toolkit for fast genomic variant transformations and intersects."""
2
+
3
+ __version__ = '0.0.1.dev2'
4
+
5
+ __all__ = [
6
+ 'align',
7
+ 'fa',
8
+ 'join',
9
+ 'io',
10
+ 'kmer',
11
+ 'schema',
12
+ 'seqmatch',
13
+ ]
14
+
15
+ from . import align
16
+ from . import fa
17
+ from . import join
18
+ from . import io
19
+ from . import kmer
20
+ from . import schema
21
+ from . import seqmatch
@@ -0,0 +1,9 @@
1
+ """Alignment operation and handling routines."""
2
+
3
+ __all__ = [
4
+ 'op',
5
+ 'score',
6
+ ]
7
+
8
+ from . import op
9
+ from . import score
@@ -0,0 +1,173 @@
1
+ """Constants and functions for working with alignment operations.
2
+
3
+ Definitions in this subpackage are borrowed from
4
+ `PAV 3+ <https://github.com/BeckLaboratory/pav>`__.
5
+ """
6
+
7
+ __all__ = [
8
+ # Sets of valid characters/codes
9
+ 'INT_STR_SET',
10
+ 'CIGAR_OP_SET',
11
+
12
+ # CIGAR operation codes
13
+ 'M',
14
+ 'I',
15
+ 'D',
16
+ 'N',
17
+ 'S',
18
+ 'H',
19
+ 'P',
20
+ 'EQ',
21
+ 'X',
22
+
23
+ # Operation code sets
24
+ 'CLIP_SET',
25
+ 'ALIGN_SET',
26
+ 'EQX_SET',
27
+
28
+ # Mappings
29
+ 'OP_CHAR',
30
+ 'OP_CHAR_FUNC',
31
+ 'OP_CODE',
32
+
33
+ # Arrays
34
+ 'CONSUMES_QRY_ARR',
35
+ 'CONSUMES_REF_ARR',
36
+ 'ADV_REF_ARR',
37
+ 'ADV_QRY_ARR',
38
+ 'VAR_ARR',
39
+
40
+ # Functions
41
+ 'cigar_to_arr',
42
+ ]
43
+
44
+
45
+ import numpy as np
46
+ from types import MappingProxyType
47
+ from typing import Mapping
48
+
49
+ INT_STR_SET: frozenset[str] = frozenset({'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', })
50
+ """Set of valid integer character strings representing operation codes."""
51
+
52
+ CIGAR_OP_SET: frozenset[str] = frozenset({'M', 'I', 'D', 'N', 'S', 'H', 'P', '=', 'X', })
53
+ """Set of valid operation characters."""
54
+
55
+ M: int = 0
56
+ """Match or mismatch operation code."""
57
+
58
+ I: int = 1 # noqa: E741
59
+ """Insertion operation code."""
60
+
61
+ D: int = 2
62
+ """Deletion operation code."""
63
+
64
+ N: int = 3
65
+ """Skipped region operation code."""
66
+
67
+ S: int = 4
68
+ """Soft clipping operation code."""
69
+
70
+ H: int = 5
71
+ """Hard clipping operation code."""
72
+
73
+ P: int = 6
74
+ """Padding operation code."""
75
+
76
+ EQ: int = 7
77
+ """Sequence match operation code."""
78
+
79
+ X: int = 8
80
+ """Sequence mismatch operation code."""
81
+
82
+ CLIP_SET: frozenset[int] = frozenset({S, H, })
83
+ """Set of clipping operation codes (soft and hard clipping)."""
84
+
85
+ ALIGN_SET: frozenset[int] = frozenset({M, EQ, X, })
86
+ """Set of alignment operation codes (match, sequence match, mismatch)."""
87
+
88
+ EQX_SET: frozenset[int] = frozenset({EQ, X, })
89
+ """Set of exact match/mismatch operation codes."""
90
+
91
+ OP_CHAR: Mapping[int, str] = MappingProxyType({
92
+ M: 'M',
93
+ I: 'I',
94
+ D: 'D',
95
+ N: 'N',
96
+ S: 'S',
97
+ H: 'H',
98
+ P: 'P',
99
+ EQ: '=',
100
+ X: 'X'
101
+ })
102
+ """Mapping from operation codes to their character representations."""
103
+
104
+ OP_CHAR_FUNC = np.vectorize(lambda val: OP_CHAR.get(val, '?'))
105
+ """Vectorized function to convert operation codes to characters."""
106
+
107
+ OP_CODE: Mapping[str, int] = MappingProxyType({
108
+ 'M': M,
109
+ 'I': I,
110
+ 'D': D,
111
+ 'N': N,
112
+ 'S': S,
113
+ 'H': H,
114
+ 'P': P,
115
+ '=': EQ,
116
+ 'X': X
117
+ })
118
+ """Mapping from CIGAR characters to operation codes."""
119
+
120
+ CONSUMES_QRY_ARR: np.typing.NDArray[np.integer] = np.array([M, I, S, EQ, X])
121
+ """Array of operation codes that consume query bases."""
122
+
123
+ CONSUMES_REF_ARR: np.typing.NDArray[np.integer] = np.array([M, D, N, EQ, X])
124
+ """Array of operation codes that consume reference bases."""
125
+
126
+ ADV_REF_ARR: np.typing.NDArray[np.integer] = np.array([M, EQ, X, D])
127
+ """Array of operation codes that advance the reference position."""
128
+
129
+ ADV_QRY_ARR: np.typing.NDArray[np.integer] = np.array([M, EQ, X, I, S, H])
130
+ """Array of operation codes that advance the query position."""
131
+
132
+ VAR_ARR: np.typing.NDArray[np.integer] = np.array([X, I, D])
133
+ """Array of operation codes that introduce variation."""
134
+
135
+
136
+ def cigar_to_arr(
137
+ cigar_str: str
138
+ ) -> np.ndarray:
139
+ """Get a numpy array with two dimensions (dtype int).
140
+
141
+ The first column is the operation codes, the second column is the operation lengths.
142
+
143
+ :param cigar_str: CIGAR string.
144
+
145
+ :returns: Array of operation codes and lengths (dtype int).
146
+
147
+ :raises ValueError: If the CIGAR string is not properly formatted.
148
+ """
149
+ pos = 0
150
+ max_pos = len(cigar_str)
151
+
152
+ op_tuples = list()
153
+
154
+ while pos < max_pos:
155
+
156
+ len_pos = pos
157
+
158
+ while cigar_str[len_pos] in INT_STR_SET:
159
+ len_pos += 1
160
+
161
+ if len_pos == pos:
162
+ raise ValueError(f'Missing length in CIGAR string at index {pos}')
163
+
164
+ if cigar_str[len_pos] not in CIGAR_OP_SET:
165
+ raise ValueError(f'Unknown CIGAR operation {cigar_str[len_pos]}')
166
+
167
+ op_tuples.append(
168
+ (OP_CODE[cigar_str[len_pos]], int(cigar_str[pos:len_pos]))
169
+ )
170
+
171
+ pos = len_pos + 1
172
+
173
+ return np.array(op_tuples)