def setUp(self):
     self.set_up()
     self.unordered_path = package_paths.data_path(
             'div-model-results-unordered.txt')
     self.ordered_path = package_paths.data_path(
             'div-model-results-ordered.txt')
     self.post_ordered_path = package_paths.data_path(
             os.path.join('posterior-sample.txt.gz'))
Exemple #2
0
 def test_modified_sample_table_error(self):
     observed_config = package_paths.data_path('ambig_config1.cfg')
     prior_config = package_paths.data_path('ambig_config2.cfg')
     args = ['-o', observed_config,
             '-p', prior_config,
             ]
     self.assertRaises(errors.SampleTableError, self.exe_main_dmc, args)
     shutil.move(observed_config + '.orig', observed_config)
 def setUp(self):
     self.set_up()
     self.test_path = self.get_test_path()
     self.cfg_path = package_paths.data_path('4pairs_1locus.cfg')
     self.gz_path = package_paths.data_path(
             'abctoolbox_posterior_density_file.txt.gz')
     self.ungz_path = package_paths.data_path(
             'abctoolbox_posterior_density_file.txt')
Exemple #4
0
 def setUp(self):
     self.set_up()
     self.cfg_path = package_paths.data_path('negros_panay.cfg')
     self.new_cfg_path = package_paths.data_path('negros_panay_new.cfg')
     self.sum_stats_path = package_paths.data_path(
             'negros_panay_sum_stats_sort0.txt')
     self.prior_path = package_paths.data_path(
             'negros_panay_new_prior_sample_10.txt')
     self.posterior_path = package_paths.data_path(
             'posterior-sample.txt.gz')
Exemple #5
0
 def setUp(self):
     self.set_up()
     self.cfg_path = package_paths.data_path('negros_panay.cfg')
     self.new_cfg_path = package_paths.data_path('negros_panay_new.cfg')
     self.sum_stats_path = package_paths.data_path(
         'negros_panay_sum_stats_sort0.txt')
     self.prior_path = package_paths.data_path(
         'negros_panay_new_prior_sample_10.txt')
     self.posterior_path = package_paths.data_path(
         'posterior-sample.txt.gz')
Exemple #6
0
 def test_modified_sample_table_error(self):
     observed_config = package_paths.data_path('ambig_config1.cfg')
     prior_config = package_paths.data_path('ambig_config2.cfg')
     args = [
         '-o',
         observed_config,
         '-p',
         prior_config,
     ]
     self.assertRaises(errors.SampleTableError, self.exe_main_dmc, args)
     shutil.move(observed_config + '.orig', observed_config)
 def setUp(self):
     self.set_up()
     self.ordered_path = package_paths.data_path(
             os.path.join('posterior-sample.txt.gz'))
     post = parsing.parse_parameters(self.ordered_path)
     self.partition_collection = pymsbayes.utils.stats.PartitionCollection(
             post['taus'])
 def setUp(self):
     self.info_path = os.path.join(package_paths.TEST_DATA_DIR,
             'pymsbayes-results', 'pymsbayes-info.txt')
     self.prior_configs = {
         1: package_paths.data_path('negros_panay_3pairs_new_dpp.cfg'),
         2: package_paths.data_path('negros_panay_3pairs_new_uniform.cfg'),
         3: package_paths.data_path('negros_panay_3pairs_new_ushaped.cfg'),
     }
     self.observed_configs = self.prior_configs
     self.observed_paths = {
         1: os.path.join(package_paths.TEST_DATA_DIR, 'pymsbayes-results',
                 'observed-summary-stats', 'observed-1.txt'),
         2: os.path.join(package_paths.TEST_DATA_DIR, 'pymsbayes-results',
                 'observed-summary-stats', 'observed-2.txt'),
         3: os.path.join(package_paths.TEST_DATA_DIR, 'pymsbayes-results',
                 'observed-summary-stats', 'observed-3.txt'),
     }
Exemple #9
0
    def test_diff_sample_table_error(self):
        observed_config = package_paths.data_path('negros_panay_new.cfg')
        prior_config = package_paths.data_path('negros_panay_3pairs.cfg')
        args = ['-o', observed_config,
                '-p', prior_config,
                '-r', '1',
                ]
        self.assertRaises(errors.SampleTableError, self.exe_main_dmc, args)
        args = ['-o', observed_config,
                '-p', prior_config,
                ]
        self.assertRaises(errors.SampleTableError, self.exe_main_dmc, args)

        prior_config = package_paths.data_path('negros_panay_new_diff.cfg')
        args = ['-o', observed_config,
                '-p', prior_config,
                '-r', '1',
                ]
        self.assertRaises(errors.SampleTableError, self.exe_main_dmc, args)
        args = ['-o', observed_config,
                '-p', prior_config,
                ]
        self.assertRaises(errors.SampleTableError, self.exe_main_dmc, args)
Exemple #10
0
    def test_diff_sample_table_error(self):
        observed_config = package_paths.data_path('negros_panay_new.cfg')
        prior_config = package_paths.data_path('negros_panay_3pairs.cfg')
        args = [
            '-o',
            observed_config,
            '-p',
            prior_config,
            '-r',
            '1',
        ]
        self.assertRaises(errors.SampleTableError, self.exe_main_dmc, args)
        args = [
            '-o',
            observed_config,
            '-p',
            prior_config,
        ]
        self.assertRaises(errors.SampleTableError, self.exe_main_dmc, args)

        prior_config = package_paths.data_path('negros_panay_new_diff.cfg')
        args = [
            '-o',
            observed_config,
            '-p',
            prior_config,
            '-r',
            '1',
        ]
        self.assertRaises(errors.SampleTableError, self.exe_main_dmc, args)
        args = [
            '-o',
            observed_config,
            '-p',
            prior_config,
        ]
        self.assertRaises(errors.SampleTableError, self.exe_main_dmc, args)
Exemple #11
0
 def setUp(self):
     self.set_up()
     self.cfg_path = package_paths.data_path('4pairs_1locus.cfg')
     self.cfg_path2 = package_paths.data_path('4pairs_1locus_maxt5.cfg')
     self.np_new_cfg = package_paths.data_path('negros_panay_new.cfg')
     self.np_new_sps_cfg = package_paths.data_path('negros_panay_new_subs_per_site.cfg')
     self.np_cfg = package_paths.data_path('negros_panay_timescale.cfg')
     self.np_sps_cfg = package_paths.data_path('negros_panay_timescale_subs_per_site.cfg')
     self.seed = GLOBAL_RNG.randint(1, 999999999)
     self.rng = random.Random()
     self.rng.seed(self.seed)
     self.output_dir = self.get_test_subdir(prefix='dmc-test-')
     self.output_prefix = self.temp_fs.token_id
Exemple #12
0
 def setUp(self):
     self.set_up()
     self.cfg_path = package_paths.data_path('4pairs_1locus.cfg')
     self.cfg_path2 = package_paths.data_path('4pairs_1locus_maxt5.cfg')
     self.np_new_cfg = package_paths.data_path('negros_panay_new.cfg')
     self.np_new_sps_cfg = package_paths.data_path(
         'negros_panay_new_subs_per_site.cfg')
     self.np_cfg = package_paths.data_path('negros_panay_timescale.cfg')
     self.np_sps_cfg = package_paths.data_path(
         'negros_panay_timescale_subs_per_site.cfg')
     self.seed = GLOBAL_RNG.randint(1, 999999999)
     self.rng = random.Random()
     self.rng.seed(self.seed)
     self.output_dir = self.get_test_subdir(prefix='dmc-test-')
     self.output_prefix = self.temp_fs.token_id
 def setUp(self):
     self.set_up()
     self.test_path = self.get_test_path()
     self.cfg_path = package_paths.data_path('4pairs_1locus.cfg')
 def setUp(self):
     self.file = package_paths.data_path("4pairs_1locus.cfg")
     self.bogus_file = package_paths.data_path("bogusdatafilename")
     self.exe = ToolPathManager.get_tool_path('eureject')
Exemple #15
0
 def setUp(self):
     self.new_cfg_path = package_paths.data_path('negros_panay_new.cfg')
 def setUp(self):
     self.set_up()
     self.pdf_path = package_paths.data_path(
             'abctoolbox_posterior_density_file.txt')
Exemple #17
0
 def setUp(self):
     self.new_cfg_path = package_paths.data_path('negros_panay_new.cfg')
 def setUp(self):
     self.set_up()
     self.psf_path = package_paths.data_path(
             'abctoolbox_posterior_summary_file.txt')
Exemple #19
0
    def test_time_scale_old_multi_locus(self):

        cu_cfg_path = package_paths.data_path('4pairs_5loci_old_cu_time.cfg')
        args = ['-o', cu_cfg_path,
                '-p', cu_cfg_path,
                '-r', 1,
                '-n', 400,
                '--num-posterior-samples', 200,
                '--num-standardizing-samples', 300,
                '-q', 100,
                '--np', 4,
                '--seed', self.seed,
                '--debug']
        self._exe_dmc(args, return_code=0)
        results1 = self.get_result_paths(1, 'm1', 1, 400)
        self.assertTrue(os.path.exists(results1['prior-dir']))
        self.assertTrue(os.path.exists(results1['sample']))

        out_dir1 = self.get_test_subdir(prefix='sps-')

        sps_cfg_path = package_paths.data_path('4pairs_5loci_old_sps_time.cfg')
        args = ['-o', sps_cfg_path,
                '-p', sps_cfg_path,
                '-r', 1,
                '-n', 400,
                '--num-posterior-samples', 200,
                '--num-standardizing-samples', 300,
                '-q', 100,
                '--np', 4,
                '--seed', self.seed,
                '--debug']
        self._exe_dmc(args, return_code=0, output_dir = out_dir1)
        results2 = self.get_result_paths(1, 'm1', 1, 400, output_dir = out_dir1)
        self.assertTrue(os.path.exists(results2['prior-dir']))
        self.assertTrue(os.path.exists(results2['sample']))

        results_old = configobj.ConfigObj(results1['summary'])
        results_sps = configobj.ConfigObj(results2['summary'])
        old_times = self.get_value_list(results1['sample'])
        sps_times = self.get_value_list(results2['sample'])
        old_pis = self.get_value_list(results1['sample'], 'pi.')
        sps_pis = self.get_value_list(results2['sample'], 'pi.')
        old_pi_bs = self.get_value_list(results1['sample'], 'pi.net.')
        sps_pi_bs = self.get_value_list(results2['sample'], 'pi.net.')

        mean_theta = 0.01

        self.assertEqual(len(old_times), len(sps_times))
        for i in range(len(old_times)):
            self.assertAlmostEqual(
                    self.convert_time(t = old_times[i],
                        mean_theta = mean_theta,
                        mu = 1.0),
                    self.convert_sps_time(t = sps_times[i], 
                        mu = 1.0),
                    places = 7)
            self.assertAlmostEqual(old_pis[i], sps_pis[i])
            self.assertAlmostEqual(old_pi_bs[i], sps_pi_bs[i])
        self.assertAlmostEqual(
                self.convert_time(t = float(results_old['PRI.E.t']['mean']),
                        mean_theta = mean_theta,
                        mu = 1.0),
                self.convert_sps_time(t = float(results_sps['PRI.E.t']['mean']),
                        mu = 1.0),
                places = 7)
        self.assertAlmostEqual(
                self.convert_time(t = float(results_old['PRI.E.t']['mean']),
                        mean_theta = mean_theta,
                        mu = 1e-8),
                self.convert_sps_time(t = float(results_sps['PRI.E.t']['mean']),
                        mu = 1e-8),
                places = 3)
        self.assertAlmostEqual(
                self.convert_time(t = float(results_old['PRI.E.t']['median']),
                        mean_theta = mean_theta,
                        mu = 1.0),
                self.convert_sps_time(t = float(results_sps['PRI.E.t']['median']),
                        mu = 1.0),
                places = 7)
        self.assertAlmostEqual(
                self.convert_time(t = float(results_old['PRI.omega']['median']),
                        mean_theta = mean_theta,
                        mu = 1.0),
                self.convert_sps_time(t = float(results_sps['PRI.omega']['median']),
                        mu = 1.0),
                places = 7)
        self.assertAlmostEqual(
                self.convert_time(t = float(results_old['PRI.E.t']['range'][0]),
                        mean_theta = mean_theta,
                        mu = 1.0),
                self.convert_sps_time(t = float(results_sps['PRI.E.t']['range'][0]),
                        mu = 1.0),
                places = 7)
        self.assertAlmostEqual(
                self.convert_time(t = float(results_old['PRI.E.t']['range'][1]),
                        mean_theta = mean_theta,
                        mu = 1.0),
                self.convert_sps_time(t = float(results_sps['PRI.E.t']['range'][1]),
                        mu = 1.0),
                places = 7)
        self.assertAlmostEqual(
                self.convert_time(t = float(results_old['PRI.omega']['range'][0]),
                        mean_theta = mean_theta,
                        mu = 1.0),
                self.convert_sps_time(t = float(results_sps['PRI.omega']['range'][0]),
                        mu = 1.0),
                places = 7)
        self.assertAlmostEqual(
                self.convert_time(t = float(results_old['PRI.omega']['range'][1]),
                        mean_theta = mean_theta,
                        mu = 1.0),
                self.convert_sps_time(t = float(results_sps['PRI.omega']['range'][1]),
                        mu = 1.0),
                places = 7)
 def setUp(self):
     self.dir = package_paths.data_path()
     self.file = package_paths.data_path("4pairs_1locus.cfg")
Exemple #21
0
 def setUp(self):
     self.dir = package_paths.data_path()
     self.file = package_paths.data_path("4pairs_1locus.cfg")
Exemple #22
0
    def test_time_scale_old_multi_locus(self):

        cu_cfg_path = package_paths.data_path('4pairs_5loci_old_cu_time.cfg')
        args = [
            '-o', cu_cfg_path, '-p', cu_cfg_path, '-r', 1, '-n', 400,
            '--num-posterior-samples', 200, '--num-standardizing-samples', 300,
            '-q', 100, '--np', 4, '--seed', self.seed, '--debug'
        ]
        self._exe_dmc(args, return_code=0)
        results1 = self.get_result_paths(1, 'm1', 1, 400)
        self.assertTrue(os.path.exists(results1['prior-dir']))
        self.assertTrue(os.path.exists(results1['sample']))

        out_dir1 = self.get_test_subdir(prefix='sps-')

        sps_cfg_path = package_paths.data_path('4pairs_5loci_old_sps_time.cfg')
        args = [
            '-o', sps_cfg_path, '-p', sps_cfg_path, '-r', 1, '-n', 400,
            '--num-posterior-samples', 200, '--num-standardizing-samples', 300,
            '-q', 100, '--np', 4, '--seed', self.seed, '--debug'
        ]
        self._exe_dmc(args, return_code=0, output_dir=out_dir1)
        results2 = self.get_result_paths(1, 'm1', 1, 400, output_dir=out_dir1)
        self.assertTrue(os.path.exists(results2['prior-dir']))
        self.assertTrue(os.path.exists(results2['sample']))

        results_old = configobj.ConfigObj(results1['summary'])
        results_sps = configobj.ConfigObj(results2['summary'])
        old_times = self.get_value_list(results1['sample'])
        sps_times = self.get_value_list(results2['sample'])
        old_pis = self.get_value_list(results1['sample'], 'pi.')
        sps_pis = self.get_value_list(results2['sample'], 'pi.')
        old_pi_bs = self.get_value_list(results1['sample'], 'pi.net.')
        sps_pi_bs = self.get_value_list(results2['sample'], 'pi.net.')

        mean_theta = 0.01

        self.assertEqual(len(old_times), len(sps_times))
        for i in range(len(old_times)):
            self.assertAlmostEqual(self.convert_time(t=old_times[i],
                                                     mean_theta=mean_theta,
                                                     mu=1.0),
                                   self.convert_sps_time(t=sps_times[i],
                                                         mu=1.0),
                                   places=7)
            self.assertAlmostEqual(old_pis[i], sps_pis[i])
            self.assertAlmostEqual(old_pi_bs[i], sps_pi_bs[i])
        self.assertAlmostEqual(
            self.convert_time(t=float(results_old['PRI.E.t']['mean']),
                              mean_theta=mean_theta,
                              mu=1.0),
            self.convert_sps_time(t=float(results_sps['PRI.E.t']['mean']),
                                  mu=1.0),
            places=7)
        self.assertAlmostEqual(
            self.convert_time(t=float(results_old['PRI.E.t']['mean']),
                              mean_theta=mean_theta,
                              mu=1e-8),
            self.convert_sps_time(t=float(results_sps['PRI.E.t']['mean']),
                                  mu=1e-8),
            places=3)
        self.assertAlmostEqual(
            self.convert_time(t=float(results_old['PRI.E.t']['median']),
                              mean_theta=mean_theta,
                              mu=1.0),
            self.convert_sps_time(t=float(results_sps['PRI.E.t']['median']),
                                  mu=1.0),
            places=7)
        self.assertAlmostEqual(
            self.convert_time(t=float(results_old['PRI.omega']['median']),
                              mean_theta=mean_theta,
                              mu=1.0),
            self.convert_sps_time(t=float(results_sps['PRI.omega']['median']),
                                  mu=1.0),
            places=7)
        self.assertAlmostEqual(
            self.convert_time(t=float(results_old['PRI.E.t']['range'][0]),
                              mean_theta=mean_theta,
                              mu=1.0),
            self.convert_sps_time(t=float(results_sps['PRI.E.t']['range'][0]),
                                  mu=1.0),
            places=7)
        self.assertAlmostEqual(
            self.convert_time(t=float(results_old['PRI.E.t']['range'][1]),
                              mean_theta=mean_theta,
                              mu=1.0),
            self.convert_sps_time(t=float(results_sps['PRI.E.t']['range'][1]),
                                  mu=1.0),
            places=7)
        self.assertAlmostEqual(self.convert_time(t=float(
            results_old['PRI.omega']['range'][0]),
                                                 mean_theta=mean_theta,
                                                 mu=1.0),
                               self.convert_sps_time(t=float(
                                   results_sps['PRI.omega']['range'][0]),
                                                     mu=1.0),
                               places=7)
        self.assertAlmostEqual(self.convert_time(t=float(
            results_old['PRI.omega']['range'][1]),
                                                 mean_theta=mean_theta,
                                                 mu=1.0),
                               self.convert_sps_time(t=float(
                                   results_sps['PRI.omega']['range'][1]),
                                                     mu=1.0),
                               places=7)
Exemple #23
0
 def setUp(self):
     self.file = package_paths.data_path("4pairs_1locus.cfg")
     self.bogus_file = package_paths.data_path("bogusdatafilename")
Exemple #24
0
 def setUp(self):
     self.set_up()
     self.cfg_path = package_paths.data_path('4pairs_1locus.cfg')
     self.workq = multiprocessing.Queue()
     self.resultq = multiprocessing.Queue()
Exemple #25
0
 def setUp(self):
     self.file = package_paths.data_path("4pairs_1locus.cfg")
     self.bogus_file = package_paths.data_path("bogusdatafilename")
     self.exe = ToolPathManager.get_tool_path('eureject')
 def setUp(self):
     self.file = package_paths.data_path("4pairs_1locus.cfg")
     self.bogus_file = package_paths.data_path("bogusdatafilename")