Skip to content

Commit

Permalink
Add helper function to reencode alleles
Browse files Browse the repository at this point in the history
  • Loading branch information
szhan committed Jan 18, 2024
1 parent 1286856 commit 3a1e9b3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions python/tests/beagle_numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ def __post_init__(self):
""" TODO: Implement a class to encapsulate the data for imputation (`ImpData`). """


def remap_alleles(a):
"""
Helper function.
TODO: Move elsewhere.
"""
_ALLELES_ACGT_ = "ACGT"
b = np.zeros(len(a), dtype=np.int8) - 1
for i in range(len(a)):
if a[i] in [None, ""]:
continue
elif a[i] in _ALLELES_ACGT_:
b[i] = _ALLELES_ACGT_.index(a[i])
else:
raise AssertionError(f"Unrecognised: {a[i]}")
return b


def convert_to_genetic_map_positions(pos, genetic_map=None):
"""
Convert physical positions (bp) to genetic map positions (cM).
Expand Down

0 comments on commit 3a1e9b3

Please sign in to comment.