def test_single_sample(self): # test that if we provide a single sample, we get the same sample back results = list(Sample.trim_samples(iter([self.samples[0]]))) self.assertEqual(len(results), 1) got, is_last_in_contig, heuristic = results[0] self.assertEqual(got, self.samples[0]) self.assertTrue(is_last_in_contig)
def test_gapped(self): # check we get is_last_in_contig if we have a gap between samples trimmed = list(Sample.trim_samples((s for s in self.samples[::2]))) for i, (expt, (got, is_last_in_contig, heuristic)) in enumerate(zip(self.samples[::2], trimmed)): self.assertEqual(got, expt) self.assertTrue(is_last_in_contig)
def test_works(self): # test simple case of 3 chained samples trimmed = list(Sample.trim_samples((s for s in self.samples))) for i, (expt, (got, is_last_in_contig, heuristic)) in enumerate(zip(self.sliced, trimmed)): self.assertEqual(got, expt) if i == len(self.sliced) - 1: self.assertTrue(is_last_in_contig) else: self.assertFalse(is_last_in_contig)
def test_raises(self): # test we get an exception if we e.g. provide samples from different # refs or samples out of order self.assertRaises(OverlapException, lambda x: list(Sample.trim_samples(x)), iter(self.samples[::-1]))