From d983a69c999681b47757254fda9c751097b4e816 Mon Sep 17 00:00:00 2001 From: Yaroslav Terentyev <17741549+YaroGitHubed@users.noreply.github.com> Date: Fri, 17 Oct 2025 11:28:53 +0100 Subject: [PATCH 1/3] Fix NameError: add default PidentComments --- scripts/puppy-primers | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/puppy-primers b/scripts/puppy-primers index 7fa2d0c..3a716cc 100644 --- a/scripts/puppy-primers +++ b/scripts/puppy-primers @@ -984,10 +984,17 @@ elif args.primers_type == "group": unintendedComment = "UNINTENDED AMPLIFICATION:\nWARNING - This gene amplifies unintended species in the defined community!" ## Comments about percentage identity of alignments: - if pidentSum == 100 * numTargets: - PidentComments = "ALIGNMENTS %ID:\nThis gene aligns perfectly (100% ID) to each target gene." - elif pidentSum < 100 * numTargets: - PidentComments = "ALIGNMENTS %ID:\nThis gene does not align perfectly (100% ID) to at least one target gene." + PidentComments = "ALIGNMENTS %ID:\nNo alignment information available." + + if isinstance(pidentSum, (int, float)) and isinstance(numTargets, (int, float)): + if pidentSum == 100 * numTargets: + PidentComments = ( + "ALIGNMENTS %ID:\nThis gene aligns perfectly (100% ID) to each target gene." + ) + elif pidentSum < 100 * numTargets: + PidentComments = ( + "ALIGNMENTS %ID:\nThis gene does not align perfectly (100% ID) to at least one target gene." + ) ## Comments about alignments query coverage: if qcovSum == 1 * numTargets: From 3505d6e0b5aa267601577b721c2b2fa22199ac2c Mon Sep 17 00:00:00 2001 From: Yaroslav Terentyev <17741549+YaroGitHubed@users.noreply.github.com> Date: Tue, 28 Oct 2025 13:42:11 +0000 Subject: [PATCH 2/3] fix(puppy-primers): correct 0% identity logic for PidentComments --- scripts/puppy-primers | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) mode change 100644 => 100755 scripts/puppy-primers diff --git a/scripts/puppy-primers b/scripts/puppy-primers old mode 100644 new mode 100755 index 3a716cc..4e9dbc5 --- a/scripts/puppy-primers +++ b/scripts/puppy-primers @@ -987,7 +987,11 @@ elif args.primers_type == "group": PidentComments = "ALIGNMENTS %ID:\nNo alignment information available." if isinstance(pidentSum, (int, float)) and isinstance(numTargets, (int, float)): - if pidentSum == 100 * numTargets: + if not pidentSum or not numTargets: + PidentComments = ( + "ALIGNMENTS %ID:\nNo alignment information available." + ) + elif pidentSum == 100 * numTargets: PidentComments = ( "ALIGNMENTS %ID:\nThis gene aligns perfectly (100% ID) to each target gene." ) From 2953f35829010ec19eef09de743443f8a7a68a5e Mon Sep 17 00:00:00 2001 From: Yaroslav Terentyev <17741549+YaroGitHubed@users.noreply.github.com> Date: Fri, 31 Oct 2025 13:40:21 +0000 Subject: [PATCH 3/3] test(pidentcomments): add unit tests for pident_comment and constants --- my_tests/test_pidentcomments.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 my_tests/test_pidentcomments.py diff --git a/my_tests/test_pidentcomments.py b/my_tests/test_pidentcomments.py new file mode 100644 index 0000000..c8ab043 --- /dev/null +++ b/my_tests/test_pidentcomments.py @@ -0,0 +1,21 @@ +import math +from my_tests.pidentcomments import pident_comment, DEFAULT, PERFECT, IMPERFECT + +def test_defaults_and_branches(): + assert "No alignment" in pident_comment(None, 3) + assert "aligns perfectly" in pident_comment(100, 1) + assert "does not align perfectly" in pident_comment(99.9, 1) + # With 0 targets we fall back to DEFAULT + assert "No alignment" in pident_comment(0, 0) + +def test_never_raises_on_weird_inputs(): + for pair in [("x","y"), ([],{}), (object(),object()), (-1,-1)]: + out = pident_comment(*pair) + assert isinstance(out, str) + assert "No alignment" in out + +def test_constants_are_strings(): + for s in (DEFAULT, PERFECT, IMPERFECT): + assert isinstance(s, str) + +