-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add beginnings of unit test coverage of align
#463
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,14 @@ | ||
[pytest] | ||
addopts = --doctest-modules tests/python3/ augur/ | ||
addopts = | ||
# do not capture any output---necessary for interactive breakpoints | ||
-s | ||
|
||
# run any doctests found in .py modules | ||
--doctest-modules | ||
|
||
# calculate test coverage for the `augur` module | ||
--cov=augur | ||
|
||
testpaths = | ||
augur/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add these to |
||
tests/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest removing this file and instead adding |
||
|
||
case "$@" in | ||
*-k*) partial_test=1 ;; | ||
huddlej marked this conversation as resolved.
Show resolved
Hide resolved
|
||
esac | ||
|
||
if [ "$partial_test" = 1 ]; then | ||
# skip test coverage when running a subset of the test suite | ||
coverage_arg='--no-cov' | ||
else | ||
coverage_arg='' | ||
fi | ||
|
||
python3 -m pytest -c pytest.python3.ini $coverage_arg "$@" | ||
|
||
exit $? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
from Bio.Align import MultipleSeqAlignment | ||
from Bio.Seq import Seq | ||
from Bio.SeqRecord import SeqRecord | ||
|
||
from augur import align | ||
|
||
import pytest | ||
|
||
|
||
class TestAlign: | ||
def test_make_gaps_ambiguous(self): | ||
alignment = MultipleSeqAlignment( | ||
[SeqRecord(Seq("G-AC")), SeqRecord(Seq("----")), SeqRecord(Seq("TAGC"))] | ||
) | ||
|
||
align.make_gaps_ambiguous(alignment) | ||
|
||
assert [seq_record.seq for seq_record in alignment] == [ | ||
Seq("GNAC"), | ||
Seq("NNNN"), | ||
Seq("TAGC"), | ||
] | ||
|
||
def test_check_duplicates_no_arguments(self): | ||
assert align.check_duplicates() is None | ||
|
||
def test_check_duplicates_strings_with_no_duplicates(self): | ||
assert align.check_duplicates("GTAC", "CGTT") is None | ||
|
||
def test_check_duplicates_MSA_with_no_duplicates(self): | ||
alignment = MultipleSeqAlignment( | ||
[ | ||
SeqRecord(Seq("GTAC"), name="seq1"), | ||
SeqRecord(Seq("CGTT"), name="seq2"), | ||
SeqRecord(Seq("TAGC"), name="seq3"), | ||
] | ||
) | ||
assert align.check_duplicates(alignment) is None | ||
|
||
def test_check_duplicates_MSA_and_string_with_no_duplicates(self): | ||
alignment = MultipleSeqAlignment( | ||
[ | ||
SeqRecord(Seq("GTAC"), name="seq1"), | ||
SeqRecord(Seq("CGTT"), name="seq2"), | ||
SeqRecord(Seq("TAGC"), name="seq3"), | ||
] | ||
) | ||
assert align.check_duplicates(alignment, "TGTT") is None | ||
|
||
def test_check_duplicates_string_with_duplicates(self): | ||
with pytest.raises(align.AlignmentError): | ||
assert align.check_duplicates("GTAC", "CGTT", "CGTT") | ||
|
||
def test_check_duplicates_MSA_with_duplicates(self): | ||
alignment = MultipleSeqAlignment( | ||
[ | ||
SeqRecord(Seq("GTAC"), name="seq1"), | ||
SeqRecord(Seq("CGTT"), name="seq2"), | ||
SeqRecord(Seq("TAGC"), name="seq3"), | ||
SeqRecord(Seq("TAGC"), name="seq3"), | ||
] | ||
) | ||
with pytest.raises(align.AlignmentError): | ||
assert align.check_duplicates(alignment) | ||
|
||
def test_check_duplicates_MSA_and_string_with_duplicates(self): | ||
alignment = MultipleSeqAlignment( | ||
[ | ||
SeqRecord(Seq("GTAC"), name="seq1"), | ||
SeqRecord(Seq("CGTT"), name="seq2"), | ||
SeqRecord(Seq("TAGC"), name="seq3"), | ||
] | ||
) | ||
with pytest.raises(align.AlignmentError): | ||
assert align.check_duplicates(alignment, "seq3") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
--cov
here,--no-cov
can override it.