Inês Mendes
Bioinformatics PhD student.
Software testing in bioinformatics
- a call to action -
XV CAML · V NeurULisboa PhD Students Meeting
4th to 6th May, 2022
Inês Mendes
MRamirez Lab - iMM
@ines_cim
cimendes
Can person X, with the same data and the same methodology, obtain the same conclusions as person Y?
https://doi.org/10.1016/j.patter.2020.100099
Design
Code
Test
Test
Code
Refactor
Traditional Technique Approach
Test Driven Development Approach
ASSEMBLY_TEST = "test/data/assembly.fasta"
def test_fasta_iter():
fasta_iterator = utils.fasta_iter(ASSEMBLY_TEST)
first_header, first_contig = fasta_iterator.__next__()
assert first_header == 'k141_4'
assert len(first_contig) == 1061
assert sorted(set(first_contig)) == ['A', 'C', 'G', 'T']test_args = ['chewBBACA.py', 'AlleleCall', '-i', 'data/prep_data/empty_dir']
def test_invalid_input(test_args, expected):
# create empty dir for empty dir test
if 'empty_dir' in test_args[3] and os.path.isdir(test_args[3]) is False:
os.mkdir(test_args[3])
with pytest.raises(SystemExit) as e:
with patch.object(sys, 'argv', test_args):
chewBBACA.main()
assert e.type == SystemExit
assert e.value.code != 0 In the field of microbial bioinformatics, good software engineering practices are not yet widely adopted. (...) This paper serves as a resource that could help microbial bioinformaticians get started with software testing if they have not had formal training.
Include test files with known expected outcomes for a successful run.
Include files or other inputs on which the tool is expected to fail.
unittest (https://docs.python.org/3/library/unittest.html)
pytest (https://docs.pytest.org/en/stable/)
(https://testthat.r-lib.org/) testthat
Try it out!
Special thanks to Pedro Vila-Cerqueira, Rafael Mamede and Mário Ramirez.
FCT PhD Grants SFRH/BD/129483/2017
COVID/BD/152618/2022
MRamirez Lab, iMM
2019
By Inês Mendes
Slide deck for the XV CAML PhD Students Meeting