def test_parse_genotypes(self): genotype_field_strings = ['0/1:20', '0/0:15'] parsed_dict = self.variant._parse_genotypes(genotype_field_strings) na12878_gt = Genotype(self.variant, genotype_field_strings[0].split(':')) na0001_gt = Genotype(self.variant, genotype_field_strings[1].split(':')) expected_genotype_dict = {'NA12878': na12878_gt, 'NA0001': na0001_gt} self.assertEqual(parsed_dict, expected_genotype_dict)
def _parse_genotypes(self, genotype_array): ''' Parse the genotype strings ''' gts = dict() for index, sample_string in enumerate(genotype_array): sample_name = self.sample_list[index] sample_field = sample_string.split(':') g = Genotype(self, sample_field) gts[sample_name] = g return gts
def test_get_gt_string(self): g = Genotype(self.variant, '0/1') g.set_format('INACTIVE', 10) self.assertEqual(g.get_gt_string(), '0/1:.:10')
def test_set_format(self): g = Genotype(self.variant, '0/1') self.assertFalse('INACTIVE' in self.variant.active_formats) g.set_format('INACTIVE', 10) self.assertEqual(g.format['INACTIVE'], 10) self.assertTrue('INACTIVE' in self.variant.active_formats)
def test_get_format(self): g = Genotype(self.variant, '0/1') g.set_format('INACTIVE', 10) self.assertEqual(g.get_format('INACTIVE'), 10)
def test_get_gt_string(self): g = Genotype(self.variant, ['0/1']) g.set_format('INACTIVE', 10) self.assertEqual(g.get_gt_string(), '0/1:.:10')
def test_set_genotype(self): new_genotype = Genotype(self.variant, ['0/1', '9']) self.variant.set_genotype('NA12878', new_genotype) self.assertEqual( self.variant.genotype('NA12878').get_gt_string(), '0/1:9')
def test_get_format(self): g = Genotype(self.variant, ['0/1']) g.set_format('INACTIVE', 10) self.assertEqual(g.get_format('INACTIVE'), 10)
def test_set_format(self): g = Genotype(self.variant, ['0/1']) self.assertFalse('INACTIVE' in self.variant.format_dict) g.set_format('INACTIVE', 10) self.assertEqual(g.get_format('INACTIVE'), 10) self.assertTrue('INACTIVE' in self.variant.format_dict)
def test_equal(self): g1 = Genotype(self.variant, ['0/1']) g1.set_format('INACTIVE', 10) g2 = Genotype(self.variant, ['0/1']) g2.set_format('INACTIVE', 10) self.assertEqual(g1, g2)