def test_make_adapter_report_dataset(self):
        """
        Test make_adapter_report with a dataset
        """
        # All of the histogram generation code should be tested in
        # pbcore.io.dataset, not here. Just test the report.
        try:
            log.info(
                TestXMLstatsRpts.test_make_adapter_report_dataset.__doc__)
            sts_xml = data.getXmlWithStats()
            rpt = make_adapter_report(sts_xml, self.get_output_dir())

            d = json.loads(rpt.to_json())

            t = d['tables'][0]
            c0 = t['columns'][0]
            c1 = t['columns'][1]

            self.assertEqual('Adapter Dimers (0-10bp)', c0['values'][0])
            self.assertEqual('Short Inserts (11-100bp)', c0['values'][1])
            self.assertEqual(0.0, c1['values'][0])
            self.assertEqual(0.0, c1['values'][1])
            self.assertTrue(os.path.exists(os.path.join(
                self.get_output_dir(),
                'interAdapterDist0.png')))
            self.assertTrue(os.path.exists(os.path.join(
                self.get_output_dir(),
                'interAdapterDist1.png')))

        except:
            log.error(traceback.format_exc())
            raise
    def test_make_loading_report_with_dataset(self):
        """
        Test the content of the loading report generated from a dataset
        """
        sts_xml = data.getXmlWithStats()

        rpt = make_loading_report(sts_xml)
        d = json.loads(rpt.to_json())

        t = d['tables'][0]
        c0 = t['columns'][0]
        c1 = t['columns'][1]
        c2 = t['columns'][2]
        c3 = t['columns'][3]
        c4 = t['columns'][4]

        self.assertEqual('Collection Context', c0['header'])
        self.assertEqual('loading_xml_report.loading_xml_table.'
                         'collection_context', c0['id'])
        self.assertEqual('Combined', c0['values'][0])
        # Turn these back on when a context is inserted in the testdataset:
        #self.assertEqual('dummy1', c0['values'][1])
        #self.assertEqual('dummy2', c0['values'][2])
        self.assertEqual('NA', c0['values'][1])
        self.assertEqual('NA', c0['values'][2])

        self.assertEqual('Productive ZMWs', c1['header'])
        self.assertEqual('loading_xml_report.loading_xml_table.'
                         'productive_zmws', c1['id'])
        self.assertEqual(153168, c1['values'][0])
        self.assertEqual(2876, c1['values'][1])
        self.assertEqual(150292, c1['values'][2])

        self.assertEqual('Productivity 0 (%)',
                         c2['header'])
        self.assertEqual('loading_xml_report.loading_xml_table.'
                         'productivity_0',
                         c2['id'])
        self.assertAlmostEqual(78.985, c2['values'][0], delta=.0003)
        self.assertAlmostEqual(54.798, c2['values'][1], delta=.0003)
        self.assertAlmostEqual(79.447, c2['values'][2], delta=.0003)

        self.assertEqual('Productivity 1 (%)',
                         c3['header'])
        self.assertEqual('loading_xml_report.loading_xml_table.'
                         'productivity_1',
                         c3['id'])
        self.assertAlmostEqual(16.402, c3['values'][0], delta=.0003)
        self.assertAlmostEqual(31.328, c3['values'][1], delta=.0003)
        self.assertAlmostEqual(16.117, c3['values'][2], delta=.0003)

        self.assertEqual('Productivity 2 (%)',
                         c4['header'])
        self.assertEqual('loading_xml_report.loading_xml_table.'
                         'productivity_2',
                         c4['id'])
        self.assertAlmostEqual(4.613, c4['values'][0], delta=.0003)
        self.assertAlmostEqual(13.873, c4['values'][1], delta=.0003)
        self.assertAlmostEqual(4.436, c4['values'][2], delta=.0003)
    def test_make_loading_report_with_dataset(self):
        """
        Test the content of the loading report generated from a dataset
        """
        sts_xml = data.getXmlWithStats()

        rpt = make_loading_report(sts_xml)
        d = json.loads(rpt.to_json())

        t = d["tables"][0]
        c0 = t["columns"][0]
        c1 = t["columns"][1]
        c2 = t["columns"][2]
        c3 = t["columns"][3]
        c4 = t["columns"][4]

        self.assertEqual("Collection Context", c0["header"])
        self.assertEqual("loading_xml_report.loading_xml_table." "collection_context", c0["id"])
        self.assertEqual("Combined", c0["values"][0])
        # Turn these back on when a context is inserted in the testdataset:
        # self.assertEqual('dummy1', c0['values'][1])
        # self.assertEqual('dummy2', c0['values'][2])
        self.assertEqual("NA", c0["values"][1])
        self.assertEqual("NA", c0["values"][2])

        self.assertEqual("Productive ZMWs", c1["header"])
        self.assertEqual("loading_xml_report.loading_xml_table." "productive_zmws", c1["id"])
        self.assertEqual(153168, c1["values"][0])
        self.assertEqual(2876, c1["values"][1])
        self.assertEqual(150292, c1["values"][2])

        self.assertEqual("Productivity 0 (%)", c2["header"])
        self.assertEqual("loading_xml_report.loading_xml_table." "productivity_0", c2["id"])
        self.assertAlmostEqual(78.985, c2["values"][0], delta=0.0003)
        self.assertAlmostEqual(54.798, c2["values"][1], delta=0.0003)
        self.assertAlmostEqual(79.447, c2["values"][2], delta=0.0003)

        self.assertEqual("Productivity 1 (%)", c3["header"])
        self.assertEqual("loading_xml_report.loading_xml_table." "productivity_1", c3["id"])
        self.assertAlmostEqual(16.402, c3["values"][0], delta=0.0003)
        self.assertAlmostEqual(31.328, c3["values"][1], delta=0.0003)
        self.assertAlmostEqual(16.117, c3["values"][2], delta=0.0003)

        self.assertEqual("Productivity 2 (%)", c4["header"])
        self.assertEqual("loading_xml_report.loading_xml_table." "productivity_2", c4["id"])
        self.assertAlmostEqual(4.613, c4["values"][0], delta=0.0003)
        self.assertAlmostEqual(13.873, c4["values"][1], delta=0.0003)
        self.assertAlmostEqual(4.436, c4["values"][2], delta=0.0003)
        validate_report_complete(self, rpt)
    def test_make_filter_stats_report_dataset(self):
        """
        Test the content of the filter report generated from a dataset
        """
        try:
            log.info(
                TestXMLstatsRpts.test_make_filter_stats_report_dataset.__doc__)
            sts_xml = data.getXmlWithStats()

            rpt = make_filter_report(sts_xml, self.get_output_dir())

            d = json.loads(rpt.to_json())

            t = d['tables'][0]
            c0 = t['columns'][0]
            c1 = t['columns'][1]
            self.assertEqual('Metrics', c0['header'])
            self.assertEqual('filtering_stats_xml_report.filter_xml_table.'
                             'filter_names_column', c0['id'])
            self.assertEqual('Polymerase Read Bases', c0['values'][0])
            self.assertEqual('Polymerase Reads', c0['values'][1])
            self.assertEqual('Polymerase Read N50', c0['values'][2])
            self.assertEqual('Polymerase Read Length', c0['values'][3])
            self.assertEqual('Polymerase Read Quality', c0['values'][4])

            self.assertEqual('Values', c1['header'])
            self.assertEqual('filtering_stats_xml_report.filter_xml_table.'
                             'filter_stats_column', c1['id'])
            self.assertEqual(393167212.65, c1['values'][0])
            self.assertEqual(25123, c1['values'][1])
            self.assertEqual(21884, c1['values'][2])
            self.assertEqual(15649.69, c1['values'][3])
            self.assertEqual(0.86, c1['values'][4])
            self.assertTrue(os.path.exists(os.path.join(
                self.get_output_dir(),
                'readLenDist0.png')))
            self.assertTrue(os.path.exists(os.path.join(
                self.get_output_dir(),
                'readQualDist0.png')))
            self.assertTrue(os.path.exists(os.path.join(
                self.get_output_dir(),
                'readLenDist1.png')))
            self.assertTrue(os.path.exists(os.path.join(
                self.get_output_dir(),
                'readQualDist1.png')))

        except:
            log.error(traceback.format_exc())
            raise
 def test_make_filter_stats_report_dataset_multiple_chips(self):
     sts_xml = data.getXmlWithStats()
     rpt = make_filter_report(sts_xml, self.get_output_dir())
     d = json.loads(rpt.to_json())
     self._compare_attribute_values(
         report_d=d,
         expected_d={
             Constants.A_NBASES: 342348413,
             Constants.A_NREADS: 25123,
             Constants.A_READ_N50: 21884,
             Constants.A_READ_LENGTH: 13627,
         },
     )
     self.assertTrue(os.path.exists(os.path.join(self.get_output_dir(), "readLenDist0.png")))
     self.assertTrue(os.path.exists(os.path.join(self.get_output_dir(), "readLenDist1.png")))
 def test_make_adapter_report_dataset(self):
     """
     Test make_adapter_report with a dataset
     """
     # All of the histogram generation code should be tested in
     # pbcore.io.dataset, not here. Just test the report.
     sts_xml = data.getXmlWithStats()
     rpt = make_adapter_report(sts_xml, self.get_output_dir())
     d = json.loads(rpt.to_json())
     a = d["attributes"]
     self.assertEqual(a[0]["name"], "Adapter Dimers (0-10bp) %")
     self.assertEqual(a[0]["value"], 0.0)
     self.assertEqual(a[1]["value"], 0.0)
     self.assertTrue(os.path.exists(os.path.join(self.get_output_dir(), "interAdapterDist0.png")))
     self.assertTrue(os.path.exists(os.path.join(self.get_output_dir(), "interAdapterDist1.png")))
     validate_report_complete(self, rpt)