def test_parse_blast(self): """ Parse a blast result with multiple entries """ fn = os.path.join(self.datadir, "2061976712.xml") results = BLASTUtilities.parse_blast(fn,25) self.assertEqual(len(results.titles),25) self.assertEqual(len(results.evalues),25) self.assertEqual(len(results.scores),25) self.assertEqual(len(results.bits),25)
def test_do_blast(self): """ Test that a BLAST subprocess runs """ fn_sequence = os.path.join(self.datadir, "2061973757.fasta") fn_database = os.path.join(self.datadir, "mini_nr", "proteins") parser = SeqIO.parse(fn_sequence, "fasta") S = parser.next() S.seq.tostring() identifier = "nothing" fn_output= BLASTUtilities.do_blast(S.seq.tostring(),identifier, fn_database) self.assertTrue(os.path.exists(fn_output),"BLAST did not produce the output file") results = BLASTUtilities.parse_blast(fn_output) self.assertEqual(len(results.titles),1) self.assertAlmostEqual(947.577, results.bits[0],delta=0.001, msg="Score not correct") self.assertAlmostEqual(0, results.evalues[0],delta=1e-5, msg="E-value not correct") os.remove(fn_output)