def test_show_examples_raises_on_wrong_column_labels(self): output_prefix = test_utils.test_tmpfile('column_labels') FLAGS.examples = testdata.GOLDEN_TRAINING_EXAMPLES FLAGS.output = output_prefix FLAGS.column_labels = 'read base,base quality,mapping quality,strand' with self.assertRaisesRegex(ValueError, '--column_labels'): show_examples.run() # With 6 channel names, it should run without error: FLAGS.column_labels = '1,2,3,4,5,6' show_examples.run()
def test_show_examples_end2end_training_examples(self): output_prefix = test_utils.test_tmpfile('training') FLAGS.examples = testdata.GOLDEN_TRAINING_EXAMPLES FLAGS.output = output_prefix show_examples.run() ls = glob.glob('{}*'.format(output_prefix)) filenames = [os.path.basename(path) for path in ls] self.assertTrue( all(['training_channels' in filename for filename in filenames])) self.assertTrue( all([filename.endswith('.png') for filename in filenames])) self.assertTrue(all(['label' in filename for filename in filenames]), msg='Training examples should produce labeled images.')
def test_show_examples_end2end_all_optional_parameters(self): # Set all the optional parameters to check that they all work together. output_prefix = test_utils.test_tmpfile('kitchen_sink') FLAGS.examples = testdata.GOLDEN_TRAINING_EXAMPLES FLAGS.output = output_prefix FLAGS.annotation = False FLAGS.regions = 'chr20:10,003,650-10,005,000' FLAGS.vcf = testdata.TRUTH_VARIANTS_VCF FLAGS.image_type = 'both' FLAGS.num_records = 5 FLAGS.verbose = False FLAGS.truth_labels = False # On by default for training examples. show_examples.run() ls = glob.glob('{}*'.format(output_prefix)) filenames = [os.path.basename(path) for path in ls] self.assertTrue( any([ 'kitchen_sink_channels' in filename for filename in filenames ]), msg='image_type=both, so there should be images with "channels"') self.assertTrue( any(['kitchen_sink_rgb' in filename for filename in filenames]), msg='image_type=both, so there should be images with "rgb"') self.assertTrue( all([filename.endswith('.png') for filename in filenames])) self.assertFalse(any(['label' in filename for filename in filenames]), msg='Should be no "label" when truth_labels=False') self.assertLen(filenames, 10, msg='Should be 10 filenames, i.e. 5 records with ' 'channels+rgb for each') self.assertCountEqual( filenames, [ 'kitchen_sink_rgb_chr20:10004146_A->G.png', 'kitchen_sink_channels_chr20:10004146_A->G.png', 'kitchen_sink_rgb_chr20:10004093_A->C.png', 'kitchen_sink_channels_chr20:10004093_A->C.png', 'kitchen_sink_rgb_chr20:10003831_G->A.png', 'kitchen_sink_channels_chr20:10003831_G->A.png', 'kitchen_sink_rgb_chr20:10003691_A->G.png', 'kitchen_sink_channels_chr20:10003691_A->G.png', 'kitchen_sink_rgb_chr20:10003650_T->C.png', 'kitchen_sink_channels_chr20:10003650_T->C.png' ], msg= 'Specific examples and their output filenames should be the same ' 'if the inputs are the same.')