From ad1f0029097e0b88a46221d717f066b3dda09a80 Mon Sep 17 00:00:00 2001 From: Gabriel Studer <gabriel.studer@unibas.ch> Date: Wed, 16 Jan 2019 15:41:20 +0100 Subject: [PATCH] make testBlastExec unit test less stringent Depending on the used BLAST version, there might be one low quality hit more or less. The unit test is now less stringent in a sense that we check whether the perfect hits are found. --- modules/bindings/tests/test_blast.py | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/modules/bindings/tests/test_blast.py b/modules/bindings/tests/test_blast.py index 48cb56068..18311abd9 100644 --- a/modules/bindings/tests/test_blast.py +++ b/modules/bindings/tests/test_blast.py @@ -32,21 +32,23 @@ class TestBlastBindings(unittest.TestCase): def testBlastExec(self): - hits=blast.Blast(self.query, 'testfiles/seqdb') - - expected_hits=['1griA','1fhsA','3n84E','1mw9X'] - self.assertEqual(len(hits), 4) - - found=0 - hit_ids=[] + hits = blast.Blast(self.query, 'testfiles/seqdb') + expected_perfect_hit_ids = ["1fhsA", "3n84E", "1griA"] + perfect_hit_ids = [] + for h in hits: - hit_ids.append(h.identifier) - - for identifier in expected_hits: - if identifier in hit_ids: - found+=1 - self.assertEqual(found, 4) + perfect_match = False + for aln_patch in h.aligned_patches: + if aln_patch.seqid == 1.0: + perfect_match = True + if perfect_match: + perfect_hit_ids.append(h.identifier) + + expected_perfect_hit_ids.sort() + perfect_hit_ids.sort() + + self.assertEqual(perfect_hit_ids, expected_perfect_hit_ids) def testBlastParseOutput(self): @@ -54,6 +56,7 @@ class TestBlastBindings(unittest.TestCase): parsed_out=blast.ParseBlastOutput(raw_out) + # numbers and ids can be specific to a certain blast version expected_ids=['1griA','1fhsA','3n84E','1mw9X'] expected_evalues=[4.80893e-59,4.80893e-59,9.06925e-58,2.96523] expected_scores=[534,534,523,27] -- GitLab