def test_get_consensus_table(self):
        """
        Test the data in the table object and the attributes
        """
        top_contigs = get_top_contigs_from_ref_entry(self._get_reference_entry(), 2)

        ref_data = _extract_alignment_summ_data(self.ALIGNMENT_SUMMARY, top_contigs)[0]
        self.assertEqual(1, len(ref_data))

        results = ref_data[self.CONTIG_ID]
        self.assertEqual(self.TEST_VALUES["contig_len"], results[LENGTH])
        self.assertEqual(0, results[ERR])

        _append_variants_gff_data(ref_data, self.VARIANTS_GFF)

        table, attributes = _get_consensus_table_and_attributes(ref_data, self._get_reference_entry())
        self.assertEqual(5, len(table.columns))
        self.assertEqual(self.CONTIG_ID, table.columns[0].values[0])
        self.assertEqual(self.TEST_VALUES["contig_len"],
                         table.columns[1].values[0])
        self.assertEqual(1, table.columns[2].values[0])
        self.assertAlmostEqual(self.TEST_VALUES["concordance"],
                               table.columns[3].values[0], places=4)
        self.assertAlmostEqual(self.TEST_VALUES["coverage"],
                               table.columns[4].values[0], places=2)
Example #2
0
    def test_get_consensus_table(self):
        """
        Test the data in the table object and the attributes
        """
        top_contigs = get_top_contigs_from_ref_entry(
            self._get_reference_entry(), 2)

        ref_data = _extract_alignment_summ_data(self.ALIGNMENT_SUMMARY,
                                                top_contigs)[0]
        self.assertEqual(1, len(ref_data))

        results = ref_data[self.CONTIG_ID]
        self.assertEqual(self.TEST_VALUES["contig_len"], results[LENGTH])
        self.assertEqual(0, results[ERR])

        _append_variants_gff_data(ref_data, self.VARIANTS_GFF)

        table, attributes = _get_consensus_table_and_attributes(
            ref_data, self._get_reference_entry())
        self.assertEqual(5, len(table.columns))
        self.assertEqual(self.CONTIG_ID, table.columns[0].values[0])
        self.assertEqual(self.TEST_VALUES["contig_len"],
                         table.columns[1].values[0])
        self.assertEqual(1, table.columns[2].values[0])
        self.assertAlmostEqual(self.TEST_VALUES["concordance"],
                               table.columns[3].values[0],
                               places=4)
        self.assertAlmostEqual(self.TEST_VALUES["coverage"],
                               table.columns[4].values[0],
                               places=2)
    def test_get_consensus_attributes(self):
        """
        Test the data in the table object and the attributes
        """
        top_contigs = get_top_contigs_from_ref_entry(self._get_reference_entry(), 2)

        ref_data = _extract_alignment_summ_data(self.ALIGNMENT_SUMMARY, top_contigs)[0]
        self.assertEqual(1, len(ref_data))

        results = ref_data[self.CONTIG_ID]
        self.assertEqual(self.TEST_VALUES["contig_len"], results[LENGTH])
        self.assertEqual(0, results[ERR])

        _append_variants_gff_data(ref_data, self.VARIANTS_GFF)

        table, attributes = _get_consensus_table_and_attributes(ref_data, self._get_reference_entry())
        self.assertEqual(5, len(attributes))

        def __get_att_val(_id, atts):
            for a in atts:
                if a.id == _id:
                    return a.value

        self.assertEqual(self.TEST_VALUES["contig_len"], __get_att_val("mean_contig_length", attributes))
        self.assertAlmostEqual(
            self.TEST_VALUES["bases_called"], __get_att_val("weighted_mean_bases_called", attributes), places=4
        )
        self.assertAlmostEqual(
            self.TEST_VALUES["concordance"], __get_att_val("weighted_mean_concordance", attributes), places=4
        )
        self.assertAlmostEqual(
            self.TEST_VALUES["coverage"], __get_att_val("weighted_mean_coverage", attributes), places=2
        )
        self.assertEqual(self.CONTIG_ID, __get_att_val("longest_contig_name", attributes))
    def test_append_variants_gff_data(self):
        """
        Test that ERR information gets added to the ref_data dict
        """
#        top_contigs = get_top_contigs(ref, 2)

        top_contigs = get_top_contigs_from_ref_entry(self._get_reference_entry(), 2)

        ref_data = _extract_alignment_summ_data(self.ALIGNMENT_SUMMARY, top_contigs)[0]
        self.assertEqual(1, len(ref_data))

        results = ref_data[self.CONTIG_ID]
        self.assertEqual(self.TEST_VALUES["contig_len"], results[LENGTH])
        self.assertEqual(self.TEST_VALUES["n_gff_err_1"], results[ERR])

        _append_variants_gff_data(ref_data, self.VARIANTS_GFF)
        self.assertEqual(self.TEST_VALUES["contig_len"], results[LENGTH])
        self.assertEqual(self.TEST_VALUES["n_gff_err_2"], results[ERR])
Example #5
0
    def test_get_consensus_attributes(self):
        """
        Test the data in the table object and the attributes
        """
        top_contigs = get_top_contigs_from_ref_entry(
            self._get_reference_entry(), 2)

        ref_data = _extract_alignment_summ_data(self.ALIGNMENT_SUMMARY,
                                                top_contigs)[0]
        self.assertEqual(1, len(ref_data))

        results = ref_data[self.CONTIG_ID]
        self.assertEqual(self.TEST_VALUES["contig_len"], results[LENGTH])
        self.assertEqual(0, results[ERR])

        _append_variants_gff_data(ref_data, self.VARIANTS_GFF)

        table, attributes = _get_consensus_table_and_attributes(
            ref_data, self._get_reference_entry())
        self.assertEqual(5, len(attributes))

        def __get_att_val(_id, atts):
            for a in atts:
                if a.id == _id:
                    return a.value

        self.assertEqual(self.TEST_VALUES["contig_len"],
                         __get_att_val('mean_contig_length', attributes))
        self.assertAlmostEqual(self.TEST_VALUES["bases_called"],
                               __get_att_val('weighted_mean_bases_called',
                                             attributes),
                               places=4)
        self.assertAlmostEqual(self.TEST_VALUES["concordance"],
                               __get_att_val('weighted_mean_concordance',
                                             attributes),
                               places=4)
        self.assertAlmostEqual(self.TEST_VALUES["coverage"],
                               __get_att_val('weighted_mean_coverage',
                                             attributes),
                               places=2)
        self.assertEqual(self.CONTIG_ID,
                         __get_att_val('longest_contig_name', attributes))
Example #6
0
    def test_append_variants_gff_data(self):
        """
        Test that ERR information gets added to the ref_data dict
        """
        #        top_contigs = get_top_contigs(ref, 2)

        top_contigs = get_top_contigs_from_ref_entry(
            self._get_reference_entry(), 2)

        ref_data = _extract_alignment_summ_data(self.ALIGNMENT_SUMMARY,
                                                top_contigs)[0]
        self.assertEqual(1, len(ref_data))

        results = ref_data[self.CONTIG_ID]
        self.assertEqual(self.TEST_VALUES["contig_len"], results[LENGTH])
        self.assertEqual(self.TEST_VALUES["n_gff_err_1"], results[ERR])

        _append_variants_gff_data(ref_data, self.VARIANTS_GFF)
        self.assertEqual(self.TEST_VALUES["contig_len"], results[LENGTH])
        self.assertEqual(self.TEST_VALUES["n_gff_err_2"], results[ERR])