mhcseqs 2.6.2__tar.gz → 2.6.3__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.
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/PKG-INFO +1 -1
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs/alleles.py +4 -5
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs/validate.py +65 -0
- mhcseqs-2.6.3/mhcseqs/version.py +1 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs.egg-info/PKG-INFO +1 -1
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/tests/test_alleles.py +13 -2
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/tests/test_pipeline.py +12 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/tests/test_validate.py +86 -0
- mhcseqs-2.6.2/mhcseqs/version.py +0 -1
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/LICENSE +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/README.md +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs/__init__.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs/__main__.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs/b2m_sequences.csv +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs/datafiles.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs/diverse_mhc_sequences.csv +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs/domain_grammar.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs/domain_parsing.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs/download.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs/imgt.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs/mhc_prefix_aliases.csv +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs/mouse_h2_sequences.csv +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs/pipeline.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs/species.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs.egg-info/SOURCES.txt +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs.egg-info/dependency_links.txt +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs.egg-info/entry_points.txt +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs.egg-info/requires.txt +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/mhcseqs.egg-info/top_level.txt +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/pyproject.toml +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/setup.cfg +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/tests/test_cli.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/tests/test_curate_diverse_mhc.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/tests/test_datafiles.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/tests/test_download.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/tests/test_evaluate_sp_ground_truth.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/tests/test_groove.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/tests/test_groove_class_ii.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/tests/test_historical_prefix_provenance.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/tests/test_imgt.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/tests/test_mutations.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/tests/test_package_api.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/tests/test_sp_overcapture.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/tests/test_species.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/tests/test_species_coverage.py +0 -0
- {mhcseqs-2.6.2 → mhcseqs-2.6.3}/tests/test_version.py +0 -0
|
@@ -206,8 +206,9 @@ def parse_allele_name(
|
|
|
206
206
|
}
|
|
207
207
|
if species:
|
|
208
208
|
kwargs["species"] = species
|
|
209
|
-
|
|
210
|
-
#
|
|
209
|
+
elif require_explicit_species:
|
|
210
|
+
# Keep strict provenance available without changing the ordinary
|
|
211
|
+
# mhcgnomes behavior where a bare allele such as A*02:01 means HLA.
|
|
211
212
|
kwargs["default_species"] = None
|
|
212
213
|
|
|
213
214
|
coerced = _coerce_allele_name(raw)
|
|
@@ -277,11 +278,9 @@ def normalize_allele_name(name: str) -> str:
|
|
|
277
278
|
|
|
278
279
|
Examples:
|
|
279
280
|
"HLA-A*02:01" -> "HomoSapiens-A*02:01"
|
|
281
|
+
"A*02:01" -> "HomoSapiens-A*02:01"
|
|
280
282
|
"A0201" -> "HomoSapiens-A*02:01"
|
|
281
283
|
"HLA-A*02:01:01:02L" -> "HomoSapiens-A*02:01L"
|
|
282
|
-
|
|
283
|
-
Bare gene/allele forms such as ``A*02:01`` require species context and are
|
|
284
|
-
rejected here rather than silently defaulting to human.
|
|
285
284
|
"""
|
|
286
285
|
parsed = parse_allele_name(name)
|
|
287
286
|
if parsed is None:
|
|
@@ -18,6 +18,22 @@ from typing import Dict, List, Tuple
|
|
|
18
18
|
|
|
19
19
|
VALID_AA = set("ACDEFGHIKLMNPQRSTVWYX")
|
|
20
20
|
|
|
21
|
+
# Conservative floors derived from the last healthy pre-regression release.
|
|
22
|
+
# v2.5.12 had 56,276 full rows and 54,639 functional grooves, including
|
|
23
|
+
# 25,824 functional human grooves (33,874 class I and 20,765 class II). These
|
|
24
|
+
# leave room for ordinary upstream curation while catching catastrophic source
|
|
25
|
+
# loss or groove-extraction failure before release artifacts are made.
|
|
26
|
+
MIN_RELEASE_ARTIFACT_COUNTS = {
|
|
27
|
+
"raw_total": 50_000,
|
|
28
|
+
"full_total": 50_000,
|
|
29
|
+
"raw_imgt": 20_000,
|
|
30
|
+
"raw_human": 20_000,
|
|
31
|
+
"functional_total": 50_000,
|
|
32
|
+
"functional_human": 20_000,
|
|
33
|
+
"functional_class_i": 30_000,
|
|
34
|
+
"functional_class_ii": 18_000,
|
|
35
|
+
}
|
|
36
|
+
|
|
21
37
|
# Expected signal peptide lengths by MHC class (wide ranges to cover species variation)
|
|
22
38
|
SP_RANGE_CLASS_I = (15, 35) # typical 20-24, some species 15-17
|
|
23
39
|
SP_RANGE_CLASS_II_ALPHA = (15, 42) # typical 24-30, DMA sometimes 39
|
|
@@ -249,6 +265,55 @@ def _aa_composition_check(sequences: List[str], label: str) -> List[str]:
|
|
|
249
265
|
return warnings
|
|
250
266
|
|
|
251
267
|
|
|
268
|
+
def validate_release_artifact_counts(
|
|
269
|
+
raw_csv: Path,
|
|
270
|
+
full_csv: Path,
|
|
271
|
+
*,
|
|
272
|
+
minimums: Dict[str, int] | None = None,
|
|
273
|
+
) -> Tuple[List[str], Dict[str, int]]:
|
|
274
|
+
"""Check release artifacts against conservative source-count floors.
|
|
275
|
+
|
|
276
|
+
The floors are intentionally lower than the last healthy release. They
|
|
277
|
+
detect a missing source or parser-wide species regression without making
|
|
278
|
+
routine upstream additions or removals a release blocker.
|
|
279
|
+
"""
|
|
280
|
+
counts = Counter(
|
|
281
|
+
raw_total=0,
|
|
282
|
+
full_total=0,
|
|
283
|
+
raw_imgt=0,
|
|
284
|
+
raw_human=0,
|
|
285
|
+
functional_total=0,
|
|
286
|
+
functional_human=0,
|
|
287
|
+
functional_class_i=0,
|
|
288
|
+
functional_class_ii=0,
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
with open(raw_csv, "r", encoding="utf-8") as f:
|
|
292
|
+
for row in csv.DictReader(f):
|
|
293
|
+
counts["raw_total"] += 1
|
|
294
|
+
if row.get("source") == "imgt":
|
|
295
|
+
counts["raw_imgt"] += 1
|
|
296
|
+
if row.get("species") == "Homo sapiens":
|
|
297
|
+
counts["raw_human"] += 1
|
|
298
|
+
|
|
299
|
+
with open(full_csv, "r", encoding="utf-8") as f:
|
|
300
|
+
for row in csv.DictReader(f):
|
|
301
|
+
counts["full_total"] += 1
|
|
302
|
+
if row.get("is_functional") != "True":
|
|
303
|
+
continue
|
|
304
|
+
counts["functional_total"] += 1
|
|
305
|
+
if row.get("species") == "Homo sapiens":
|
|
306
|
+
counts["functional_human"] += 1
|
|
307
|
+
if row.get("mhc_class") == "I":
|
|
308
|
+
counts["functional_class_i"] += 1
|
|
309
|
+
elif row.get("mhc_class") == "II":
|
|
310
|
+
counts["functional_class_ii"] += 1
|
|
311
|
+
|
|
312
|
+
required = minimums or MIN_RELEASE_ARTIFACT_COUNTS
|
|
313
|
+
errors = [f"{name}={counts[name]:,} is below the release minimum of {minimum:,}" for name, minimum in required.items() if counts[name] < minimum]
|
|
314
|
+
return errors, dict(counts)
|
|
315
|
+
|
|
316
|
+
|
|
252
317
|
# ---------------------------------------------------------------------------
|
|
253
318
|
# Main validation entry point
|
|
254
319
|
# ---------------------------------------------------------------------------
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.6.3"
|
|
@@ -74,8 +74,19 @@ def test_normalize_allele_name_compact():
|
|
|
74
74
|
assert result == "HomoSapiens-A*02:01"
|
|
75
75
|
|
|
76
76
|
|
|
77
|
-
def
|
|
78
|
-
|
|
77
|
+
def test_bare_hla_allele_uses_mhcgnomes_default_species():
|
|
78
|
+
parsed = parse_allele_name("A*02:01")
|
|
79
|
+
assert parsed.to_string() == "HLA-A*02:01"
|
|
80
|
+
assert parsed.species.name == "Homo sapiens"
|
|
81
|
+
assert parsed.species_source == "default"
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def test_bare_hla_allele_can_require_explicit_species():
|
|
85
|
+
assert parse_allele_name("A*02:01", require_explicit_species=True) is None
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def test_normalize_bare_hla_allele():
|
|
89
|
+
assert normalize_allele_name("A*02:01") == "HomoSapiens-A*02:01"
|
|
79
90
|
|
|
80
91
|
|
|
81
92
|
def test_generated_short_alias_is_not_accepted_without_external_evidence():
|
|
@@ -13,6 +13,7 @@ from mhcseqs.pipeline import (
|
|
|
13
13
|
_load_diverse_mhc_references,
|
|
14
14
|
_load_mouse_h2_references,
|
|
15
15
|
_looks_like_nucleotide,
|
|
16
|
+
_resolve_header_allele,
|
|
16
17
|
build_raw_index,
|
|
17
18
|
)
|
|
18
19
|
|
|
@@ -168,6 +169,17 @@ def test_extract_source_id_unknown():
|
|
|
168
169
|
assert _extract_source_id("some random header", "other") == ""
|
|
169
170
|
|
|
170
171
|
|
|
172
|
+
def test_resolve_official_imgt_header_with_bare_hla_allele():
|
|
173
|
+
result = _resolve_header_allele("HLA:HLA00001 A*01:01:01:01 365 bp")
|
|
174
|
+
assert result == (
|
|
175
|
+
"HomoSapiens-A*01:01:01:01",
|
|
176
|
+
"A",
|
|
177
|
+
"I",
|
|
178
|
+
"Homo sapiens",
|
|
179
|
+
"A*01:01:01:01",
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
|
|
171
183
|
def test_load_mouse_h2_references():
|
|
172
184
|
rows = _load_mouse_h2_references()
|
|
173
185
|
assert len(rows) == 30
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import csv
|
|
2
|
+
|
|
1
3
|
from mhcseqs.validate import (
|
|
4
|
+
MIN_RELEASE_ARTIFACT_COUNTS,
|
|
2
5
|
VALID_AA,
|
|
3
6
|
_check_b2m,
|
|
4
7
|
_check_groove_row,
|
|
@@ -6,6 +9,7 @@ from mhcseqs.validate import (
|
|
|
6
9
|
_check_signal_peptide,
|
|
7
10
|
_check_valid_aa,
|
|
8
11
|
format_validation_report,
|
|
12
|
+
validate_release_artifact_counts,
|
|
9
13
|
)
|
|
10
14
|
|
|
11
15
|
|
|
@@ -178,3 +182,85 @@ def test_format_validation_report_truncates_when_requested():
|
|
|
178
182
|
assert "allele_2" in report
|
|
179
183
|
assert "allele_3" not in report
|
|
180
184
|
assert "... and 7 more" in report
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def _write_count_fixture(path, fieldnames, rows):
|
|
188
|
+
with open(path, "w", newline="", encoding="utf-8") as f:
|
|
189
|
+
writer = csv.DictWriter(f, fieldnames=fieldnames)
|
|
190
|
+
writer.writeheader()
|
|
191
|
+
writer.writerows(rows)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def test_validate_release_artifact_counts_accepts_healthy_counts(tmp_path):
|
|
195
|
+
raw_csv = tmp_path / "raw.csv"
|
|
196
|
+
full_csv = tmp_path / "full.csv"
|
|
197
|
+
_write_count_fixture(
|
|
198
|
+
raw_csv,
|
|
199
|
+
["source", "species"],
|
|
200
|
+
[
|
|
201
|
+
{"source": "imgt", "species": "Homo sapiens"},
|
|
202
|
+
{"source": "imgt", "species": "Homo sapiens"},
|
|
203
|
+
{"source": "ipd_mhc", "species": "Macaca mulatta"},
|
|
204
|
+
],
|
|
205
|
+
)
|
|
206
|
+
_write_count_fixture(
|
|
207
|
+
full_csv,
|
|
208
|
+
["allele", "species", "mhc_class", "is_functional"],
|
|
209
|
+
[
|
|
210
|
+
{
|
|
211
|
+
"allele": "a",
|
|
212
|
+
"species": "Homo sapiens",
|
|
213
|
+
"mhc_class": "I",
|
|
214
|
+
"is_functional": "True",
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"allele": "b",
|
|
218
|
+
"species": "Macaca mulatta",
|
|
219
|
+
"mhc_class": "II",
|
|
220
|
+
"is_functional": "True",
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
errors, counts = validate_release_artifact_counts(
|
|
226
|
+
raw_csv,
|
|
227
|
+
full_csv,
|
|
228
|
+
minimums={"raw_total": 3, "full_total": 2, "raw_imgt": 2, "raw_human": 2},
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
assert errors == []
|
|
232
|
+
assert counts == {
|
|
233
|
+
"raw_total": 3,
|
|
234
|
+
"full_total": 2,
|
|
235
|
+
"raw_imgt": 2,
|
|
236
|
+
"raw_human": 2,
|
|
237
|
+
"functional_total": 2,
|
|
238
|
+
"functional_human": 1,
|
|
239
|
+
"functional_class_i": 1,
|
|
240
|
+
"functional_class_ii": 1,
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def test_validate_release_artifact_counts_reports_each_regression(tmp_path):
|
|
245
|
+
raw_csv = tmp_path / "raw.csv"
|
|
246
|
+
full_csv = tmp_path / "full.csv"
|
|
247
|
+
_write_count_fixture(raw_csv, ["source", "species"], [{"source": "ipd_mhc", "species": "Macaca mulatta"}])
|
|
248
|
+
_write_count_fixture(full_csv, ["allele"], [])
|
|
249
|
+
|
|
250
|
+
errors, _ = validate_release_artifact_counts(
|
|
251
|
+
raw_csv,
|
|
252
|
+
full_csv,
|
|
253
|
+
minimums={"raw_total": 2, "full_total": 1, "raw_imgt": 1, "raw_human": 1},
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
assert len(errors) == 4
|
|
257
|
+
assert any("raw_imgt=0" in error for error in errors)
|
|
258
|
+
assert any("raw_human=0" in error for error in errors)
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def test_release_artifact_minimums_cover_hla_source_loss():
|
|
262
|
+
assert MIN_RELEASE_ARTIFACT_COUNTS["raw_imgt"] >= 20_000
|
|
263
|
+
assert MIN_RELEASE_ARTIFACT_COUNTS["raw_human"] >= 20_000
|
|
264
|
+
assert MIN_RELEASE_ARTIFACT_COUNTS["functional_human"] >= 20_000
|
|
265
|
+
assert MIN_RELEASE_ARTIFACT_COUNTS["functional_class_i"] >= 30_000
|
|
266
|
+
assert MIN_RELEASE_ARTIFACT_COUNTS["functional_class_ii"] >= 18_000
|
mhcseqs-2.6.2/mhcseqs/version.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.6.2"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|