Ejemplo n.º 1
0
    def check_and_run_validate(self, lib):
        # run validation
        self.assertTrue(glob_exists(self.temp_output, lib,
                                    SUBCOMMAND.VALIDATE))
        qsub = unique_exists(
            os.path.join(self.temp_output, lib, SUBCOMMAND.VALIDATE,
                         '*-1/submit.sh'))
        args = convert_qsub_to_args(qsub)  # read the arguments from the file
        print(args)
        with patch.object(sys, 'argv', args):
            self.assertEqual(0, main())

        for suffix in [
                'contigs.bam', 'contigs.fa', 'contigs.sorted.bam',
                'contigs.sorted.bam.bai', 'evidence.bed', 'igv.batch',
                'raw_evidence.bam', 'raw_evidence.sorted.bam',
                'raw_evidence.sorted.bam.bai', 'validation-failed.tab',
                'validation-passed.tab'
        ]:
            self.assertTrue(
                glob_exists(self.temp_output, lib,
                            SUBCOMMAND.VALIDATE + '/*-1', '*.' + suffix))
        self.assertTrue(
            glob_exists(self.temp_output, lib, SUBCOMMAND.VALIDATE + '/*-1',
                        '*.COMPLETE'))
Ejemplo n.º 2
0
    def test_clean_files(self):
        args = [
            'mavis', SUBCOMMAND.PIPELINE, CLEAN_CONFIG, '-o', self.temp_output
        ]
        with patch.object(sys, 'argv', args):
            self.assertEqual(0, main())

        # check that the subdirectories were built
        for lib in [MOCK_GENOME + '_*', MOCK_TRANS + '_*']:
            self.check_cluster(lib)

            # run validation
            self.assertTrue(
                glob_exists(self.temp_output, lib, SUBCOMMAND.VALIDATE))
            qsub = unique_exists(
                os.path.join(self.temp_output, lib, SUBCOMMAND.VALIDATE,
                             '*-1/submit.sh'))
            args = convert_qsub_to_args(
                qsub)  # read the arguments from the file
            print(args)
            with patch.object(sys, 'argv', args):
                self.assertEqual(0, main())

            for suffix in [
                    'evidence.bed', 'validation-failed.tab',
                    'validation-passed.tab'
            ]:
                self.assertTrue(
                    glob_exists(self.temp_output, lib,
                                SUBCOMMAND.VALIDATE + '/*-1', '*.' + suffix))
            for suffix in [
                    'contigs.bam',
                    'contigs.blat_out.pslx',
                    'contigs.fa',
                    'contigs.sorted.bam',
                    'contigs.sorted.bam.bai',
                    'igv.batch',
                    'raw_evidence.bam',
                    'raw_evidence.sorted.bam',
                    'raw_evidence.sorted.bam.bai',
            ]:
                self.assertFalse(
                    glob_exists(self.temp_output, lib,
                                SUBCOMMAND.VALIDATE + '/*-1', '*.' + suffix))
            self.assertTrue(
                glob_exists(self.temp_output, lib,
                            SUBCOMMAND.VALIDATE + '/*-1', '*.COMPLETE'))

            self.check_and_run_annotate(lib)
        # now run the pairing
        self.check_and_run_pairing()

        # now run the summary
        self.check_and_run_summary()

        with patch.object(
                sys, 'argv',
            ['mavis', SUBCOMMAND.CHECKER, '-o', self.temp_output]):
            self.assertEqual(0, main())
        self.assertTrue(glob_exists(self.temp_output, 'submit_pipeline*.sh'))
Ejemplo n.º 3
0
    def check_and_run_pairing(self):
        # now run the pairing
        self.assertTrue(glob_exists(self.temp_output, SUBCOMMAND.PAIR))
        qsub = unique_exists(
            os.path.join(self.temp_output, SUBCOMMAND.PAIR, 'submit.sh'))
        args = convert_qsub_to_args(qsub)
        with patch.object(sys, 'argv', args):
            self.assertEqual(0, main())

        self.assertTrue(
            glob_exists(self.temp_output, SUBCOMMAND.PAIR,
                        'mavis_paired*.tab'))
        self.assertTrue(
            glob_exists(self.temp_output, SUBCOMMAND.PAIR, '*.COMPLETE'))
Ejemplo n.º 4
0
 def run_main(self, inputfile, file_type, strand_specific=False):
     outputfile = os.path.join(TEMP_OUTPUT, file_type + '.tab')
     args = [
         'mavis', SUBCOMMAND.CONVERT, '-o', outputfile, '-n', inputfile,
         '--file_type', file_type, '--strand_specific', strand_specific
     ]
     with patch.object(sys, 'argv', args):
         self.assertEqual(0, main())
         print('output', outputfile)
         self.assertTrue(unique_exists(outputfile))
     result = {}
     for pair in read_bpp_from_input_file(outputfile):
         result.setdefault(pair.tracking_id, []).append(pair)
     return result
Ejemplo n.º 5
0
    def check_and_run_summary(self, count=3):
        # now run the summary
        self.assertTrue(glob_exists(self.temp_output, SUBCOMMAND.SUMMARY))
        qsub = unique_exists(
            os.path.join(self.temp_output, SUBCOMMAND.SUMMARY, 'submit.sh'))
        args = convert_qsub_to_args(qsub)
        with patch.object(sys, 'argv', args):
            self.assertEqual(0, main())

        self.assertTrue(
            glob_exists(self.temp_output,
                        SUBCOMMAND.SUMMARY,
                        'mavis_summary*.tab',
                        n=count))
        self.assertTrue(
            glob_exists(self.temp_output, SUBCOMMAND.SUMMARY, '*.COMPLETE'))
Ejemplo n.º 6
0
 def check_and_run_annotate(self, lib):
     # run annotation
     self.assertTrue(glob_exists(self.temp_output, lib,
                                 SUBCOMMAND.ANNOTATE))
     qsub = unique_exists(
         os.path.join(self.temp_output, lib, SUBCOMMAND.ANNOTATE,
                      '*-1/submit.sh'))
     args = convert_qsub_to_args(qsub)
     with patch.object(sys, 'argv', args):
         self.assertEqual(0, main())
     # check the generated files
     self.assertTrue(
         glob_exists(self.temp_output, lib, SUBCOMMAND.ANNOTATE + '/*-1',
                     'annotations.tab'))
     self.assertTrue(
         glob_exists(self.temp_output, lib, SUBCOMMAND.ANNOTATE + '/*-1',
                     'annotations.fusion-cdna.fa'))
     self.assertTrue(
         glob_exists(self.temp_output, lib, SUBCOMMAND.ANNOTATE + '/*-1',
                     'drawings'))
     self.assertTrue(
         glob_exists(self.temp_output,
                     lib,
                     SUBCOMMAND.ANNOTATE + '/*-1',
                     'drawings',
                     '*svg',
                     strict=False))
     self.assertTrue(
         glob_exists(self.temp_output,
                     lib,
                     SUBCOMMAND.ANNOTATE + '/*-1',
                     'drawings',
                     '*json',
                     strict=False))
     self.assertTrue(
         glob_exists(self.temp_output, lib, SUBCOMMAND.ANNOTATE + '/*-1',
                     '*.COMPLETE'))