def test_invert_match_generator_bad_pos1(self): pos_text = self.pos_text[:] pos_text.insert(0, "3.5 bad position") pos_txt = StringIO(''.join(pos_text)) vcf_txt = StringIO(''.join(self.vcf_text)) with self.assertRaises(ValueError): _ = list(grep_vcf.invert_match_generator(pos_txt, vcf_txt))
def test_invert_match_trunked_pos(self): # pos < vcf and pos file is shorter than vcf file pos_txt = StringIO('7\tline 1\n') vcf_txt = StringIO('9\tvcf 1\n10\tvcf 2\n11\tvcf 3\n') diff = list(grep_vcf.invert_match_generator(pos_txt, vcf_txt)) self.assertListEqual(diff, ['9\tvcf 1\n', '10\tvcf 2\n', '11\tvcf 3\n'])
def test_invert_match_generator_bad_vcf3(self): pos_txt = StringIO(''.join(self.pos_text)) vcf_text = self.vcf_text[:] vcf_text.insert(3, "8.5\tbad position\n") vcf_txt = StringIO(''.join(vcf_text)) with self.assertRaises(ValueError): _ = list(grep_vcf.invert_match_generator(pos_txt, vcf_txt))
def test_invert_match_generator(self): pos_txt = StringIO(''.join(self.pos_text)) vcf_txt = StringIO(''.join(self.vcf_text)) diff = list(grep_vcf.invert_match_generator(pos_txt, vcf_txt)) self.assertListEqual(diff, [ "7\tvcf line 1\n", "12\tvcf line 5\n", ])
def test_invert_match_trunked_vcf2(self): # vcf < pos and vcf file is shorter than pos file pos_txt = StringIO('9\tline 1\n10\tline 2\n') vcf_txt = StringIO('8\tvcf 1\n') diff = list(grep_vcf.invert_match_generator(pos_txt, vcf_txt)) self.assertListEqual(diff, ['8\tvcf 1\n'])
def test_invert_match_empty_vcf(self): pos_txt = StringIO(''.join(self.pos_text[:])) vcf_txt = StringIO('') diff = list(grep_vcf.invert_match_generator(pos_txt, vcf_txt)) self.assertListEqual(diff, [])
def test_invert_match_empty_pos(self): pos_txt = StringIO('') vcf_txt = StringIO(''.join(self.vcf_text)) diff = list(grep_vcf.invert_match_generator(pos_txt, vcf_txt)) expected_lines = [l for l in self.vcf_text if l[0] not in ('#', '\n')] self.assertListEqual(diff, expected_lines)