From a5cc05e24191a848099cc66977cca16d3e11d92d Mon Sep 17 00:00:00 2001 From: XingerTang Date: Thu, 26 Mar 2026 16:31:39 +0000 Subject: [PATCH 1/6] Cleanup issues AlphaGenes/AlphaImpute2#64 --- .github/workflows/tests.yml | 1 + pyproject.toml | 2 +- src/alphaimpute2/alphaimpute2.py | 27 ++++++++++++++++++++++++--- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 38f9c15..22f79a2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,6 +7,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, Windows-latest, macos-latest] + python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] runs-on: ${{ matrix.os }} permissions: contents: read diff --git a/pyproject.toml b/pyproject.toml index 0f1d3ff..796449a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ dependencies = [ "numpy>=1.19", "numba>=0.49.0" ] -requires-python = "!= 3.12, !=3.14" +requires-python = ">= 3.6, < 3.14" [project.scripts] # correspond to entry_points diff --git a/src/alphaimpute2/alphaimpute2.py b/src/alphaimpute2/alphaimpute2.py index 940ce2e..3ac3d52 100644 --- a/src/alphaimpute2/alphaimpute2.py +++ b/src/alphaimpute2/alphaimpute2.py @@ -1,4 +1,5 @@ import argparse +import sys import numpy as np from .tinyhouse import Pedigree @@ -13,10 +14,9 @@ from .tinyhouse.Utils import time_func -# try: from .Imputation import version -version_verion = version.version +version_version = version.version if not ("profile" in globals()): @@ -240,6 +240,21 @@ def getArgs(): help=argparse.SUPPRESS, ) # help='Flag to prioritze pedigree imputation for individuals at the same genotyping density as their parents.') + # special handle for version argument to allow it to be called with just -version + parser.add_argument( + "-version", + default=None, + action="version", + version="%(prog)s " + version_version, + help="Show program's version number and exit.", + ) + + args = sys.argv[1:] + + if "-version" in args: + parser.parse_args(args) + sys.exit(0) + return InputOutput.parseArgs("AlphaImpute", parser) @@ -472,9 +487,15 @@ def write_seg(pedigree, outputFile): @time_func("Full Program Run") def main(): - InputOutput.print_boilerplate("AlphaImpute2", version_verion) args = getArgs() + # commenting out as AlphaImpute2 does not have recent changes for x-chr and metafounder + # therefore cannot use the boilerplate as the commit with updated boilerplate also has + # the changes for x-chr and metafounder and cause issues + # remove comment once AlphaImpute2 has been updated to work with x-chr and metafounder + + # InputOutput.print_boilerplate("AlphaImpute2", version_version) + InputOutput.setNumbaSeeds(12345) pedigree = Pedigree.Pedigree(constructor=ImputationIndividual.AlphaImputeIndividual) read_in_data(pedigree, args) From 6f3df0212e4e12eaab02d67f33170085183bba07 Mon Sep 17 00:00:00 2001 From: XingerTang Date: Thu, 26 Mar 2026 16:59:06 +0000 Subject: [PATCH 2/6] Add test workflow output printout for more informative output --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 22f79a2..656d4be 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -46,4 +46,4 @@ jobs: - name: Run pytest run: | - pytest \ No newline at end of file + pytest -s \ No newline at end of file From 11226e74a3828eaec635c0fe6b95d57dbab90fb3 Mon Sep 17 00:00:00 2001 From: XingerTang Date: Fri, 27 Mar 2026 10:38:57 +0000 Subject: [PATCH 3/6] Add exception clause --- conftest.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/conftest.py b/conftest.py index 593a39d..5f59809 100644 --- a/conftest.py +++ b/conftest.py @@ -50,13 +50,22 @@ def pytest_runtest_makereport(): num_file = 3 else: num_file = 2 - accu = stdout[-1][-1].split("\n")[-(2 + 3 * num_file) :] - name = accu[0].split()[-1] - with open("tests/accuracy_tests/accu_report.txt", "a") as file: - for i in range(num_file): - assessed_file = accu[i * 3 + 1].split()[-1] - file.write(name + " " + assessed_file + " " + accu[i * 3 + 2] + "\n") - file.write(name + " " + assessed_file + " " + accu[i * 3 + 3] + "\n") + try: + accu = stdout[-1][-1].split("\n")[-(2 + 3 * num_file) :] + name = accu[0].split()[-1] + with open("tests/accuracy_tests/accu_report.txt", "a") as file: + for i in range(num_file): + assessed_file = accu[i * 3 + 1].split()[-1] + file.write( + name + " " + assessed_file + " " + accu[i * 3 + 2] + "\n" + ) + file.write( + name + " " + assessed_file + " " + accu[i * 3 + 3] + "\n" + ) + except IndexError: + print( + "Some outputs are not obtained. Please check the test log for details." + ) @pytest.hookimpl() From 6f7e4bedf401b9ec482089d9a2154d08431bdfe6 Mon Sep 17 00:00:00 2001 From: XingerTang Date: Fri, 27 Mar 2026 12:36:17 +0000 Subject: [PATCH 4/6] Remove printout --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 656d4be..22f79a2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -46,4 +46,4 @@ jobs: - name: Run pytest run: | - pytest -s \ No newline at end of file + pytest \ No newline at end of file From 4c362d053ae2f802fbe1f18adb605befe45b0016 Mon Sep 17 00:00:00 2001 From: XingerTang Date: Fri, 27 Mar 2026 15:55:58 +0000 Subject: [PATCH 5/6] Update warning message --- conftest.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conftest.py b/conftest.py index 5f59809..7d3023f 100644 --- a/conftest.py +++ b/conftest.py @@ -2,6 +2,7 @@ import operator import os import shutil +import warnings import numpy as np @@ -63,8 +64,8 @@ def pytest_runtest_makereport(): name + " " + assessed_file + " " + accu[i * 3 + 3] + "\n" ) except IndexError: - print( - "Some outputs are not obtained. Please check the test log for details." + warnings.warn( + "Some outputs are missing in the accuracy report. If you are using Linux system, you can try Python 3.12 or 3.13 to run the tests, or check the test outputs directly with pytest -s for more details." ) From 3db63aa3c1c68191fd0bb6922fbab14c9ed95749 Mon Sep 17 00:00:00 2001 From: XingerTang Date: Fri, 27 Mar 2026 16:54:59 +0000 Subject: [PATCH 6/6] Update warning message --- conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conftest.py b/conftest.py index 7d3023f..8a44c26 100644 --- a/conftest.py +++ b/conftest.py @@ -65,7 +65,7 @@ def pytest_runtest_makereport(): ) except IndexError: warnings.warn( - "Some outputs are missing in the accuracy report. If you are using Linux system, you can try Python 3.12 or 3.13 to run the tests, or check the test outputs directly with pytest -s for more details." + "Some outputs are missing in the accuracy report. If you are using Linux system, you can rerun the tests, or check the test outputs directly with pytest -s for more details." )