Пример #1
0
    def _check_results_base(self):
        jc_raw_se_path = os.path.join(self._out_dir, 'JC.raw.input.SE.txt')
        jc_raw_se_header, jc_raw_se_rows, error = output_parser.parse_jc_raw(
            jc_raw_se_path)
        self.assertFalse(error)
        self.assertEqual(len(jc_raw_se_rows), 1)
        jc_raw_se_row = jc_raw_se_rows[0]
        self.assertEqual(jc_raw_se_row['IJC_SAMPLE_1'], '1,0')
        self.assertEqual(jc_raw_se_row['SJC_SAMPLE_1'], '0,1')
        self.assertEqual(jc_raw_se_row['IJC_SAMPLE_2'], '')
        self.assertEqual(jc_raw_se_row['SJC_SAMPLE_2'], '')

        se_mats_jc_path = os.path.join(self._out_dir, 'SE.MATS.JC.txt')
        se_mats_jc_header, se_mats_jc_rows, error = output_parser.parse_mats_jc(
            se_mats_jc_path)
        self.assertFalse(error)
        self._check_se_mats_jc_header(se_mats_jc_header)
        self.assertEqual(len(se_mats_jc_rows), 1)
        se_mats_jc_row = se_mats_jc_rows[0]
        self.assertEqual(se_mats_jc_row['PValue'], 'NA')
        self.assertEqual(se_mats_jc_row['FDR'], 'NA')
        inc_level_1_splits = se_mats_jc_row['IncLevel1'].split(',')
        self.assertEqual(len(inc_level_1_splits), 2)
        self.assertAlmostEqual(float(inc_level_1_splits[0]), 1)
        self.assertAlmostEqual(float(inc_level_1_splits[1]), 0)
        self.assertEqual(se_mats_jc_row['IncLevel2'], '')
        self.assertEqual(se_mats_jc_row['IncLevelDifference'], 'NA')
Пример #2
0
    def _check_results(self):
        self._check_no_error_results()

        se_mats_jc_path = os.path.join(self._out_dir, 'SE.MATS.JC.txt')
        se_mats_jc_header, se_mats_jc_rows, error = output_parser.parse_mats_jc(
            se_mats_jc_path)
        self.assertFalse(error)
        self._check_se_mats_jc_header(se_mats_jc_header)
        self.assertEqual(len(se_mats_jc_rows), 2)
        se_mats_jc_row_0 = se_mats_jc_rows[0]
        self._check_row(se_mats_jc_row_0, '1,3', '1,0', '0,2', '1,2', 2)
        se_mats_jc_row_1 = se_mats_jc_rows[1]
        self._check_row(se_mats_jc_row_1, '0,2', '1,1', '0,1', '1,1', 2)

        se_mats_jcec_path = os.path.join(self._out_dir, 'SE.MATS.JCEC.txt')
        se_mats_jcec_header, se_mats_jcec_rows, error = output_parser.parse_mats_jcec(
            se_mats_jcec_path)
        self.assertFalse(error)
        self._check_se_mats_jcec_header(se_mats_jcec_header)
        self.assertEqual(len(se_mats_jcec_rows), 2)
        se_mats_jcec_row_0 = se_mats_jcec_rows[0]
        self._check_row(se_mats_jcec_row_0, '2,4', '1,0', '0,3', '1,2', 2)
        se_mats_jcec_row_1 = se_mats_jcec_rows[1]
        self._check_row(se_mats_jcec_row_1, '1,4', '1,1', '1,4', '1,1', 2)

        status_path = os.path.join(self._out_dir, 'tmp', 'JC_SE',
                                   'pairadise_status.txt')
        self.assertTrue(os.path.exists(status_path))
Пример #3
0
    def _check_results_post(self):
        self._check_no_error_results()

        command_stdout_file_name = self._get_stdout_file_name()
        with open(command_stdout_file_name, 'rt') as out_f_h:
            out_lines = out_f_h.readlines()

        tests.util.assert_some_line_has(self, out_lines,
                                        'Processing count files')

        from_gtf_se_path = os.path.join(self._out_dir, 'fromGTF.SE.txt')
        from_gtf_se_header, from_gtf_se_rows, error = output_parser.parse_from_gtf(
            from_gtf_se_path)
        self.assertFalse(error)
        self.assertEqual(len(from_gtf_se_rows), 1)
        from_gtf_se_row = from_gtf_se_rows[0]
        self.assertEqual(from_gtf_se_row['GeneID'],
                         tests.util.double_quote(tests.util.gene_id_str(1)))
        self.assertEqual(from_gtf_se_row['exonStart_0base'], '200')
        self.assertEqual(from_gtf_se_row['exonEnd'], '300')

        jc_raw_se_path = os.path.join(self._out_dir, 'JC.raw.input.SE.txt')
        jc_raw_se_header, jc_raw_se_rows, error = output_parser.parse_jc_raw(
            jc_raw_se_path)
        self.assertFalse(error)
        self.assertEqual(len(jc_raw_se_rows), 1)
        jc_raw_se_row = jc_raw_se_rows[0]
        self.assertEqual(jc_raw_se_row['ID'], from_gtf_se_row['ID'])
        self.assertEqual(jc_raw_se_row['IJC_SAMPLE_1'], '1,1')
        self.assertEqual(jc_raw_se_row['SJC_SAMPLE_1'], '0,0')
        self.assertEqual(jc_raw_se_row['IJC_SAMPLE_2'], '0,0')
        self.assertEqual(jc_raw_se_row['SJC_SAMPLE_2'], '1,1')

        se_mats_jc_path = os.path.join(self._out_dir, 'SE.MATS.JC.txt')
        se_mats_jc_header, se_mats_jc_rows, error = output_parser.parse_mats_jc(
            se_mats_jc_path)
        self.assertFalse(error)
        self._check_se_mats_jc_header(se_mats_jc_header)
        self.assertEqual(len(se_mats_jc_rows), 1)
        se_mats_jc_row = se_mats_jc_rows[0]
        pvalue = float(se_mats_jc_row['PValue'])
        tests.util.assert_within_bounds(self, pvalue, 0, 1)
        fdr = float(se_mats_jc_row['FDR'])
        tests.util.assert_within_bounds(self, fdr, 0, 1)
        inc_level_1_splits = se_mats_jc_row['IncLevel1'].split(',')
        self.assertEqual(len(inc_level_1_splits), 2)
        self.assertAlmostEqual(float(inc_level_1_splits[0]), 1)
        self.assertAlmostEqual(float(inc_level_1_splits[1]), 1)
        inc_level_2_splits = se_mats_jc_row['IncLevel2'].split(',')
        self.assertEqual(len(inc_level_2_splits), 2)
        self.assertAlmostEqual(float(inc_level_2_splits[0]), 0)
        self.assertAlmostEqual(float(inc_level_2_splits[1]), 0)
        self.assertAlmostEqual(float(se_mats_jc_row['IncLevelDifference']), 1)
Пример #4
0
    def _check_results(self):
        self._check_no_error_results()

        se_mats_jc_path = os.path.join(self._out_dir, 'SE.MATS.JC.txt')
        se_mats_jc_header, se_mats_jc_rows, error = output_parser.parse_mats_jc(
            se_mats_jc_path)
        self.assertFalse(error)
        self._check_se_mats_jc_header(se_mats_jc_header)
        self.assertEqual(len(se_mats_jc_rows), 1)
        se_mats_jc_row_0 = se_mats_jc_rows[0]
        self.assertEqual(se_mats_jc_row_0['IJC_SAMPLE_1'], '1,0')
        self.assertEqual(se_mats_jc_row_0['SJC_SAMPLE_1'], '1,0')
        self.assertEqual(se_mats_jc_row_0['IJC_SAMPLE_2'], '1,0')
        self.assertEqual(se_mats_jc_row_0['SJC_SAMPLE_2'], '1,0')
Пример #5
0
    def _get_matched_se_mats_jc_rows(self, gtf_rows):
        matched_rows = [None for _ in range(len(gtf_rows))]

        se_mats_jc_path = os.path.join(self._out_dir, 'SE.MATS.JC.txt')
        se_mats_jc_header, se_mats_jc_rows, error = output_parser.parse_mats_jc(
            se_mats_jc_path)
        self.assertFalse(error)
        self.assertEqual(len(se_mats_jc_rows), len(gtf_rows))
        gtf_ids = [r['ID'] for r in gtf_rows]
        for mats_row in se_mats_jc_rows:
            idx = gtf_ids.index(mats_row['ID'])
            matched_rows[idx] = mats_row

        self.assertTrue(all(matched_rows))
        return matched_rows
Пример #6
0
    def _check_results(self):
        self._check_no_error_results()

        se_mats_jc_path = os.path.join(self._out_dir, 'SE.MATS.JC.txt')
        se_mats_jc_header, se_mats_jc_rows, error = output_parser.parse_mats_jc(
            se_mats_jc_path)
        self.assertFalse(error)
        self._check_se_mats_jc_header(se_mats_jc_header)
        self.assertEqual(len(se_mats_jc_rows), 1)
        se_mats_jc_row_0 = se_mats_jc_rows[0]
        self._check_row(se_mats_jc_row_0, '1,3', '1,1', '0,1', '2,3', 2)

        se_mats_jcec_path = os.path.join(self._out_dir, 'SE.MATS.JCEC.txt')
        se_mats_jcec_header, se_mats_jcec_rows, error = output_parser.parse_mats_jcec(
            se_mats_jcec_path)
        self.assertFalse(error)
        self._check_se_mats_jcec_header(se_mats_jcec_header)
        self.assertEqual(len(se_mats_jcec_rows), 1)
        se_mats_jcec_row_0 = se_mats_jcec_rows[0]
        self._check_row(se_mats_jcec_row_0, '2,6', '1,1', '0,2', '2,3', 2)
Пример #7
0
    def _check_results(self):
        self._check_no_error_results()

        se_mats_jc_path = os.path.join(self._out_dir, 'SE.MATS.JC.txt')
        se_mats_jc_header, se_mats_jc_rows, error = output_parser.parse_mats_jc(
            se_mats_jc_path)
        self.assertFalse(error)
        self._check_se_mats_jc_header(se_mats_jc_header)
        self.assertEqual(len(se_mats_jc_rows), 2)
        expected_genes = [
            tests.util.double_quote(tests.util.gene_id_str(i)) for i in [1, 2]
        ]
        for row in se_mats_jc_rows:
            self.assertIn(row['exonStart_0base'], ['200', '1200'])
            if row['exonStart_0base'] == '200':
                self.assertEqual(row['IJC_SAMPLE_1'], '1,0')
                self.assertEqual(row['SJC_SAMPLE_1'], '1,0')
                self.assertIn(row['GeneID'], expected_genes)
            elif row['exonStart_0base'] == '1200':
                self.assertEqual(row['IJC_SAMPLE_1'], '0,1')
                self.assertEqual(row['SJC_SAMPLE_1'], '0,1')
                self.assertEqual(row['GeneID'], expected_genes[0])

        from_gtf_se_path = os.path.join(self._out_dir, 'fromGTF.SE.txt')
        from_gtf_se_header, from_gtf_se_rows, error = (
            output_parser.parse_from_gtf(from_gtf_se_path))
        self.assertFalse(error)
        self.assertEqual(len(from_gtf_se_rows), 2)
        gtf_coords = list()
        for row in from_gtf_se_rows:
            gtf_coords.append(row['exonStart_0base'])

        self.assertEqual(sorted(gtf_coords), ['1200', '200'])

        from_gtf_nj_se_path = os.path.join(self._out_dir,
                                           'fromGTF.novelJunction.SE.txt')
        from_gtf_nj_se_header, from_gtf_nj_se_rows, error = (
            output_parser.parse_from_gtf_novel_junction(from_gtf_nj_se_path))
        self.assertFalse(error)
        self.assertEqual(len(from_gtf_nj_se_rows), 0)
Пример #8
0
    def _check_results(self):
        self._check_no_error_results()

        se_mats_jc_path = os.path.join(self._out_dir, 'SE.MATS.JC.txt')
        se_mats_jc_header, se_mats_jc_rows, error = output_parser.parse_mats_jc(
            se_mats_jc_path)
        self.assertFalse(error)
        self._check_se_mats_jc_header(se_mats_jc_header)
        self.assertEqual(len(se_mats_jc_rows), 3)
        se_mats_jc_row_0 = se_mats_jc_rows[0]
        self._check_row(se_mats_jc_row_0, '1,0', '1,0', '1,0', '1,0', 2)
        se_mats_jc_row_1 = se_mats_jc_rows[1]
        self._check_row(se_mats_jc_row_1,
                        '0,1',
                        '0,1',
                        '1,0',
                        '1,0',
                        2,
                        expect_nan_pvalue=True)
        se_mats_jc_row_2 = se_mats_jc_rows[2]
        self._check_row(se_mats_jc_row_2, '0,1', '0,1', '0,1', '0,1', 2)

        se_mats_jcec_path = os.path.join(self._out_dir, 'SE.MATS.JCEC.txt')
        se_mats_jcec_header, se_mats_jcec_rows, error = output_parser.parse_mats_jcec(
            se_mats_jcec_path)
        self.assertFalse(error)
        self._check_se_mats_jcec_header(se_mats_jcec_header)
        self.assertEqual(len(se_mats_jcec_rows), 3)
        se_mats_jcec_row_0 = se_mats_jcec_rows[0]
        self._check_row(se_mats_jcec_row_0, '2,0', '1,0', '2,0', '1,0', 2)
        se_mats_jcec_row_1 = se_mats_jcec_rows[1]
        self._check_row(se_mats_jcec_row_1,
                        '0,2',
                        '0,1',
                        '2,0',
                        '1,0',
                        2,
                        expect_nan_pvalue=True)
        se_mats_jcec_row_2 = se_mats_jcec_rows[2]
        self._check_row(se_mats_jcec_row_2, '0,2', '0,1', '0,2', '0,1', 2)
Пример #9
0
    def _check_results(self):
        self._check_no_error_results()

        se_mats_jc_path = os.path.join(self._out_dir, 'SE.MATS.JC.txt')
        se_mats_jc_header, se_mats_jc_rows, error = output_parser.parse_mats_jc(
            se_mats_jc_path)
        self.assertFalse(error)
        self._check_se_mats_jc_header(se_mats_jc_header)
        self.assertEqual(len(se_mats_jc_rows), 2)
        for row in se_mats_jc_rows:
            self.assertIn(row['exonStart_0base'], ['200', '1200'])
            if row['exonStart_0base'] == '200':
                self.assertEqual(row['IJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['SJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['strand'], '+')
            elif row['exonStart_0base'] == '1200':
                self.assertEqual(row['IJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['SJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['strand'], '-')

        se_mats_jcec_path = os.path.join(self._out_dir, 'SE.MATS.JCEC.txt')
        se_mats_jcec_header, se_mats_jcec_rows, error = (
            output_parser.parse_mats_jcec(se_mats_jcec_path))
        self.assertFalse(error)
        self._check_se_mats_jcec_header(se_mats_jcec_header)
        self.assertEqual(len(se_mats_jcec_rows), 2)
        for row in se_mats_jcec_rows:
            self.assertIn(row['exonStart_0base'], ['200', '1200'])
            if row['exonStart_0base'] == '200':
                self.assertEqual(row['IJC_SAMPLE_1'], '2,2')
                self.assertEqual(row['SJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['strand'], '+')
            elif row['exonStart_0base'] == '1200':
                self.assertEqual(row['IJC_SAMPLE_1'], '2,2')
                self.assertEqual(row['SJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['strand'], '-')
Пример #10
0
    def _check_results_deferred_stat(self):
        self._check_no_error_results()

        se_mats_jc_path = os.path.join(self._out_dir_all, 'SE.MATS.JC.txt')
        se_mats_jc_header, se_mats_jc_rows, error = output_parser.parse_mats_jc(
            se_mats_jc_path)
        self.assertFalse(error)
        self._check_se_mats_jc_header(se_mats_jc_header)
        self.assertEqual(len(se_mats_jc_rows), 2)
        for row in se_mats_jc_rows:
            self.assertIn(row['exonStart_0base'], ['200', '800'])
            if row['exonStart_0base'] == '200':
                self.assertEqual(row['IJC_SAMPLE_1'], '10,15')
                self.assertEqual(row['SJC_SAMPLE_1'], '10,5')
                self.assertEqual(row['IJC_SAMPLE_2'], '10,10')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,0')
                tests.util.assert_within_bounds(self, float(row['PValue']), 0,
                                                1)
                tests.util.assert_within_bounds(self, float(row['FDR']), 0, 1)
                self.assertEqual(self._read_floats(row['IncLevel1']),
                                 [0.333, 0.6])
                self.assertEqual(self._read_floats(row['IncLevel2']),
                                 [1.0, 1.0])
                self.assertEqual(float(row['IncLevelDifference']), -0.533)
            elif row['exonStart_0base'] == '800':
                self.assertEqual(row['IJC_SAMPLE_1'], '10,10')
                self.assertEqual(row['SJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['IJC_SAMPLE_2'], '10,15')
                self.assertEqual(row['SJC_SAMPLE_2'], '10,5')
                tests.util.assert_within_bounds(self, float(row['PValue']), 0,
                                                1)
                tests.util.assert_within_bounds(self, float(row['FDR']), 0, 1)
                self.assertEqual(self._read_floats(row['IncLevel1']),
                                 [1.0, 1.0])
                self.assertEqual(self._read_floats(row['IncLevel2']),
                                 [0.333, 0.6])
                self.assertEqual(float(row['IncLevelDifference']), 0.533)

        se_mats_jcec_path = os.path.join(self._out_dir_all, 'SE.MATS.JCEC.txt')
        se_mats_jcec_header, se_mats_jcec_rows, error = (
            output_parser.parse_mats_jcec(se_mats_jcec_path))
        self.assertFalse(error)
        self._check_se_mats_jcec_header(se_mats_jcec_header)
        self.assertEqual(len(se_mats_jcec_rows), 2)
        for row in se_mats_jcec_rows:
            self.assertIn(row['exonStart_0base'], ['200', '800'])
            if row['exonStart_0base'] == '200':
                self.assertEqual(row['IJC_SAMPLE_1'], '20,30')
                self.assertEqual(row['SJC_SAMPLE_1'], '10,5')
                self.assertEqual(row['IJC_SAMPLE_2'], '20,20')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,0')
                tests.util.assert_within_bounds(self, float(row['PValue']), 0,
                                                1)
                tests.util.assert_within_bounds(self, float(row['FDR']), 0, 1)
                self.assertEqual(self._read_floats(row['IncLevel1']),
                                 [0.397, 0.664])
                self.assertEqual(self._read_floats(row['IncLevel2']),
                                 [1.0, 1.0])
                self.assertEqual(float(row['IncLevelDifference']), -0.47)

        mxe_mats_jc_path = os.path.join(self._out_dir_all, 'MXE.MATS.JC.txt')
        mxe_mats_jc_header, mxe_mats_jc_rows, error = (
            output_parser.parse_mats_jc(mxe_mats_jc_path))
        self.assertFalse(error)
        self._check_mxe_mats_jc_header(mxe_mats_jc_header)
        self.assertEqual(len(mxe_mats_jc_rows), 1)
        tests.util.assert_within_bounds(self,
                                        float(mxe_mats_jc_rows[0]['FDR']), 0,
                                        1)

        mxe_mats_jcec_path = os.path.join(self._out_dir_all,
                                          'MXE.MATS.JCEC.txt')
        mxe_mats_jcec_header, mxe_mats_jcec_rows, error = (
            output_parser.parse_mats_jcec(mxe_mats_jcec_path))
        self.assertFalse(error)
        self._check_mxe_mats_jcec_header(mxe_mats_jcec_header)
        self.assertEqual(len(mxe_mats_jcec_rows), 1)
        tests.util.assert_within_bounds(self,
                                        float(mxe_mats_jcec_rows[0]['FDR']), 0,
                                        1)

        a5ss_mats_jc_path = os.path.join(self._out_dir_all, 'A5SS.MATS.JC.txt')
        a5ss_mats_jc_header, a5ss_mats_jc_rows, error = (
            output_parser.parse_mats_jc(a5ss_mats_jc_path))
        self.assertFalse(error)
        self._check_a35ss_mats_jc_header(a5ss_mats_jc_header)
        self.assertEqual(len(a5ss_mats_jc_rows), 1)
        tests.util.assert_within_bounds(self,
                                        float(a5ss_mats_jc_rows[0]['FDR']), 0,
                                        1)

        a5ss_mats_jcec_path = os.path.join(self._out_dir_all,
                                           'A5SS.MATS.JCEC.txt')
        a5ss_mats_jcec_header, a5ss_mats_jcec_rows, error = (
            output_parser.parse_mats_jcec(a5ss_mats_jcec_path))
        self.assertFalse(error)
        self._check_a35ss_mats_jcec_header(a5ss_mats_jcec_header)
        self.assertEqual(len(a5ss_mats_jcec_rows), 1)
        tests.util.assert_within_bounds(self,
                                        float(a5ss_mats_jcec_rows[0]['FDR']),
                                        0, 1)

        a3ss_mats_jc_path = os.path.join(self._out_dir_all, 'A3SS.MATS.JC.txt')
        a3ss_mats_jc_header, a3ss_mats_jc_rows, error = (
            output_parser.parse_mats_jc(a3ss_mats_jc_path))
        self.assertFalse(error)
        self._check_a35ss_mats_jc_header(a3ss_mats_jc_header)
        self.assertEqual(len(a3ss_mats_jc_rows), 1)
        tests.util.assert_within_bounds(self,
                                        float(a3ss_mats_jc_rows[0]['FDR']), 0,
                                        1)

        a3ss_mats_jcec_path = os.path.join(self._out_dir_all,
                                           'A3SS.MATS.JCEC.txt')
        a3ss_mats_jcec_header, a3ss_mats_jcec_rows, error = (
            output_parser.parse_mats_jcec(a3ss_mats_jcec_path))
        self.assertFalse(error)
        self._check_a35ss_mats_jcec_header(a3ss_mats_jcec_header)
        self.assertEqual(len(a3ss_mats_jcec_rows), 1)
        tests.util.assert_within_bounds(self,
                                        float(a3ss_mats_jcec_rows[0]['FDR']),
                                        0, 1)

        ri_mats_jc_path = os.path.join(self._out_dir_all, 'RI.MATS.JC.txt')
        ri_mats_jc_header, ri_mats_jc_rows, error = output_parser.parse_mats_jc(
            ri_mats_jc_path)
        self.assertFalse(error)
        self._check_ri_mats_jc_header(ri_mats_jc_header)
        self.assertEqual(len(ri_mats_jc_rows), 1)
        tests.util.assert_within_bounds(self, float(ri_mats_jc_rows[0]['FDR']),
                                        0, 1)

        ri_mats_jcec_path = os.path.join(self._out_dir_all, 'RI.MATS.JCEC.txt')
        ri_mats_jcec_header, ri_mats_jcec_rows, error = (
            output_parser.parse_mats_jcec(ri_mats_jcec_path))
        self.assertFalse(error)
        self._check_ri_mats_jcec_header(ri_mats_jcec_header)
        self.assertEqual(len(ri_mats_jcec_rows), 1)
        tests.util.assert_within_bounds(self,
                                        float(ri_mats_jcec_rows[0]['FDR']), 0,
                                        1)
Пример #11
0
    def _check_results_just_se(self):
        self.assertEqual(self._rmats_return_code, 0)
        command_stderr_file_name = self._get_stderr_file_name()
        with open(command_stderr_file_name, 'rt') as err_f_h:
            err_lines = err_f_h.readlines()

        self.assertEqual(len(err_lines), 9)
        unable_to_produce_lines = collections.defaultdict(int)
        for err_line in err_lines:
            self.assertIn('Unable to produce final output files for', err_line)
            if ' SE ' in err_line:
                unable_to_produce_lines['SE'] += 1
            if ' MXE ' in err_line:
                unable_to_produce_lines['MXE'] += 1
            if ' A5SS ' in err_line:
                unable_to_produce_lines['A5SS'] += 1
            if ' A3SS ' in err_line:
                unable_to_produce_lines['A3SS'] += 1
            if ' RI ' in err_line:
                unable_to_produce_lines['RI'] += 1

        self.assertEqual(unable_to_produce_lines, {
            'SE': 1,
            'MXE': 2,
            'A5SS': 2,
            'A3SS': 2,
            'RI': 2
        })

        se_mats_jc_path = os.path.join(self._out_dir_just_se, 'SE.MATS.JC.txt')
        se_mats_jc_header, se_mats_jc_rows, error = output_parser.parse_mats_jc(
            se_mats_jc_path)
        self.assertFalse(error)
        self._check_se_mats_jc_header(se_mats_jc_header)
        self.assertEqual(len(se_mats_jc_rows), 2)
        for row in se_mats_jc_rows:
            self.assertIn(row['exonStart_0base'], ['200', '800'])
            if row['exonStart_0base'] == '200':
                self.assertEqual(row['IJC_SAMPLE_1'], '10,15')
                self.assertEqual(row['SJC_SAMPLE_1'], '10,5')
                self.assertEqual(row['IJC_SAMPLE_2'], '10,10')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,0')
                tests.util.assert_within_bounds(self, float(row['PValue']), 0,
                                                1)
                tests.util.assert_within_bounds(self, float(row['FDR']), 0, 1)
                self.assertEqual(self._read_floats(row['IncLevel1']),
                                 [0.333, 0.6])
                self.assertEqual(self._read_floats(row['IncLevel2']),
                                 [1.0, 1.0])
                self.assertEqual(float(row['IncLevelDifference']), -0.533)

        se_mats_jcec_path = os.path.join(self._out_dir_just_se,
                                         'SE.MATS.JCEC.txt')
        self.assertFalse(os.path.exists(se_mats_jcec_path))
        mxe_mats_jc_path = os.path.join(self._out_dir_just_se,
                                        'MXE.MATS.JC.txt')
        self.assertFalse(os.path.exists(mxe_mats_jc_path))
        mxe_mats_jcec_path = os.path.join(self._out_dir_just_se,
                                          'MXE.MATS.JCEC.txt')
        self.assertFalse(os.path.exists(mxe_mats_jcec_path))
        a5ss_mats_jc_path = os.path.join(self._out_dir_just_se,
                                         'A5SS.MATS.JC.txt')
        self.assertFalse(os.path.exists(a5ss_mats_jc_path))
        a5ss_mats_jcec_path = os.path.join(self._out_dir_just_se,
                                           'A5SS.MATS.JCEC.txt')
        self.assertFalse(os.path.exists(a5ss_mats_jcec_path))
        a3ss_mats_jc_path = os.path.join(self._out_dir_just_se,
                                         'A3SS.MATS.JC.txt')
        self.assertFalse(os.path.exists(a3ss_mats_jc_path))
        a3ss_mats_jcec_path = os.path.join(self._out_dir_just_se,
                                           'A3SS.MATS.JCEC.txt')
        self.assertFalse(os.path.exists(a3ss_mats_jcec_path))
        ri_mats_jc_path = os.path.join(self._out_dir_just_se, 'RI.MATS.JC.txt')
        self.assertFalse(os.path.exists(ri_mats_jc_path))
        ri_mats_jcec_path = os.path.join(self._out_dir_just_se,
                                         'RI.MATS.JCEC.txt')
        self.assertFalse(os.path.exists(ri_mats_jcec_path))
Пример #12
0
    def _check_results_fixed(self):
        self._check_no_error_results()

        se_mats_jc_path = os.path.join(self._out_dir_fixed, 'SE.MATS.JC.txt')
        se_mats_jc_header, se_mats_jc_rows, error = output_parser.parse_mats_jc(
            se_mats_jc_path)
        self.assertFalse(error)
        self._check_se_mats_jc_header(se_mats_jc_header)
        self.assertEqual(len(se_mats_jc_rows), 4)
        for row in se_mats_jc_rows:
            self.assertIn(row['exonStart_0base'],
                          ['200', '1200', '3600', '4600'])
            if row['exonStart_0base'] == '200':
                self.assertEqual(row['IJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['SJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['IncFormLen'], '98')
                self.assertEqual(row['SkipFormLen'], '49')
            if row['exonStart_0base'] == '1200':
                self.assertEqual(row['IJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['SJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,0')

        se_mats_jcec_path = os.path.join(self._out_dir_fixed,
                                         'SE.MATS.JCEC.txt')
        se_mats_jcec_header, se_mats_jcec_rows, error = (
            output_parser.parse_mats_jcec(se_mats_jcec_path))
        self.assertFalse(error)
        self._check_se_mats_jcec_header(se_mats_jcec_header)
        self.assertEqual(len(se_mats_jcec_rows), 4)
        for row in se_mats_jcec_rows:
            self.assertIn(row['exonStart_0base'],
                          ['200', '1200', '3600', '4600'])
            if row['exonStart_0base'] == '200':
                self.assertEqual(row['IJC_SAMPLE_1'], '2,2')
                self.assertEqual(row['SJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,2')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['IncFormLen'], '149')
                self.assertEqual(row['SkipFormLen'], '49')
            if row['exonStart_0base'] == '1200':
                self.assertEqual(row['IJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['SJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,2')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,0')

        mxe_mats_jc_path = os.path.join(self._out_dir_fixed, 'MXE.MATS.JC.txt')
        mxe_mats_jc_header, mxe_mats_jc_rows, error = (
            output_parser.parse_mats_jc(mxe_mats_jc_path))
        self.assertFalse(error)
        self._check_mxe_mats_jc_header(mxe_mats_jc_header)
        self.assertEqual(len(mxe_mats_jc_rows), 2)
        for row in mxe_mats_jc_rows:
            self.assertIn(row['1stExonStart_0base'], ['3200', '4200'])
            if row['1stExonStart_0base'] == '3200':
                self.assertEqual(row['IJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['SJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['IncFormLen'], '98')
                self.assertEqual(row['SkipFormLen'], '98')
            if row['1stExonStart_0base'] == '4200':
                self.assertEqual(row['IJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['SJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,0')

        mxe_mats_jcec_path = os.path.join(self._out_dir_fixed,
                                          'MXE.MATS.JCEC.txt')
        mxe_mats_jcec_header, mxe_mats_jcec_rows, error = (
            output_parser.parse_mats_jcec(mxe_mats_jcec_path))
        self.assertFalse(error)
        self._check_mxe_mats_jcec_header(mxe_mats_jcec_header)
        self.assertEqual(len(mxe_mats_jcec_rows), 2)
        for row in mxe_mats_jcec_rows:
            self.assertIn(row['1stExonStart_0base'], ['3200', '4200'])
            if row['1stExonStart_0base'] == '3200':
                self.assertEqual(row['IJC_SAMPLE_1'], '2,2')
                self.assertEqual(row['SJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,2')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['IncFormLen'], '149')
                self.assertEqual(row['SkipFormLen'], '149')
            if row['1stExonStart_0base'] == '4200':
                self.assertEqual(row['IJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['SJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,2')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,0')

        a5ss_mats_jc_path = os.path.join(self._out_dir_fixed,
                                         'A5SS.MATS.JC.txt')
        a5ss_mats_jc_header, a5ss_mats_jc_rows, error = (
            output_parser.parse_mats_jc(a5ss_mats_jc_path))
        self.assertFalse(error)
        self._check_a35ss_mats_jc_header(a5ss_mats_jc_header)
        self.assertEqual(len(a5ss_mats_jc_rows), 2)
        for row in a5ss_mats_jc_rows:
            self.assertIn(row['longExonStart_0base'], ['6000', '7000'])
            if row['longExonStart_0base'] == '6000':
                self.assertEqual(row['IJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['SJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['IncFormLen'], '98')
                self.assertEqual(row['SkipFormLen'], '49')
            if row['longExonStart_0base'] == '7000':
                self.assertEqual(row['IJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['SJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,0')

        a5ss_mats_jcec_path = os.path.join(self._out_dir_fixed,
                                           'A5SS.MATS.JCEC.txt')
        a5ss_mats_jcec_header, a5ss_mats_jcec_rows, error = (
            output_parser.parse_mats_jcec(a5ss_mats_jcec_path))
        self.assertFalse(error)
        self._check_a35ss_mats_jcec_header(a5ss_mats_jcec_header)
        self.assertEqual(len(a5ss_mats_jcec_rows), 2)
        for row in a5ss_mats_jcec_rows:
            self.assertIn(row['longExonStart_0base'], ['6000', '7000'])
            if row['longExonStart_0base'] == '6000':
                self.assertEqual(row['IJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['SJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['IncFormLen'], '149')
                self.assertEqual(row['SkipFormLen'], '49')
            if row['longExonStart_0base'] == '7000':
                self.assertEqual(row['IJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['SJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,0')

        a3ss_mats_jc_path = os.path.join(self._out_dir_fixed,
                                         'A3SS.MATS.JC.txt')
        a3ss_mats_jc_header, a3ss_mats_jc_rows, error = (
            output_parser.parse_mats_jc(a3ss_mats_jc_path))
        self.assertFalse(error)
        self._check_a35ss_mats_jc_header(a3ss_mats_jc_header)
        self.assertEqual(len(a3ss_mats_jc_rows), 2)
        for row in a3ss_mats_jc_rows:
            self.assertIn(row['longExonStart_0base'], ['9200', '10200'])
            if row['longExonStart_0base'] == '9200':
                self.assertEqual(row['IJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['SJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['IncFormLen'], '98')
                self.assertEqual(row['SkipFormLen'], '49')
            if row['longExonStart_0base'] == '10200':
                self.assertEqual(row['IJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['SJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,0')

        a3ss_mats_jcec_path = os.path.join(self._out_dir_fixed,
                                           'A3SS.MATS.JCEC.txt')
        a3ss_mats_jcec_header, a3ss_mats_jcec_rows, error = (
            output_parser.parse_mats_jcec(a3ss_mats_jcec_path))
        self.assertFalse(error)
        self._check_a35ss_mats_jcec_header(a3ss_mats_jcec_header)
        self.assertEqual(len(a3ss_mats_jcec_rows), 2)
        for row in a3ss_mats_jcec_rows:
            self.assertIn(row['longExonStart_0base'], ['9200', '10200'])
            if row['longExonStart_0base'] == '9200':
                self.assertEqual(row['IJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['SJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['IncFormLen'], '149')
                self.assertEqual(row['SkipFormLen'], '49')
            if row['longExonStart_0base'] == '10200':
                self.assertEqual(row['IJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['SJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,0')

        ri_mats_jc_path = os.path.join(self._out_dir_fixed, 'RI.MATS.JC.txt')
        ri_mats_jc_header, ri_mats_jc_rows, error = output_parser.parse_mats_jc(
            ri_mats_jc_path)
        self.assertFalse(error)
        self._check_ri_mats_jc_header(ri_mats_jc_header)
        self.assertEqual(len(ri_mats_jc_rows), 2)
        for row in ri_mats_jc_rows:
            self.assertIn(row['riExonStart_0base'], ['12000', '13000'])
            if row['riExonStart_0base'] == '12000':
                self.assertEqual(row['IJC_SAMPLE_1'], '2,2')
                self.assertEqual(row['SJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,2')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['IncFormLen'], '98')
                self.assertEqual(row['SkipFormLen'], '49')
            if row['riExonStart_0base'] == '13000':
                self.assertEqual(row['IJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['SJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,2')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,0')

        ri_mats_jcec_path = os.path.join(self._out_dir_fixed,
                                         'RI.MATS.JCEC.txt')
        ri_mats_jcec_header, ri_mats_jcec_rows, error = (
            output_parser.parse_mats_jcec(ri_mats_jcec_path))
        self.assertFalse(error)
        self._check_ri_mats_jcec_header(ri_mats_jcec_header)
        self.assertEqual(len(ri_mats_jcec_rows), 2)
        for row in ri_mats_jcec_rows:
            self.assertIn(row['riExonStart_0base'], ['12000', '13000'])
            if row['riExonStart_0base'] == '12000':
                self.assertEqual(row['IJC_SAMPLE_1'], '2,2')
                self.assertEqual(row['SJC_SAMPLE_1'], '1,1')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,2')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,1')
                self.assertEqual(row['IncFormLen'], '249')
                self.assertEqual(row['SkipFormLen'], '49')
            if row['riExonStart_0base'] == '13000':
                self.assertEqual(row['IJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['SJC_SAMPLE_1'], '0,0')
                self.assertEqual(row['IJC_SAMPLE_2'], '0,2')
                self.assertEqual(row['SJC_SAMPLE_2'], '0,0')