Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 26 additions & 8 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import operator
import os
import shutil
import warnings
import numpy as np


Expand Down Expand Up @@ -50,13 +51,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:
warnings.warn(
"Some outputs may be missing for the generation for the accuracy report. You can check tests/accuracy_tests/accu_report.txt for the recorded accuracies or rerun the tests. "
)


@pytest.hookimpl()
Expand Down Expand Up @@ -88,7 +98,15 @@ def pytest_terminal_summary(terminalreporter):
"Gen5 Accu",
)
dt = {"names": columns, "formats": ("U76", "U28", "U25") + ("f4",) * (nGen + 1)}
accu = np.loadtxt("tests/accuracy_tests/accu_report.txt", encoding=None, dtype=dt)
try:
accu = np.loadtxt(
"tests/accuracy_tests/accu_report.txt", encoding=None, dtype=dt
)
except ValueError:
warnings.warn(
"Some outputs may be missing for the generation for the accuracy report. You can check tests/accuracy_tests/accu_report.txt for the recorded accuracies or rerun the tests. "
)
return

mkr_accu = list(
filter(
Expand Down
6 changes: 5 additions & 1 deletion docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ Usage
Program options
===============

|Software| takes in a number of command line arguments to control the program's behavior. To view a list of arguments, run |Software| without any command line arguments, i.e. |Software| or ``AlphaImpute2 -h``.
|Software| takes in a number of command line arguments to control the program's behavior. To view a list of arguments, run |Software| without any command line arguments, i.e. |Software|, ``AlphaImpute2 -h``, ``AlphaImpute2 -help`` or ``AlphaImpute2 --help``.

User can check the version of the program with ``AlphaImpute2 -version``.
Remember to use the correct version of the documentation for the version of the program you are using.
For example, the link to the documentation for version ``v0.0.3`` is https://alphaimpute2.readthedocs.io/en/v0.0.3/.

There are four primary ways to run |Software| which differ on whether population or pedigree imputation should be run. The default option is to run both population and pedigree imputation in an integrated algorithm. This will be the option most users will want if they have access to pedigree data on a majority of individuals. The second option is to run population imputation only with the ``-pop_only`` flag. This option should be used if no pedigree data is availible. The third option is to run only pedigree based imputation using the ``-ped_only`` flag. This option is not recommended for general use cases, but may be applicable if

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/alphaimpute2/Imputation/ImputationIndividual.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def profile(x):


class AlphaImputeIndividual(Pedigree.Individual):
def __init__(self, idx, idn):
super().__init__(idx, idn)
def __init__(self, idx, idn, MetaFounder=None):
super().__init__(idx, idn, MetaFounder=None)

self.reverse_view = None
self.backward_information = None
Expand Down
23 changes: 20 additions & 3 deletions src/alphaimpute2/alphaimpute2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import sys
import numpy as np

from .tinyhouse import Pedigree
Expand All @@ -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()):

Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -472,11 +487,13 @@ def write_seg(pedigree, outputFile):

@time_func("Full Program Run")
def main():
InputOutput.print_boilerplate("AlphaImpute2", version_verion)
args = getArgs()

InputOutput.print_boilerplate("AlphaImpute2", version_version)

InputOutput.setNumbaSeeds(12345)
pedigree = Pedigree.Pedigree(constructor=ImputationIndividual.AlphaImputeIndividual)
args.main_metafounder = "MF_1"
read_in_data(pedigree, args)
for ind in pedigree:
ind.map_length = args.length
Expand Down
Loading