def test_create_pileup_examples(self): self.processor.pic = mock.Mock() self.add_mock('_encode_tensor', side_effect=[ ('tensor1', self.default_shape, self.default_format), ('tensor2', self.default_shape, self.default_format) ]) dv_call = mock.Mock() dv_call.variant = test_utils.make_variant(start=10, alleles=['A', 'C', 'G']) ex = mock.Mock() alt1, alt2 = ['C'], ['G'] self.processor.pic.create_pileup_images.return_value = [ (alt1, 'tensor1'), (alt2, 'tensor2') ] actual = self.processor.create_pileup_examples(dv_call) self.processor.pic.create_pileup_images.assert_called_once_with( dv_call) self.assertEquals(len(actual), 2) for ex, (alt, img) in zip(actual, [(alt1, 'tensor1'), (alt2, 'tensor2')]): self.assertEqual(tf_utils.example_alt_alleles(ex), alt) self.assertEqual(tf_utils.example_variant(ex), dv_call.variant) self.assertEqual(tf_utils.example_encoded_image(ex), img) self.assertEqual(tf_utils.example_image_shape(ex), self.default_shape) self.assertEqual(tf_utils.example_image_format(ex), self.default_format)
def testMakeExample(self): example = tf_utils.make_example(self.variant, self.alts, self.encoded_image, self.default_shape, self.default_format) self.assertEqual(self.encoded_image, tf_utils.example_encoded_image(example)) self.assertEqual( 'raw', example.features.feature['image/format'].bytes_list.value[0]) self.assertEqual(self.variant, tf_utils.example_variant(example)) self.assertEqual('1:11-11', tf_utils.example_locus(example)) self.assertEqual([0], tf_utils.example_alt_alleles_indices(example)) self.assertEqual('1:11:C->A', tf_utils.example_key(example))
def test_create_pileup_examples(self): self.processor.pic = mock.Mock() self.add_mock( '_encode_tensor', side_effect=[('tensor1', self.default_shape, self.default_format), ('tensor2', self.default_shape, self.default_format)]) dv_call = mock.Mock() dv_call.variant = test_utils.make_variant(start=10, alleles=['A', 'C', 'G']) ex = mock.Mock() alt1, alt2 = ['C'], ['G'] self.processor.pic.create_pileup_images.return_value = [(alt1, 'tensor1'), (alt2, 'tensor2')] actual = self.processor.create_pileup_examples(dv_call) self.processor.pic.create_pileup_images.assert_called_once_with(dv_call) self.assertEquals(len(actual), 2) for ex, (alt, img) in zip(actual, [(alt1, 'tensor1'), (alt2, 'tensor2')]): self.assertEqual(tf_utils.example_alt_alleles(ex), alt) self.assertEqual(tf_utils.example_variant(ex), dv_call.variant) self.assertEqual(tf_utils.example_encoded_image(ex), img) self.assertEqual(tf_utils.example_image_shape(ex), self.default_shape) self.assertEqual(tf_utils.example_image_format(ex), self.default_format)
def test_create_pileup_examples(self): self.processor.pic = mock.Mock() self.processor.pic.get_reads.return_value = [] self.add_mock('_encode_tensor', side_effect=[(six.b('tensor1'), self.default_shape, self.default_format), (six.b('tensor2'), self.default_shape, self.default_format)]) dv_call = mock.Mock() dv_call.variant = test_utils.make_variant(start=10, alleles=['A', 'C', 'G']) ex = mock.Mock() alt1, alt2 = ['C'], ['G'] self.processor.pic.create_pileup_images.return_value = [ (alt1, six.b('tensor1')), (alt2, six.b('tensor2')) ] actual = self.processor.create_pileup_examples(dv_call) self.processor.pic.create_pileup_images.assert_called_once_with( dv_call=dv_call, reads_for_samples=[[]], haplotype_alignments_for_samples=None, haplotype_sequences=None, sample_order=None) self.assertLen(actual, 2) for ex, (alt, img) in zip(actual, [(alt1, six.b('tensor1')), (alt2, six.b('tensor2'))]): self.assertEqual(tf_utils.example_alt_alleles(ex), alt) self.assertEqual(tf_utils.example_variant(ex), dv_call.variant) self.assertEqual(tf_utils.example_encoded_image(ex), img) self.assertEqual(tf_utils.example_image_shape(ex), self.default_shape) self.assertEqual(tf_utils.example_image_format(ex), six.b(self.default_format))