def test_create_histogram(self): """ Simple (non null) test of histogram """ tcs = get_top_contigs(self.REFERENCE, 25) als = self.GFF pls = _get_contigs_to_plot(als, tcs) stats = _get_reference_coverage_stats(pls.values()) fig, ax = _create_histogram(stats) self.assertIsNotNone(fig) self.assertIsNotNone(ax)
def test_get_coverage_stats(self): """ Test the coverage stats object (needs more) """ tcs = get_top_contigs(self.REFERENCE, 25) als = self.GFF pls = _get_contigs_to_plot(als, tcs) contig = tcs[0] c_cov = pls[contig.header] stats = _get_reference_coverage_stats(pls.values()) self.assertEqual(485, len(stats.means))
def test_create_histogram(self): """ Simple (non null) test of histogram """ tcs = get_top_contigs(self.REFERENCE, 25) als = self.GFF pls = _get_contigs_to_plot(als, tcs) stats = _get_reference_coverage_stats(pls.values()) fig, ax = CoverageReport()._create_histogram(stats) self.assertIsNotNone(fig) self.assertIsNotNone(ax)
def test_get_coverage_stats(self): """ Test the coverage stats object (needs more) """ tcs = get_top_contigs(self.REFERENCE, 25) als = self.GFF pls = _get_contigs_to_plot(als, tcs) contig = tcs[0] c_cov = pls[contig.header] stats = _get_reference_coverage_stats(pls.values()) self.assertEqual(485, len(stats.means))
def test_create_contig_plot(self): """ Simple non-null test of single contig fig,ax """ tcs = get_top_contigs(self.REFERENCE, 25) als = self.GFF pls = _get_contigs_to_plot(als, tcs) contig = tcs[0] c_cov = pls[contig.header] fig, ax = CoverageReport()._create_contig_plot(c_cov) self.assertIsNotNone(fig) self.assertIsNotNone(ax)
def test_get_coverage_stats(self): """ Test the coverage stats object (needs more) """ ref = os.path.join(self._data_dir, 'references', 'lambda') tcs = get_top_contigs(ref, 25) als = os.path.join(self._data_dir, 'alignment_summary.lambda.gff') pls = _get_contigs_to_plot(als, tcs) contig = tcs[0] c_cov = pls[contig.header] stats = _get_reference_coverage_stats(pls.values()) self.assertEqual(485, len(stats.means))
def test_create_contig_plot(self): """ Simple non-null test of single contig fig,ax """ tcs = get_top_contigs(self.REFERENCE, 25) als = self.GFF pls = _get_contigs_to_plot(als, tcs) contig = tcs[0] c_cov = pls[contig.header] fig, ax = _create_contig_plot(c_cov) self.assertIsNotNone(fig) self.assertIsNotNone(ax)
def test_contigs_to_plot(self): """ Test top contigs from ref """ tcs = get_top_contigs(self.REFERENCE, 25) self.assertEqual(1, len(tcs)) # op.join(self._data_dir, 'alignment_summary.lambda.gff') als = self.GFF pls = _get_contigs_to_plot(als, tcs) self.assertEqual(len(pls), len(tcs)) contig = tcs[0] c_cov = pls[contig.header] self.assertEqual(self.CONTIG_ID, c_cov._name) self.assertEqual(self.PLOT_FILE_NAME, op.basename(c_cov.file_name))
def test_attributes_high_coverage(self): tcs = get_top_contigs(self.REFERENCE, 25) als = op.join(self._data_dir, "alignment_summary.lambda.gff") pls = _get_contigs_to_plot(als, tcs) contig = tcs[0] c_cov = pls[contig.header] stats = _get_reference_coverage_stats(pls.values()) att = _get_att_mean_coverage(stats) # This was in coverage.xml for the alignment summary gff used # attribute hidden="true" id="depth_coverage_mean" name="Coverage" # value="2958.16">2958.16</attribute> self.assertEqual(2958, int(att.value)) att = _get_att_percent_missing(stats) self.assertEqual(0, att.value)
def test_create_contig_plot(self): """ Simple non-null test of single contig fig,ax """ ref = os.path.join(self._data_dir, 'references', 'lambda') tcs = get_top_contigs(ref, 25) als = os.path.join(self._data_dir, 'alignment_summary.lambda.gff') pls = _get_contigs_to_plot(als, tcs) contig = tcs[0] c_cov = pls[contig.header] fig, ax = _create_contig_plot(c_cov) self.assertIsNotNone(fig) self.assertIsNotNone(ax)
def test_attributes_high_coverage(self): tcs = get_top_contigs(self.REFERENCE, 25) als = op.join(self._data_dir, "alignment_summary.lambda.gff") pls = _get_contigs_to_plot(als, tcs) contig = tcs[0] c_cov = pls[contig.header] stats = _get_reference_coverage_stats(pls.values()) att = _get_att_mean_coverage(stats) # This was in coverage.xml for the alignment summary gff used # attribute hidden="true" id="depth_coverage_mean" name="Coverage" # value="2958.16">2958.16</attribute> self.assertAlmostEqual(2958.16, att.value, places=2) att = _get_att_percent_missing(stats) self.assertEqual(0, att.value)
def test_contigs_to_plot(self): """ Test top contigs from ref """ tcs = get_top_contigs(self.REFERENCE, 25) self.assertEqual(1, len(tcs)) # op.join(self._data_dir, 'alignment_summary.lambda.gff') als = self.GFF pls = _get_contigs_to_plot(als, tcs) self.assertEqual(len(pls), len(tcs)) contig = tcs[0] c_cov = pls[contig.header] self.assertEqual(self.CONTIG_ID, c_cov._name) self.assertEqual(self.PLOT_FILE_NAME, op.basename(c_cov.file_name))
def test_contigs_to_plot(self): """ Test top contigs from ref """ ref = os.path.join(self._data_dir, 'references', 'lambda') tcs = get_top_contigs(ref, 25) self.assertEqual(1, len(tcs)) als = os.path.join(self._data_dir, 'alignment_summary.lambda.gff') pls = _get_contigs_to_plot(als, tcs) self.assertEqual(len(pls), len(tcs)) contig = tcs[0] c_cov = pls[contig.header] self.assertEqual('lambda_NEB3011', c_cov._name)
def test_create_histogram(self): """ Simple (non null) test of histogram """ ref = os.path.join(self._data_dir, 'references', 'lambda') tcs = get_top_contigs(ref, 25) als = os.path.join(self._data_dir, 'alignment_summary.lambda.gff') pls = _get_contigs_to_plot(als, tcs) stats = _get_reference_coverage_stats(pls.values()) fig, ax = _create_histogram(stats) self.assertIsNotNone(fig) self.assertIsNotNone(ax)
def test_create_coverage_histo_plot_grp(self): """ Test that plotGroup of the histogram is created as expected """ tcs = get_top_contigs(self.REFERENCE, 25) als = self.GFF pls = _get_contigs_to_plot(als, tcs) stats = _get_reference_coverage_stats(pls.values()) plot_group = _create_coverage_histo_plot_grp(stats, self._output_dir) # only 1 histo self.assertEqual(1, len(plot_group.plots)) self._assert_image_file(plot_group.thumbnail) for plot in plot_group.plots: self._assert_image_file(plot.image)
def test_create_coverage_plot_grp(self): """ Test that plotGroup of coverage plots is created as expected """ tcs = get_top_contigs(self.REFERENCE, 25) als = self.GFF pls = _get_contigs_to_plot(als, tcs) plot_group = _create_coverage_plot_grp(tcs, pls, self._output_dir) # only 1 contig in lambda self.assertEqual(1, len(plot_group.plots)) self._assert_image_file(plot_group.thumbnail) for plot in plot_group.plots: self._assert_image_file(plot.image)
def test_create_coverage_plot_grp(self): """ Test that plotGroup of coverage plots is created as expected """ tcs = get_top_contigs(self.REFERENCE, 25) als = self.GFF pls = _get_contigs_to_plot(als, tcs) plot_group = CoverageReport()._create_coverage_plot_grp( tcs, pls, self._output_dir) # only 1 contig in lambda self.assertEqual(1, len(plot_group.plots)) self._assert_image_file(plot_group.thumbnail) for plot in plot_group.plots: self._assert_image_file(plot.image)
def test_create_coverage_histo_plot_grp(self): """ Test that plotGroup of the histogram is created as expected """ tcs = get_top_contigs(self.REFERENCE, 25) als = self.GFF pls = _get_contigs_to_plot(als, tcs) stats = _get_reference_coverage_stats(pls.values()) plot_group = CoverageReport()._create_coverage_histo_plot_grp( stats, self._output_dir) # only 1 histo self.assertEqual(1, len(plot_group.plots)) self._assert_image_file(plot_group.thumbnail) for plot in plot_group.plots: self._assert_image_file(plot.image)
def test_create_coverage_plot_grp(self): """ Test that plotGroup of coverage plots is created as expected """ ref = os.path.join(self._data_dir, 'references', 'lambda') tcs = get_top_contigs(ref, 25) als = os.path.join(self._data_dir, 'alignment_summary.lambda.gff') pls = _get_contigs_to_plot(als, tcs) plot_group = _create_coverage_plot_grp(tcs, pls, self._output_dir) # only 1 contig in lambda self.assertEqual(1, len(plot_group.plots)) self._assert_image_file(plot_group.thumbnail) for plot in plot_group.plots: self._assert_image_file(plot.image)
def test_attributes(self): """ Test that attribute values match expected """ tcs = get_top_contigs(self.REFERENCE, 25) als = self.GFF pls = _get_contigs_to_plot(als, tcs) contig = tcs[0] c_cov = pls[contig.header] stats = _get_reference_coverage_stats(pls.values()) att = _get_att_mean_coverage(stats) # This was in coverage.xml for the alignment summary gff used # attribute hidden="true" id="depth_coverage_mean" name="Coverage" # value="2958.16">2958.16</attribute> self.assertEqual(1, int(att.value)) att = _get_att_percent_missing(stats) self.assertAlmostEqual(0.584, att.value, places=3)
def test_attributes(self): """ Test that attribute values match expected """ tcs = get_top_contigs(self.REFERENCE, 25) als = self.GFF pls = _get_contigs_to_plot(als, tcs) contig = tcs[0] c_cov = pls[contig.header] stats = _get_reference_coverage_stats(pls.values()) att = _get_att_mean_coverage(stats) # This was in coverage.xml for the alignment summary gff used # attribute hidden="true" id="depth_coverage_mean" name="Coverage" # value="2958.16">2958.16</attribute> self.assertAlmostEqual(1.228, att.value, places=3) att = _get_att_percent_missing(stats) self.assertAlmostEqual(58.4, att.value, places=1)
def test_attributes(self): """ Test that attribute values match expected """ ref = os.path.join(self._data_dir, 'references', 'lambda') tcs = get_top_contigs(ref, 25) als = os.path.join(self._data_dir, 'alignment_summary.lambda.gff') pls = _get_contigs_to_plot(als, tcs) contig = tcs[0] c_cov = pls[contig.header] stats = _get_reference_coverage_stats(pls.values()) att = _get_att_mean_coverage(stats) # This was in coverage.xml for the alignment summary gff used # attribute hidden="true" id="depth_coverage_mean" name="Coverage" value="2958.16">2958.16</attribute> self.assertEqual(2958.1640346377467, att.value) att = _get_att_percent_missing(stats) self.assertEqual(0, att.value)
def test__get_contigs_to_plot(self): top_contigs = get_top_contigs(self.REFERENCE, 25) cov_map = _get_contigs_to_plot(self.GFF, top_contigs) self.assertNotEqual(len(cov_map), 0)
def test__get_contigs_to_plot(self): top_contigs = get_top_contigs(self.REFERENCE, 25) cov_map = _get_contigs_to_plot(self.GFF, top_contigs) self.assertNotEqual(len(cov_map), 0)