py-ard 2.4.0__tar.gz → 2.4.2__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 (136) hide show
  1. py_ard-2.4.2/.gitignore +126 -0
  2. {py_ard-2.4.0 → py_ard-2.4.2}/CONTRIBUTING.rst +6 -5
  3. {py_ard-2.4.0 → py_ard-2.4.2}/PKG-INFO +25 -33
  4. {py_ard-2.4.0 → py_ard-2.4.2}/README.md +8 -6
  5. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/__init__.py +16 -7
  6. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/ard.py +18 -19
  7. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/blender.py +1 -1
  8. py_ard-2.4.2/pyard/cli/__init__.py +22 -0
  9. py_ard-2.4.0/scripts/pyard-import → py_ard-2.4.2/pyard/cli/import_db.py +8 -6
  10. py_ard-2.4.0/scripts/pyard-reduce-csv → py_ard-2.4.2/pyard/cli/reduce_csv.py +190 -143
  11. py_ard-2.4.0/scripts/pyard → py_ard-2.4.2/pyard/cli/redux.py +22 -20
  12. py_ard-2.4.0/scripts/pyard-status → py_ard-2.4.2/pyard/cli/status.py +10 -6
  13. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/config.py +24 -4
  14. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/data_repository.py +17 -17
  15. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/db.py +35 -36
  16. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/drbx.py +1 -2
  17. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/handlers/__init__.py +1 -3
  18. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/handlers/allele_handler.py +0 -2
  19. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/handlers/gl_string_processor.py +4 -4
  20. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/handlers/hats_handler.py +2 -3
  21. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/handlers/mac_handler.py +8 -8
  22. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/handlers/serology_handler.py +5 -4
  23. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/handlers/shortnull_handler.py +2 -2
  24. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/handlers/v2_handler.py +2 -2
  25. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/handlers/xx_handler.py +5 -3
  26. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/loader/g_group.py +2 -2
  27. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/loader/serology.py +6 -5
  28. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/loader/version.py +3 -3
  29. py_ard-2.4.2/pyard/loader/wmda-data-model.md +378 -0
  30. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/misc.py +8 -6
  31. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/rc.py +1 -1
  32. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/reducers/__init__.py +8 -10
  33. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/reducers/base_reducer.py +3 -4
  34. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/reducers/default_reducer.py +2 -3
  35. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/reducers/exon_reducer.py +1 -2
  36. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/reducers/first_field_reducer.py +1 -3
  37. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/reducers/g_reducer.py +0 -1
  38. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/reducers/hats_reducer.py +1 -3
  39. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/reducers/lg_reducer.py +0 -1
  40. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/reducers/p_reducer.py +0 -1
  41. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/reducers/reducer_factory.py +5 -7
  42. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/reducers/s_reducer.py +1 -2
  43. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/reducers/u2_reducer.py +1 -2
  44. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/reducers/w_reducer.py +0 -1
  45. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/serology.py +6 -5
  46. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/simple_table.py +9 -5
  47. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/smart_sort.py +0 -2
  48. py_ard-2.4.2/pyproject.toml +121 -0
  49. py_ard-2.4.2/tests/api-test.hurl +266 -0
  50. py_ard-2.4.2/tests/environment.py +49 -0
  51. py_ard-2.4.2/tests/features/1f_reduction.feature +35 -0
  52. py_ard-2.4.2/tests/features/Gexpand.feature +12 -0
  53. py_ard-2.4.2/tests/features/Pexpand.feature +12 -0
  54. py_ard-2.4.2/tests/features/Wexpand.feature +16 -0
  55. py_ard-2.4.2/tests/features/XX.feature +27 -0
  56. py_ard-2.4.2/tests/features/allele.feature +128 -0
  57. py_ard-2.4.2/tests/features/cwd.feature +53 -0
  58. py_ard-2.4.2/tests/features/drbx.feature +32 -0
  59. py_ard-2.4.2/tests/features/drbx_blender.feature +56 -0
  60. py_ard-2.4.2/tests/features/glstring.feature +33 -0
  61. py_ard-2.4.2/tests/features/mac.feature +103 -0
  62. py_ard-2.4.2/tests/features/p_g_group.feature +100 -0
  63. py_ard-2.4.2/tests/features/p_group.feature +26 -0
  64. py_ard-2.4.2/tests/features/serology.feature +96 -0
  65. py_ard-2.4.2/tests/features/serology_broad_splits.feature +49 -0
  66. py_ard-2.4.2/tests/features/serology_typings_redux.feature +21 -0
  67. py_ard-2.4.2/tests/features/shortnulls.feature +27 -0
  68. py_ard-2.4.2/tests/features/u2_reduction.feature +39 -0
  69. py_ard-2.4.2/tests/features/valid_allele.feature +108 -0
  70. py_ard-2.4.2/tests/features/version2.feature +33 -0
  71. py_ard-2.4.2/tests/features/who.feature +34 -0
  72. py_ard-2.4.2/tests/steps/XX.py +17 -0
  73. py_ard-2.4.2/tests/steps/broad_splits.py +79 -0
  74. py_ard-2.4.2/tests/steps/cwd.py +33 -0
  75. py_ard-2.4.2/tests/steps/drbx_blender.py +74 -0
  76. py_ard-2.4.2/tests/steps/generate_drbx.py +64 -0
  77. py_ard-2.4.2/tests/steps/mac.py +50 -0
  78. py_ard-2.4.2/tests/steps/redux_allele.py +172 -0
  79. py_ard-2.4.2/tests/steps/validate_allele.py +39 -0
  80. py_ard-2.4.2/tests/unit/expected-serology.json +14 -0
  81. py_ard-2.4.2/tests/unit/expected.json +59 -0
  82. py_ard-2.4.2/tests/unit/handlers/__init__.py +0 -0
  83. py_ard-2.4.2/tests/unit/handlers/test_allele_handler.py +73 -0
  84. py_ard-2.4.2/tests/unit/handlers/test_gl_string_handler.py +149 -0
  85. py_ard-2.4.2/tests/unit/handlers/test_mac_handler.py +179 -0
  86. py_ard-2.4.2/tests/unit/handlers/test_serology_handler.py +150 -0
  87. py_ard-2.4.2/tests/unit/handlers/test_shortnull_handler.py +124 -0
  88. py_ard-2.4.2/tests/unit/handlers/test_v2_handler.py +178 -0
  89. py_ard-2.4.2/tests/unit/handlers/test_xx_handler.py +110 -0
  90. py_ard-2.4.2/tests/unit/reducers/__init__.py +0 -0
  91. py_ard-2.4.2/tests/unit/reducers/test_all_reducers.py +91 -0
  92. py_ard-2.4.2/tests/unit/reducers/test_base_reducer.py +34 -0
  93. py_ard-2.4.2/tests/unit/reducers/test_default_reducer.py +60 -0
  94. py_ard-2.4.2/tests/unit/reducers/test_exon_reducer.py +81 -0
  95. py_ard-2.4.2/tests/unit/reducers/test_first_field_reducer.py +33 -0
  96. py_ard-2.4.2/tests/unit/reducers/test_g_reducer.py +42 -0
  97. py_ard-2.4.2/tests/unit/reducers/test_lg_reducer.py +64 -0
  98. py_ard-2.4.2/tests/unit/reducers/test_p_reducer.py +32 -0
  99. py_ard-2.4.2/tests/unit/reducers/test_reducer_factory.py +116 -0
  100. py_ard-2.4.2/tests/unit/reducers/test_s_reducer.py +66 -0
  101. py_ard-2.4.2/tests/unit/reducers/test_u2_reducer.py +47 -0
  102. py_ard-2.4.2/tests/unit/reducers/test_w_reducer.py +49 -0
  103. py_ard-2.4.2/tests/unit/simple_table/__init__.py +0 -0
  104. py_ard-2.4.2/tests/unit/simple_table/test_column.py +44 -0
  105. py_ard-2.4.2/tests/unit/simple_table/test_simple_table.py +305 -0
  106. py_ard-2.4.2/tests/unit/simple_table/test_simple_table_failures.py +107 -0
  107. py_ard-2.4.2/tests/unit/test_cli.py +90 -0
  108. py_ard-2.4.2/tests/unit/test_load_allele_list.py +77 -0
  109. py_ard-2.4.2/tests/unit/test_load_serology_broad_split_mapping.py +74 -0
  110. py_ard-2.4.2/tests/unit/test_load_serology_mappings.py +107 -0
  111. py_ard-2.4.2/tests/unit/test_pyard.py +208 -0
  112. py_ard-2.4.2/tests/unit/test_smart_sort.py +131 -0
  113. py_ard-2.4.0/COPYING +0 -674
  114. py_ard-2.4.0/MANIFEST.in +0 -16
  115. py_ard-2.4.0/py_ard.egg-info/PKG-INFO +0 -792
  116. py_ard-2.4.0/py_ard.egg-info/SOURCES.txt +0 -67
  117. py_ard-2.4.0/py_ard.egg-info/dependency_links.txt +0 -1
  118. py_ard-2.4.0/py_ard.egg-info/not-zip-safe +0 -1
  119. py_ard-2.4.0/py_ard.egg-info/requires.txt +0 -5
  120. py_ard-2.4.0/py_ard.egg-info/top_level.txt +0 -1
  121. py_ard-2.4.0/requirements-tests.txt +0 -3
  122. py_ard-2.4.0/requirements.txt +0 -2
  123. py_ard-2.4.0/setup.cfg +0 -35
  124. py_ard-2.4.0/setup.py +0 -77
  125. {py_ard-2.4.0 → py_ard-2.4.2}/HISTORY.rst +0 -0
  126. {py_ard-2.4.0 → py_ard-2.4.2}/LICENSE +0 -0
  127. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/constants.py +0 -0
  128. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/dna_relshp.csv +0 -0
  129. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/exceptions.py +0 -0
  130. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/loader/CWD2.csv +0 -0
  131. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/loader/__init__.py +0 -0
  132. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/loader/allele_list.py +0 -0
  133. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/loader/cwd.py +0 -0
  134. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/loader/mac_codes.py +0 -0
  135. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/loader/p_group.py +0 -0
  136. {py_ard-2.4.0 → py_ard-2.4.2}/pyard/mappings.py +0 -0
@@ -0,0 +1,126 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ env/
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+
28
+ # PyInstaller
29
+ # Usually these files are written by a python script from a template
30
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
31
+ *.manifest
32
+ *.spec
33
+
34
+ # Installer logs
35
+ pip-log.txt
36
+ pip-delete-this-directory.txt
37
+
38
+ # Unit test / coverage reports
39
+ htmlcov/
40
+ .tox/
41
+ .coverage
42
+ .coverage.*
43
+ .cache
44
+ nosetests.xml
45
+ coverage.xml
46
+ *.cover
47
+ .hypothesis/
48
+
49
+ # Translations
50
+ *.mo
51
+ *.pot
52
+
53
+ # Django stuff:
54
+ *.log
55
+ local_settings.py
56
+
57
+ # Flask stuff:
58
+ instance/
59
+ .webassets-cache
60
+
61
+ # Scrapy stuff:
62
+ .scrapy
63
+
64
+ # Sphinx documentation
65
+ docs/_build/
66
+
67
+ # PyBuilder
68
+ target/
69
+
70
+ # Jupyter Notebook
71
+ .ipynb_checkpoints
72
+
73
+ # pyenv
74
+ .python-version
75
+
76
+ # celery beat schedule file
77
+ celerybeat-schedule
78
+
79
+ # SageMath parsed files
80
+ *.sage.py
81
+
82
+ # dotenv
83
+ .env
84
+ .env.dev
85
+
86
+ # virtualenv
87
+ .?venv*/
88
+ ENV/
89
+
90
+ # Spyder project settings
91
+ .spyderproject
92
+ .spyproject
93
+
94
+ # Rope project settings
95
+ .ropeproject
96
+
97
+ # mkdocs documentation
98
+ /site
99
+
100
+ # mypy
101
+ .mypy_cache/
102
+
103
+ # downloaded
104
+ *.pickle
105
+ *.zip
106
+
107
+ # BDD Testing
108
+ testing/
109
+ !test-requirements.txt
110
+ pretty.output
111
+ allure_report/
112
+
113
+ # Misc
114
+ tags
115
+ *.swp
116
+ *.patch
117
+ .direnv/
118
+ .envrc
119
+ .idea/
120
+ tmp/
121
+ temp/
122
+ demo/
123
+ great-docs/
124
+ .vscode
125
+ __marimo__
126
+ .DS_Store
@@ -64,13 +64,14 @@ Ready to contribute? Here's how to set up `py-ard` for local development.
64
64
 
65
65
  $ git clone git@github.com:your_name_here/py-ard.git
66
66
 
67
- 3. Install your local copy into a venv. This is how you set up your fork for local development::
67
+ 3. Install your local copy using `uv <https://docs.astral.sh/uv/>`_. This is how you set up your fork for local development::
68
68
 
69
69
  $ cd py-ard
70
- $ make venv
71
- $ source venv/bin/activate
72
70
  $ make install
73
71
 
72
+ This runs ``uv sync --all-extras --group test --group dev`` and sets up pre-commit.
73
+ Run project commands with ``uv run`` (e.g. ``uv run pytest``).
74
+
74
75
  4. Create a branch for local development::
75
76
 
76
77
  $ git checkout -b name-of-your-bugfix-or-feature
@@ -86,11 +87,11 @@ Ready to contribute? Here's how to set up `py-ard` for local development.
86
87
 
87
88
  To run behavior-driven development (BDD) tests locally via the behave framework, run::
88
89
 
89
- $ behave
90
+ $ uv run behave
90
91
 
91
92
  Run unit-tests::
92
93
 
93
- $ python -m unittest tests.test_pyard
94
+ $ uv run pytest
94
95
 
95
96
  6. Commit your changes and push your branch to GitHub::
96
97
 
@@ -1,16 +1,15 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: py-ard
3
- Version: 2.4.0
3
+ Version: 2.4.2
4
4
  Summary: ARD reduction for HLA with Python
5
- Home-page: https://github.com/nmdp-bioinformatics/py-ard
6
- Author: CIBMTR
7
- Author-email: cibmtr-pypi@nmdp.org
8
- License: LGPL 3.0
5
+ Project-URL: Homepage, https://github.com/nmdp-bioinformatics/py-ard
6
+ Project-URL: Repository, https://github.com/nmdp-bioinformatics/py-ard
7
+ Author-email: CIBMTR <cibmtr-pypi@nmdp.org>
8
+ License-Expression: LGPL-3.0-or-later
9
+ License-File: LICENSE
9
10
  Keywords: pyard
10
11
  Classifier: Development Status :: 5 - Production/Stable
11
12
  Classifier: Intended Audience :: Science/Research
12
- Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
13
- Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
14
13
  Classifier: Natural Language :: English
15
14
  Classifier: Programming Language :: Python :: 3.8
16
15
  Classifier: Programming Language :: Python :: 3.9
@@ -18,27 +17,18 @@ Classifier: Programming Language :: Python :: 3.10
18
17
  Classifier: Programming Language :: Python :: 3.11
19
18
  Classifier: Programming Language :: Python :: 3.12
20
19
  Classifier: Programming Language :: Python :: 3.13
21
- Provides: pyard
22
- Description-Content-Type: text/markdown
23
- License-File: LICENSE
24
- License-File: COPYING
25
- Requires-Dist: setuptools==83.0.0
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
22
+ Requires-Python: >=3.8
26
23
  Requires-Dist: toml==0.10.2
24
+ Provides-Extra: deploy
25
+ Requires-Dist: connexion[flask,swagger-ui,uvicorn]==3.3.0; (python_version >= '3.10') and extra == 'deploy'
26
+ Requires-Dist: flask>=3.1.0; (python_version >= '3.10') and extra == 'deploy'
27
+ Requires-Dist: gunicorn==25.3.0; (python_version >= '3.10') and extra == 'deploy'
28
+ Requires-Dist: uvicorn>=0.45.0; (python_version >= '3.10') and extra == 'deploy'
27
29
  Provides-Extra: script
28
- Requires-Dist: pandas>=2.0; extra == "script"
29
- Dynamic: author
30
- Dynamic: author-email
31
- Dynamic: classifier
32
- Dynamic: description
33
- Dynamic: description-content-type
34
- Dynamic: home-page
35
- Dynamic: keywords
36
- Dynamic: license
37
- Dynamic: license-file
38
- Dynamic: provides
39
- Dynamic: provides-extra
40
- Dynamic: requires-dist
41
- Dynamic: summary
30
+ Requires-Dist: pandas>=2.0; extra == 'script'
31
+ Description-Content-Type: text/markdown
42
32
 
43
33
  # py-ard
44
34
 
@@ -46,7 +36,7 @@ Swiss army knife of **HLA** Nomenclature
46
36
 
47
37
  [![PyPi Version](https://img.shields.io/pypi/v/py-ard.svg)](https://pypi.python.org/pypi/py-ard)
48
38
 
49
- ![py-ard-logo.png](images/py-ard-logo.png)
39
+ ![py-ard: redux() happens](images/py-ard-logo.png)
50
40
 
51
41
  **Note:**
52
42
 
@@ -126,16 +116,18 @@ git clone https://github.com/nmdp-bioinformatics/py-ard.git
126
116
  cd py-ard
127
117
  ```
128
118
 
129
- Create and activate virtual environment. Install the py-ard dependencies.
119
+ `py-ard` uses [uv](https://docs.astral.sh/uv/) to manage the project environment
120
+ and dependencies. Create the environment and install all dependency groups and
121
+ extras with:
130
122
 
131
123
  ```shell
132
- make venv
133
-
134
- source venv/bin/activate
135
-
136
124
  make install
137
125
  ```
138
126
 
127
+ which runs `uv sync --all-extras --group test --group dev` and sets up
128
+ pre-commit. Run commands inside the environment with `uv run`, e.g.
129
+ `uv run pytest`.
130
+
139
131
  See [Our Contribution Guide](CONTRIBUTING.rst) for open source contribution to `py-ard`.
140
132
 
141
133
  ## Using `py-ard`
@@ -4,7 +4,7 @@ Swiss army knife of **HLA** Nomenclature
4
4
 
5
5
  [![PyPi Version](https://img.shields.io/pypi/v/py-ard.svg)](https://pypi.python.org/pypi/py-ard)
6
6
 
7
- ![py-ard-logo.png](images/py-ard-logo.png)
7
+ ![py-ard: redux() happens](images/py-ard-logo.png)
8
8
 
9
9
  **Note:**
10
10
 
@@ -84,16 +84,18 @@ git clone https://github.com/nmdp-bioinformatics/py-ard.git
84
84
  cd py-ard
85
85
  ```
86
86
 
87
- Create and activate virtual environment. Install the py-ard dependencies.
87
+ `py-ard` uses [uv](https://docs.astral.sh/uv/) to manage the project environment
88
+ and dependencies. Create the environment and install all dependency groups and
89
+ extras with:
88
90
 
89
91
  ```shell
90
- make venv
91
-
92
- source venv/bin/activate
93
-
94
92
  make install
95
93
  ```
96
94
 
95
+ which runs `uv sync --all-extras --group test --group dev` and sets up
96
+ pre-commit. Run commands inside the environment with `uv run`, e.g.
97
+ `uv run pytest`.
98
+
97
99
  See [Our Contribution Guide](CONTRIBUTING.rst) for open source contribution to `py-ard`.
98
100
 
99
101
  ## Using `py-ard`
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
1
  #
3
2
  # py-ard
4
3
  # Copyright (c) 2023 Be The Match operated by National Marrow Donor Program. All Rights Reserved.
@@ -20,6 +19,8 @@
20
19
  # > http://www.fsf.org/licensing/licenses/lgpl.html
21
20
  # > http://www.opensource.org/licenses/lgpl-license.php
22
21
  #
22
+ from __future__ import annotations
23
+
23
24
  import os
24
25
 
25
26
  # exports for `pyard`
@@ -28,16 +29,24 @@ from .config import ARDConfig
28
29
  from .constants import DEFAULT_CACHE_SIZE
29
30
  from .misc import get_imgt_db_versions as db_versions
30
31
 
32
+ __all__ = [
33
+ "DEFAULT_CACHE_SIZE",
34
+ "ARDConfig",
35
+ "db_versions",
36
+ "dr_blender",
37
+ "init",
38
+ ]
39
+
31
40
  __author__ = """NMDP Bioinformatics"""
32
- __version__ = "2.4.0"
41
+ __version__ = "2.4.2"
33
42
 
34
43
 
35
44
  def init(
36
- imgt_version: str = None,
37
- data_dir: str = None,
38
- load_mac: bool = None,
39
- cache_size: int = None,
40
- config: dict = None,
45
+ imgt_version: str | None = None,
46
+ data_dir: str | None = None,
47
+ load_mac: bool | None = None,
48
+ cache_size: int | None = None,
49
+ config: dict | None = None,
41
50
  ):
42
51
  from .ard import ARD
43
52
  from .rc import load_rc
@@ -1,17 +1,16 @@
1
- # -*- coding: utf-8 -*-
1
+ from __future__ import annotations
2
2
 
3
3
  import functools
4
4
  import sys
5
- from typing import Union, List
6
5
 
7
6
  from . import data_repository as dr
8
- from . import db
9
- from . import smart_sort
7
+ from . import db, smart_sort
8
+ from .config import ARDConfig
10
9
  from .constants import (
11
- HLA_regex,
12
10
  DEFAULT_CACHE_SIZE,
13
11
  G_GROUP_LOCI,
14
12
  VALID_REDUCTION_TYPE,
13
+ HLA_regex,
15
14
  expression_chars,
16
15
  )
17
16
  from .exceptions import InvalidMACError, InvalidTypingError
@@ -21,16 +20,15 @@ from .handlers import (
21
20
  HATSHandler,
22
21
  MACHandler,
23
22
  SerologyHandler,
23
+ ShortNullHandler,
24
24
  V2Handler,
25
25
  XXHandler,
26
- ShortNullHandler,
27
26
  )
28
27
  from .misc import get_2field_allele, is_2_field_allele
29
28
  from .serology import SerologyMapping
30
- from .config import ARDConfig
31
29
 
32
30
 
33
- class ARD(object):
31
+ class ARD:
34
32
  """
35
33
  ARD reduction for HLA - Refactored with specialized handlers
36
34
  """
@@ -38,10 +36,10 @@ class ARD(object):
38
36
  def __init__(
39
37
  self,
40
38
  imgt_version: str = "Latest",
41
- data_dir: str = None,
39
+ data_dir: str | None = None,
42
40
  load_mac: bool = True,
43
41
  max_cache_size: int = DEFAULT_CACHE_SIZE,
44
- config: dict = None,
42
+ config: dict | None = None,
45
43
  ):
46
44
  self._data_dir = data_dir
47
45
  self.config = ARDConfig.from_dict(config)
@@ -130,7 +128,7 @@ class ARD(object):
130
128
  @staticmethod
131
129
  def _freeze_reference_data():
132
130
  """Freeze reference data for Python >= 3.9"""
133
- if sys.version_info.major == 3 and sys.version_info.minor >= 9:
131
+ if sys.version_info >= (3, 9):
134
132
  import gc
135
133
 
136
134
  gc.freeze()
@@ -140,7 +138,7 @@ class ARD(object):
140
138
  if hasattr(self, "db_connection") and self.db_connection:
141
139
  self.db_connection.close()
142
140
 
143
- @functools.lru_cache(maxsize=DEFAULT_CACHE_SIZE)
141
+ @functools.lru_cache(maxsize=DEFAULT_CACHE_SIZE) # noqa: B019
144
142
  def _redux_allele(
145
143
  self, allele: str, redux_type: VALID_REDUCTION_TYPE, re_ping=True
146
144
  ) -> str:
@@ -191,9 +189,8 @@ class ARD(object):
191
189
  if "*" in allele:
192
190
  locus, fields = allele.split("*")
193
191
  # Handle ignored allele suffixes
194
- if self.config.ignore_allele_with_suffixes:
195
- if fields in self.config.ignore_allele_with_suffixes:
196
- return allele
192
+ if fields in self.config.ignore_allele_with_suffixes:
193
+ return allele
197
194
  if locus not in G_GROUP_LOCI:
198
195
  return allele
199
196
 
@@ -253,7 +250,7 @@ class ARD(object):
253
250
  redux_allele = self._redux_allele(allele, redux_type)
254
251
  return redux_allele
255
252
 
256
- @functools.lru_cache(maxsize=DEFAULT_CACHE_SIZE)
253
+ @functools.lru_cache(maxsize=DEFAULT_CACHE_SIZE) # noqa: B019
257
254
  def redux(self, glstring: str, redux_type: VALID_REDUCTION_TYPE = "lgx") -> str:
258
255
  """Main redux method using specialized handlers"""
259
256
 
@@ -295,7 +292,9 @@ class ARD(object):
295
292
  def is_v2(self, allele: str) -> bool:
296
293
  return self.v2_handler.is_v2(allele)
297
294
 
298
- def is_XX(self, glstring: str, loc_antigen: str = None, code: str = None) -> bool:
295
+ def is_XX(
296
+ self, glstring: str, loc_antigen: str | None = None, code: str | None = None
297
+ ) -> bool:
299
298
  return self.xx_handler.is_xx(glstring, loc_antigen, code)
300
299
 
301
300
  def is_shortnull(self, allele: str) -> bool:
@@ -413,7 +412,7 @@ class ARD(object):
413
412
  return False
414
413
 
415
414
  if self.config.ignore_allele_with_suffixes:
416
- locus, fields = allele.split("*")
415
+ _locus, fields = allele.split("*")
417
416
  if fields in self.config.ignore_allele_with_suffixes:
418
417
  return True
419
418
 
@@ -460,7 +459,7 @@ class ARD(object):
460
459
  def get_db_version(self) -> str:
461
460
  return dr.get_db_version(self.db_connection)
462
461
 
463
- def similar_alleles(self, prefix: str) -> Union[List, None]:
462
+ def similar_alleles(self, prefix: str) -> list | None:
464
463
  """Find similar alleles using existing logic"""
465
464
  if "*" not in prefix:
466
465
  return None
@@ -50,7 +50,7 @@ def blender(drb1, drb3="", drb4="", drb5=""):
50
50
  drb1_allele_2 = drb1_2.split("*")[1]
51
51
  drb1_fam_1 = drb1_allele_1.split(":")[0] # First field (family)
52
52
  drb1_fam_2 = drb1_allele_2.split(":")[0] # First field (family)
53
- except Exception:
53
+ except Exception: # noqa: BLE001
54
54
  return ""
55
55
  # Map DRB1 families to expected DRBX genes (3, 4, 5, or 0 for none)
56
56
  x1 = expdrbx(drb1_fam_1)
@@ -0,0 +1,22 @@
1
+ #
2
+ # py-ard
3
+ # Copyright (c) 2023 Be The Match operated by National Marrow Donor Program. All Rights Reserved.
4
+ #
5
+ # This library is free software; you can redistribute it and/or modify it
6
+ # under the terms of the GNU Lesser General Public License as published
7
+ # by the Free Software Foundation; either version 3 of the License, or (at
8
+ # your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful, but WITHOUT
11
+ # ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
12
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13
+ # License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with this library; if not, write to the Free Software Foundation,
17
+ # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18
+ #
19
+ # > http://www.fsf.org/licensing/licenses/lgpl.html
20
+ # > http://www.opensource.org/licenses/lgpl-license.php
21
+ #
22
+ """Command-line entry points for py-ard tools."""
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
1
  #
4
2
  # py-ard
5
3
  # Copyright (c) 2023 Be The Match operated by National Marrow Donor Program. All Rights Reserved.
@@ -26,7 +24,7 @@ import pathlib
26
24
  import sys
27
25
 
28
26
  import pyard
29
- from pyard import db, data_repository
27
+ from pyard import data_repository, db
30
28
  from pyard.misc import get_data_dir
31
29
 
32
30
 
@@ -53,7 +51,7 @@ def get_v2_v3_mapping(v2_v3_mapping):
53
51
  return None
54
52
 
55
53
 
56
- if __name__ == "__main__":
54
+ def main():
57
55
  parser = argparse.ArgumentParser(
58
56
  description="""
59
57
  py-ard tool to generate reference SQLite database.
@@ -128,7 +126,7 @@ if __name__ == "__main__":
128
126
  print(f"Importing IPD/IMGT-HLA database version: {imgt_version}")
129
127
  if args.skip_mac:
130
128
  load_mac = False
131
- print(f"Skipping MAC tables creation")
129
+ print("Skipping MAC tables creation")
132
130
  else:
133
131
  load_mac = True
134
132
 
@@ -156,7 +154,11 @@ if __name__ == "__main__":
156
154
  )
157
155
 
158
156
  if args.refresh_mac:
159
- print(f"Updating MACs")
157
+ print("Updating MACs")
160
158
  db_connection, _ = db.create_db_connection(data_dir, imgt_version, ro=False)
161
159
  data_repository.generate_mac_codes(db_connection, refresh_mac=True)
162
160
  print(f"Updated MACs for {imgt_version} IPD/IMGT-HLA database.")
161
+
162
+
163
+ if __name__ == "__main__":
164
+ main()