Skip to content
Open
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
21 changes: 21 additions & 0 deletions my_tests/test_pidentcomments.py
Original file line number Diff line number Diff line change
@@ -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)


19 changes: 15 additions & 4 deletions scripts/puppy-primers
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -984,10 +984,21 @@ 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 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."
)
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:
Expand Down