Esempio n. 1
0
 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'))
Esempio n. 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)
Esempio n. 3
0
 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')
Esempio n. 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')
Esempio n. 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')
Esempio n. 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)
Esempio n. 7
0
 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'])
Esempio n. 8
0
 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'),
     }
Esempio n. 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)
Esempio n. 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)
Esempio n. 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
Esempio n. 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
Esempio n. 13
0
 def setUp(self):
     self.set_up()
     self.test_path = self.get_test_path()
     self.cfg_path = package_paths.data_path('4pairs_1locus.cfg')
Esempio n. 14
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')
Esempio n. 15
0
 def setUp(self):
     self.new_cfg_path = package_paths.data_path('negros_panay_new.cfg')
Esempio n. 16
0
 def setUp(self):
     self.set_up()
     self.pdf_path = package_paths.data_path(
             'abctoolbox_posterior_density_file.txt')
Esempio n. 17
0
 def setUp(self):
     self.new_cfg_path = package_paths.data_path('negros_panay_new.cfg')
Esempio n. 18
0
 def setUp(self):
     self.set_up()
     self.psf_path = package_paths.data_path(
             'abctoolbox_posterior_summary_file.txt')
Esempio n. 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)
Esempio n. 20
0
 def setUp(self):
     self.dir = package_paths.data_path()
     self.file = package_paths.data_path("4pairs_1locus.cfg")
Esempio n. 21
0
 def setUp(self):
     self.dir = package_paths.data_path()
     self.file = package_paths.data_path("4pairs_1locus.cfg")
Esempio n. 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)
Esempio n. 23
0
 def setUp(self):
     self.file = package_paths.data_path("4pairs_1locus.cfg")
     self.bogus_file = package_paths.data_path("bogusdatafilename")
Esempio n. 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()
Esempio n. 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')
Esempio n. 26
0
 def setUp(self):
     self.file = package_paths.data_path("4pairs_1locus.cfg")
     self.bogus_file = package_paths.data_path("bogusdatafilename")