-
Notifications
You must be signed in to change notification settings - Fork 1
/
punnet.py
executable file
·40 lines (30 loc) · 966 Bytes
/
punnet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
"""
@file punnet.py
@brief Solves punnet squares.
@author Evan Elias Young
@date 2017-03-31
@date 2022-02-04
@copyright Copyright 2022 Evan Elias Young. All rights reserved.
"""
import itertools as ite
def parse_punnet(mat: str, pat: str) -> list[str]:
"""Will parse a punnet square for two genomes.
Args:
mat (string): The mother's alleles.
pat (string): The father's alleles.
Returns:
List: The mixed alleles.
"""
raw: list[str] = ["".join(p) for p in ite.permutations(mat + pat, 2)]
out: list[str] = [
"".join(sorted(pair, key=lambda L: (L.lower(), L))) for pair in raw
]
out.sort()
out = [out[i * 2 + 2] for i in range(4)]
return out
if __name__ == "__main__":
print("Hello Console!")
MATERNAL: str = input("Mother Alleles (Aa): ")
PATERNAL: str = input("Father Alleles (Aa): ")
print(parse_punnet(MATERNAL, PATERNAL))