Esempio n. 1
0
    def _run_continuous(self, version):
        """
        Changed one session file:
            - 012.txt resp & stdev changed from 0.0 to 0.1. Confirmed that this
              session file causes the BMDS GUI to crash as well.
        """
        output_folder = version.replace(".", "") + "_outputs"
        input_path = os.path.join(BMDS_TEST_PATH, 'continuous', 'inputs')
        output_path = os.path.join(BMDS_TEST_PATH, 'continuous', output_folder)
        if os.path.exists(output_path):
            shutil.rmtree(output_path)
        os.makedirs(output_path)

        wb, ws = self._create_xls_wb()
        row = 0

        # begin model runs
        bmds = BMDS.versions[version]()
        files = sorted(os.listdir(input_path))
        for f in files:
            fn = os.path.join(input_path, f)
            dataset = self._load_continuous(fn)
            endpoint_d = self._get_continuous_endpoint_d(dataset)
            for setting in self.default_c_models:
                # get default bmds settings
                run_instance = bmds.models['C'][setting['model_name']]()
                runnable = endpoint_d['numDG'] >= run_instance.minimum_DG
                if runnable:
                    row += 1
                    logging.debug('Running {0}:{1}'.format(
                        f, setting['model_name']))

                    # change the poly degree for the multistage model
                    if setting['model_name'] == 'Polynomial':
                        setting['override'][
                            'degree_poly'] = endpoint_d['numDG'] - 1
                        if endpoint_d['dataset_increasing']:
                            setting['override']['restrict_polynomial'] = 1
                        else:
                            setting['override']['restrict_polynomial'] = -1

                    d_file = run_instance.dfile_print(endpoint_d)
                    model = BMD_model_run(model_name=run_instance.model_name)
                    results = model.execute_bmds(bmds,
                                                 run_instance,
                                                 d_file,
                                                 create_image=False)
                    file_identifier = f[:(len(f) - 4)]
                    model_name = setting['model_name']
                    self._print_individual_run(ws, results, file_identifier,
                                               model_name, row, output_path,
                                               d_file)

        # save excel file
        wb.save(os.path.join(output_path, 'outputs.xls'))
Esempio n. 2
0
    def _run_continuous(self, version):
        """
        Changed one session file:
            - 012.txt resp & stdev changed from 0.0 to 0.1. Confirmed that this
              session file causes the BMDS GUI to crash as well.
        """
        output_folder = version.replace(".", "") + "_outputs"
        input_path = os.path.join(BMDS_TEST_PATH, 'continuous', 'inputs')
        output_path = os.path.join(BMDS_TEST_PATH, 'continuous', output_folder)
        if os.path.exists(output_path):
            shutil.rmtree(output_path)
        os.makedirs(output_path)

        wb, ws = self._create_xls_wb()
        row = 0

        # begin model runs
        bmds = BMDS.versions[version]()
        files = sorted(os.listdir(input_path))
        for f in files:
            fn = os.path.join(input_path, f)
            dataset = self._load_continuous(fn)
            endpoint_d = self._get_continuous_endpoint_d(dataset)
            for setting in self.default_c_models:
                # get default bmds settings
                run_instance = bmds.models['C'][setting['model_name']]()
                runnable = endpoint_d['numDG'] >= run_instance.minimum_DG
                if runnable:
                    row += 1
                    logging.debug('Running {0}:{1}'.format(f, setting['model_name']))

                    # change the poly degree for the multistage model
                    if setting['model_name'] == 'Polynomial':
                        setting['override']['degree_poly'] = endpoint_d['numDG'] - 1
                        if endpoint_d['dataset_increasing']:
                            setting['override']['restrict_polynomial'] = 1
                        else:
                            setting['override']['restrict_polynomial'] = -1

                    d_file = run_instance.dfile_print(endpoint_d)
                    model = BMD_model_run(model_name=run_instance.model_name)
                    results = model.execute_bmds(bmds,
                                                 run_instance,
                                                 d_file,
                                                 create_image=False)
                    file_identifier = f[:(len(f)-4)]
                    model_name = setting['model_name']
                    self._print_individual_run(ws, results, file_identifier,
                                               model_name, row, output_path,
                                               d_file)

        # save excel file
        wb.save(os.path.join(output_path, 'outputs.xls'))
Esempio n. 3
0
    def _run_dichotomous(self, version):
        """
        One change made to input files: 038.dat, dropped highest dose. Confirmed
        that this causes the standard BMDS models to hard-hang and therefore,
        removed the high dose from this case which fixed modeling issue.
        """
        output_folder = version.replace(".", "") + "_outputs"
        input_path = os.path.join(BMDS_TEST_PATH, 'dichotomous', 'inputs')
        output_path = os.path.join(BMDS_TEST_PATH, 'dichotomous',
                                   output_folder)
        if os.path.exists(output_path):
            shutil.rmtree(output_path)
        os.makedirs(output_path)

        wb, ws = self._create_xls_wb()
        row = 0

        # begin model runs
        bmds = BMDS.versions[version]()
        files = sorted(os.listdir(input_path))
        for f in files:
            fn = os.path.join(input_path, f)
            dataset = self._load_dichotomous(fn)
            endpoint_d = self._get_dichotomous_endpoint_d(dataset)
            for setting in self.default_d_models:
                row += 1
                # change the poly degree for the multistage model
                if setting['model_name'] == 'Multistage':
                    setting['override']['degree_poly'] = len(dataset) - 1

                # get default bmds settings
                logging.debug('Running {0}:{1}'.format(f,
                                                       setting['model_name']))
                run_instance = bmds.models['D'][setting['model_name']]()
                d_file = run_instance.dfile_print(endpoint_d)

                model = BMD_model_run(model_name=run_instance.model_name)
                results = model.execute_bmds(bmds,
                                             run_instance,
                                             d_file,
                                             create_image=False)
                file_identifier = f[:(len(f) - 4)]
                model_name = run_instance.model_name
                self._print_individual_run(ws, results, file_identifier,
                                           model_name, row, output_path,
                                           d_file)

        # save excel file
        wb.save(os.path.join(output_path, 'outputs.xls'))
Esempio n. 4
0
    def _run_dichotomous(self, version):
        """
        One change made to input files: 038.dat, dropped highest dose. Confirmed
        that this causes the standard BMDS models to hard-hang and therefore,
        removed the high dose from this case which fixed modeling issue.
        """
        output_folder = version.replace(".", "") + "_outputs"
        input_path = os.path.join(BMDS_TEST_PATH, 'dichotomous', 'inputs')
        output_path = os.path.join(BMDS_TEST_PATH, 'dichotomous', output_folder)
        if os.path.exists(output_path):
            shutil.rmtree(output_path)
        os.makedirs(output_path)

        wb, ws = self._create_xls_wb()
        row = 0

        # begin model runs
        bmds = BMDS.versions[version]()
        files = sorted(os.listdir(input_path))
        for f in files:
            fn = os.path.join(input_path, f)
            dataset = self._load_dichotomous(fn)
            endpoint_d = self._get_dichotomous_endpoint_d(dataset)
            for setting in self.default_d_models:
                row += 1
                # change the poly degree for the multistage model
                if setting['model_name'] == 'Multistage':
                    setting['override']['degree_poly'] = len(dataset)-1

                # get default bmds settings
                logging.debug('Running {0}:{1}'.format(f, setting['model_name']))
                run_instance = bmds.models['D'][setting['model_name']]()
                d_file = run_instance.dfile_print(endpoint_d)

                model = BMD_model_run(model_name=run_instance.model_name)
                results = model.execute_bmds(bmds,
                                             run_instance,
                                             d_file,
                                             create_image=False)
                file_identifier = f[:(len(f)-4)]
                model_name = run_instance.model_name
                self._print_individual_run(
                    ws, results, file_identifier,
                    model_name, row, output_path, d_file)

        # save excel file
        wb.save(os.path.join(output_path, 'outputs.xls'))