def test_various_issues(self):
        '''Test if output is generated for a mix of errors and warnings.

        This includes HTML ouput, the error line file and the exit status.
        '''
        # build the argument list
        html_file_name = 'test_data/study_various_issues/result_report.html~'
        error_file_name = 'test_data/study_various_issues/error_file.txt~'
        args = ['--study_directory','test_data/study_various_issues/',
                '--portal_info_dir', PORTAL_INFO_DIR, '-v',
                '--html_table', html_file_name,
                '--error_file', error_file_name]
        args = validateData.interface(args)
        # execute main function with arguments provided through sys.argv
        exit_status = validateData.main_validate(args)
        # flush logging handlers used in validateData
        validator_logger = logging.getLogger(validateData.__name__)
        for logging_handler in validator_logger.handlers:
            logging_handler.flush()
        # should fail because of various errors in addition to warnings
        self.assertEquals(1, exit_status)
        # In MAF files (mutation data) there is a column called
        # "Matched_Norm_Sample_Barcode". The respective metadata file supports
        # giving a list of sample codes against which this column is validated.
        # This and other errors are expected in these output files.
        self.assertFileGenerated(
                html_file_name,
                'test_data/study_various_issues/result_report.html')
        self.assertFileGenerated(
                error_file_name,
                'test_data/study_various_issues/error_file.txt')
Пример #2
0
    def test_problem_in_clinical(self):
        """Test whether the script aborts if the sample file cannot be parsed.

        Further files cannot be validated in this case, as all sample IDs will
        be undefined. Validate if the script is giving the proper error.
        """
        # build the argument list
        out_file_name = "test_data/study_wr_clin/result_report.html~"
        print("==test_problem_in_clinical==")
        args = [
            "--study_directory",
            "test_data/study_wr_clin/",
            "--portal_info_dir",
            PORTAL_INFO_DIR,
            "-v",
            "--html_table",
            out_file_name,
        ]
        # execute main function with arguments provided as if from sys.argv
        args = validateData.interface(args)
        exit_status = validateData.main_validate(args)
        self.assertEqual(1, exit_status)
        # TODO - set logger in main_validate and read out buffer here to assert on nr of errors
        self.assertFileGenerated(
            out_file_name, "test_data/study_wr_clin/result_report.html"
        )
Пример #3
0
    def test_various_issues(self):
        '''Test if output is generated for a mix of errors and warnings.

        This includes HTML ouput, the error line file and the exit status.
        '''
        # build the argument list
        html_file_name = 'test_data/study_various_issues/result_report.html~'
        error_file_name = 'test_data/study_various_issues/error_file.txt~'
        args = [
            '--study_directory', 'test_data/study_various_issues/',
            '--portal_info_dir', PORTAL_INFO_DIR, '-v', '--html_table',
            html_file_name, '--error_file', error_file_name
        ]
        args = validateData.interface(args)
        # execute main function with arguments provided through sys.argv
        exit_status = validateData.main_validate(args)
        # flush logging handlers used in validateData
        validator_logger = logging.getLogger(validateData.__name__)
        for logging_handler in validator_logger.handlers:
            logging_handler.flush()
        # should fail because of various errors in addition to warnings
        self.assertEquals(1, exit_status)
        # In MAF files (mutation data) there is a column called
        # "Matched_Norm_Sample_Barcode". The respective metadata file supports
        # giving a list of sample codes against which this column is validated.
        # This and other errors are expected in these output files.
        self.assertFileGenerated(
            html_file_name,
            'test_data/study_various_issues/result_report.html')
        self.assertFileGenerated(
            error_file_name, 'test_data/study_various_issues/error_file.txt')
Пример #4
0
 def test_exit_status_invalid(self):
     '''test to fail: give wrong hugo file, or let a meta file point to a non-existing data file, expected exit_status = 2.'''
     #Build up arguments and run
     print("===study invalid")
     args = ['--study_directory', 'test_data/study_es_invalid/',
             '--portal_info_dir', PORTAL_INFO_DIR, '-v']
     args = validateData.interface(args)
     # Execute main function with arguments provided through sys.argv
     exit_status = validateData.main_validate(args)
     self.assertEqual(2, exit_status)
Пример #5
0
 def test_exit_status_failure(self):
     '''study 1 : errors, expected exit_status = 1.'''
     #Build up arguments and run
     print("===study 1")
     args = ['--study_directory', 'test_data/study_es_1/',
             '--portal_info_dir', PORTAL_INFO_DIR, '-v']
     args = validateData.interface(args)
     # Execute main function with arguments provided through sys.argv
     exit_status = validateData.main_validate(args)
     self.assertEqual(1, exit_status)
 def test_exit_status_failure(self):
     '''study 1 : errors, expected exit_status = 1.'''
     #Build up arguments and run
     print "===study 1"
     args = ['--study_directory','test_data/study_es_1/', 
             '--portal_info_dir', PORTAL_INFO_DIR, '-v']
     args = validateData.interface(args)
     # Execute main function with arguments provided through sys.argv
     exit_status = validateData.main_validate(args)
     self.assertEquals(1, exit_status)
Пример #7
0
def executeScript(importerDir, studyDir, outfile):
    import os
    import sys
    sys.path.append(importerDir)

    from importer import validateData

    args = validateData.interface(
        ["-s" + studyDir + "/", "-n", "-v", "-html", outfile])
    return validateData.main_validate(args)
 def test_exit_status_invalid(self):
     '''test to fail: give wrong hugo file, or let a meta file point to a non-existing data file, expected exit_status = 2.'''
     #Build up arguments and run
     print "===study invalid"
     args = ['--study_directory','test_data/study_es_invalid/', 
             '--portal_info_dir', PORTAL_INFO_DIR, '-v']
     args = validateData.interface(args)
     # Execute main function with arguments provided through sys.argv
     exit_status = validateData.main_validate(args)
     self.assertEquals(2, exit_status)
 def test_exit_status_warnings(self):
     '''study 3 : warnings only, expected exit_status = 3.'''
     # data_filename: test
     #Build up arguments and run
     print "===study 3"
     args = ['--study_directory','test_data/study_es_3/', 
             '--portal_info_dir', PORTAL_INFO_DIR, '-v']
     args = validateData.interface(args)
     # Execute main function with arguments provided through sys.argv
     exit_status = validateData.main_validate(args)
     self.assertEquals(3, exit_status)
Пример #10
0
 def test_exit_status_warnings(self):
     '''study 3 : warnings only, expected exit_status = 3.'''
     # data_filename: test
     #Build up arguments and run
     print("===study 3")
     args = ['--study_directory', 'test_data/study_es_3/',
             '--portal_info_dir', PORTAL_INFO_DIR, '-v']
     args = validateData.interface(args)
     # Execute main function with arguments provided through sys.argv
     exit_status = validateData.main_validate(args)
     self.assertEqual(3, exit_status)
 def test_portal_mismatch(self):
     '''Test if validation fails when data contradicts the portal.'''
     # build up arguments and run
     argv = ['--study_directory', 'test_data/study_portal_mismatch',
             '--portal_info_dir', PORTAL_INFO_DIR, '--verbose']
     parsed_args = validateData.interface(argv)
     exit_status = validateData.main_validate(parsed_args)
     # flush logging handlers used in validateData
     validator_logger = logging.getLogger(validateData.__name__)
     for logging_handler in validator_logger.handlers:
         logging_handler.flush()
     # expecting only warnings (about the skipped checks), no errors
     self.assertEquals(exit_status, 1)
Пример #12
0
 def test_portal_mismatch(self):
     '''Test if validation fails when data contradicts the portal.'''
     # build up arguments and run
     argv = ['--study_directory', 'test_data/study_portal_mismatch',
             '--portal_info_dir', PORTAL_INFO_DIR, '--verbose']
     parsed_args = validateData.interface(argv)
     exit_status = validateData.main_validate(parsed_args)
     # flush logging handlers used in validateData
     validator_logger = logging.getLogger(validateData.__name__)
     for logging_handler in validator_logger.handlers:
         logging_handler.flush()
     # expecting only warnings (about the skipped checks), no errors
     self.assertEqual(exit_status, 1)
 def test_no_portal_checks(self):
     '''Test if validation skips portal-specific checks when instructed.'''
     # build up arguments and run
     argv = ['--study_directory', 'test_data/study_portal_mismatch',
             '--verbose',
             '--no_portal_checks']
     parsed_args = validateData.interface(argv)
     exit_status = validateData.main_validate(parsed_args)
     # flush logging handlers used in validateData
     validator_logger = logging.getLogger(validateData.__name__)
     for logging_handler in validator_logger.handlers:
         logging_handler.flush()
     # expecting only warnings (about the skipped checks), no errors
     self.assertEquals(exit_status, 3)
Пример #14
0
 def test_no_portal_checks(self):
     '''Test if validation skips portal-specific checks when instructed.'''
     # build up arguments and run
     argv = ['--study_directory', 'test_data/study_portal_mismatch',
             '--verbose',
             '--no_portal_checks']
     parsed_args = validateData.interface(argv)
     exit_status = validateData.main_validate(parsed_args)
     # flush logging handlers used in validateData
     validator_logger = logging.getLogger(validateData.__name__)
     for logging_handler in validator_logger.handlers:
         logging_handler.flush()
     # expecting only warnings (about the skipped checks), no errors
     self.assertEqual(exit_status, 3)
 def test_html_output(self):
     '''
     Test if html file is correctly generated when 'html_table' is given
     '''
     #Build up arguments and run
     out_file_name = 'test_data/study_es_0/result_report.html~'
     args = ['--study_directory','test_data/study_es_0/', 
             '--portal_info_dir', PORTAL_INFO_DIR, '-v',
             '--html_table', out_file_name]
     args = validateData.interface(args)
     # Execute main function with arguments provided through sys.argv
     exit_status = validateData.main_validate(args)
     self.assertEquals(0, exit_status)
     self.assertFileGenerated(out_file_name,
                              'test_data/study_es_0/result_report.html')
Пример #16
0
 def test_html_output(self):
     '''
     Test if html file is correctly generated when 'html_table' is given
     '''
     #Build up arguments and run
     out_file_name = 'test_data/study_es_0/result_report.html~'
     args = ['--study_directory', 'test_data/study_es_0/',
             '--portal_info_dir', PORTAL_INFO_DIR, '-v',
             '--html_table', out_file_name]
     args = validateData.interface(args)
     # Execute main function with arguments provided through sys.argv
     exit_status = validateData.main_validate(args)
     self.assertEqual(0, exit_status)
     self.assertFileGenerated(out_file_name,
                              'test_data/study_es_0/result_report.html')
 def test_files_with_quotes(self):
     '''
     Tests the scenario where data files contain quotes. This should give errors.
     '''
     #Build up arguments and run
     out_file_name = 'test_data/study_quotes/result_report.html~'
     print '==test_files_with_quotes=='
     args = ['--study_directory','test_data/study_quotes/', 
             '--portal_info_dir', PORTAL_INFO_DIR, '-v',
             '--html_table', out_file_name]
     args = validateData.interface(args)
     # Execute main function with arguments provided through sys.argv
     exit_status = validateData.main_validate(args)
     # should fail because of errors with quotes
     self.assertEquals(1, exit_status)
     self.assertFileGenerated(out_file_name,
                              'test_data/study_quotes/result_report.html')
 def test_errorline_output(self):
     '''Test if error file is generated when '--error_file' is given.'''
     out_file_name = 'test_data/study_maf_test/error_file.txt~'
     # build up arguments and run
     argv = ['--study_directory','test_data/study_maf_test/',
             '--portal_info_dir', PORTAL_INFO_DIR,
             '--error_file', out_file_name]
     parsed_args = validateData.interface(argv)
     exit_status = validateData.main_validate(parsed_args)
     # flush logging handlers used in validateData
     validator_logger = logging.getLogger(validateData.__name__)
     for logging_handler in validator_logger.handlers:
         logging_handler.flush()
     # assert that the results are as expected
     self.assertEquals(1, exit_status)
     self.assertFileGenerated(out_file_name,
                              'test_data/study_maf_test/error_file.txt')
Пример #19
0
 def test_files_with_quotes(self):
     '''
     Tests the scenario where data files contain quotes. This should give errors.
     '''
     #Build up arguments and run
     out_file_name = 'test_data/study_quotes/result_report.html~'
     print('==test_files_with_quotes==')
     args = ['--study_directory', 'test_data/study_quotes/',
             '--portal_info_dir', PORTAL_INFO_DIR, '-v',
             '--html_table', out_file_name]
     args = validateData.interface(args)
     # Execute main function with arguments provided through sys.argv
     exit_status = validateData.main_validate(args)
     # should fail because of errors with quotes
     self.assertEqual(1, exit_status)
     self.assertFileGenerated(out_file_name,
                              'test_data/study_quotes/result_report.html')
Пример #20
0
    def test_exit_status_success(self):
        '''study 0 : no errors, expected exit_status = 0.

        If there are errors, the script should return
                0: 'succeeded',
                1: 'failed',
                2: 'not performed as problems occurred',
                3: 'succeeded with warnings'
        '''

        # build up the argument list
        print("===study 0")
        args = ['--study_directory', 'test_data/study_es_0/',
                '--portal_info_dir', PORTAL_INFO_DIR, '-v']
        # execute main function with arguments provided as if from sys.argv
        args = validateData.interface(args)
        exit_status = validateData.main_validate(args)
        self.assertEqual(0, exit_status)
    def test_exit_status_success(self):
        '''study 0 : no errors, expected exit_status = 0.

        If there are errors, the script should return 
                0: 'succeeded',
                1: 'failed',
                2: 'not performed as problems occurred',
                3: 'succeeded with warnings'
        '''

        # build up the argument list
        print "===study 0"
        args = ['--study_directory','test_data/study_es_0/', 
                '--portal_info_dir', PORTAL_INFO_DIR, '-v']
        # execute main function with arguments provided as if from sys.argv
        args = validateData.interface(args)
        exit_status = validateData.main_validate(args)
        self.assertEquals(0, exit_status)
 def test_errorline_output(self):
     '''Test if error file is generated when '--error_file' is given.'''
     out_file_name = 'test_data/study_maf_test/error_file.txt~'
     # build up arguments and run
     argv = [
         '--study_directory', 'test_data/study_maf_test/',
         '--portal_info_dir', PORTAL_INFO_DIR, '--error_file', out_file_name
     ]
     parsed_args = validateData.interface(argv)
     exit_status = validateData.main_validate(parsed_args)
     # flush logging handlers used in validateData
     validator_logger = logging.getLogger(validateData.__name__)
     for logging_handler in validator_logger.handlers:
         logging_handler.flush()
     # assert that the results are as expected
     self.assertEquals(1, exit_status)
     self.assertFileGenerated(out_file_name,
                              'test_data/study_maf_test/error_file.txt')
    def test_problem_in_clinical(self):
        '''Test whether the script aborts if the sample file cannot be parsed.

        Further files cannot be validated in this case, as all sample IDs will
        be undefined. Validate if the script is giving the proper error.
        '''
        # build the argument list
        out_file_name = 'test_data/study_wr_clin/result_report.html~'
        print '==test_problem_in_clinical=='
        args = ['--study_directory','test_data/study_wr_clin/', 
                '--portal_info_dir', PORTAL_INFO_DIR, '-v',
                '--html_table', out_file_name]
        # execute main function with arguments provided as if from sys.argv
        args = validateData.interface(args)
        exit_status = validateData.main_validate(args)
        self.assertEquals(1, exit_status)
        # TODO - set logger in main_validate and read out buffer here to assert on nr of errors
        self.assertFileGenerated(out_file_name,
                                 'test_data/study_wr_clin/result_report.html')
 def test_normal_samples_list_in_maf(self):
     '''
     For mutations MAF files there is a column called "Matched_Norm_Sample_Barcode". 
     In the respective meta file it is possible to give a list of sample codes against which this 
     column "Matched_Norm_Sample_Barcode" is validated. Here we test if this 
     validation works well.
     '''
     #Build up arguments and run
     out_file_name = 'test_data/study_maf_test/result_report.html~'
     print '==test_normal_samples_list_in_maf=='
     args = ['--study_directory','test_data/study_maf_test/', 
             '--portal_info_dir', PORTAL_INFO_DIR, '-v',
             '--html_table', out_file_name]
     args = validateData.interface(args)
     # Execute main function with arguments provided through sys.argv
     exit_status = validateData.main_validate(args)
     # should fail because of errors with invalid Matched_Norm_Sample_Barcode values
     self.assertEquals(1, exit_status)
     self.assertFileGenerated(out_file_name,
                              'test_data/study_maf_test/result_report.html')
 def test_normal_samples_list_in_maf(self):
     '''
     For mutations MAF files there is a column called "Matched_Norm_Sample_Barcode". 
     In the respective meta file it is possible to give a list of sample codes against which this 
     column "Matched_Norm_Sample_Barcode" is validated. Here we test if this 
     validation works well.
     '''
     #Build up arguments and run
     out_file_name = 'test_data/study_maf_test/result_report.html~'
     print '==test_normal_samples_list_in_maf=='
     args = [
         '--study_directory', 'test_data/study_maf_test/',
         '--portal_info_dir', PORTAL_INFO_DIR, '-v', '--html_table',
         out_file_name
     ]
     args = validateData.interface(args)
     # Execute main function with arguments provided through sys.argv
     exit_status = validateData.main_validate(args)
     # should fail because of errors with invalid Matched_Norm_Sample_Barcode values
     self.assertEquals(1, exit_status)
     self.assertFileGenerated(
         out_file_name, 'test_data/study_maf_test/result_report.html')
Пример #26
0
 def test_html_output(self):
     """
     Test if html file is correctly generated when 'html_table' is given
     """
     # Build up arguments and run
     out_file_name = "test_data/study_es_0/result_report.html~"
     args = [
         "--study_directory",
         "test_data/study_es_0/",
         "--portal_info_dir",
         PORTAL_INFO_DIR,
         "-v",
         "--html_table",
         out_file_name,
     ]
     args = validateData.interface(args)
     # Execute main function with arguments provided through sys.argv
     exit_status = validateData.main_validate(args)
     self.assertEqual(0, exit_status)
     self.assertFileGenerated(
         out_file_name, "test_data/study_es_0/result_report.html"
     )
Пример #27
0
 def test_files_with_quotes(self):
     """
     Tests the scenario where data files contain quotes. This should give errors.
     """
     # Build up arguments and run
     out_file_name = "test_data/study_quotes/result_report.html~"
     print("==test_files_with_quotes==")
     args = [
         "--study_directory",
         "test_data/study_quotes/",
         "--portal_info_dir",
         PORTAL_INFO_DIR,
         "-v",
         "--html_table",
         out_file_name,
     ]
     args = validateData.interface(args)
     # Execute main function with arguments provided through sys.argv
     exit_status = validateData.main_validate(args)
     # should fail because of errors with quotes
     self.assertEqual(1, exit_status)
     self.assertFileGenerated(
         out_file_name, "test_data/study_quotes/result_report.html"
     )