Ejemplo n.º 1
0
 def setUp(self):
     self.fsc = fsc2.Fsc2Handler(
         name="test-one",
         fsc2_path="fsc",
         working_directory=FSC_DATA_DIR,
         is_calculate_single_population_sfs=True,
         is_calculate_joint_population_sfs=True,
         is_unfolded_site_frequency_spectrum=False,
         is_infinite_sites_model=True,
     )
Ejemplo n.º 2
0
 def get_fsc_handler(self, is_unfolded_site_frequency_spectrum):
     fsc_handler = fsc2.Fsc2Handler(
         name="test-one",
         fsc2_path="fsc",
         working_directory=FSC_DATA_DIR,
         is_calculate_single_population_sfs=True,
         is_calculate_joint_population_sfs=True,
         is_infinite_sites_model=False,
         is_unfolded_site_frequency_spectrum=
         is_unfolded_site_frequency_spectrum,
     )
     return fsc_handler
Ejemplo n.º 3
0
 def test_fsc_config(self):
     fsc_handler = fsc2.Fsc2Handler(
         name="test-one",
         fsc2_path="fsc",
         working_directory=FSC_DATA_DIR,
         is_calculate_single_population_sfs=True,
         is_calculate_joint_population_sfs=True,
         is_unfolded_site_frequency_spectrum=False,
         is_infinite_sites_model=False,
     )
     fsc2_config_d = {
         "d0_population_size": "Test-1",
         "d1_population_size": "Test-2",
         "d0_sample_size": "Test-3",
         "d1_sample_size": "Test-4",
         "div_time": "Test-5",
         "num_sites": "Test-6",
         "recombination_rate": "Test-7",
         "mutation_rate": "Test-8",
         "ti_proportional_bias": "Test-9",
         "fsc2_command": "test",
     }
     dest = StringIO()
     fsc_handler._write_parameter_configuration(dest=dest,
                                                fsc2_config_d=fsc2_config_d)
     result = [row for row in dest.getvalue().split("\n") if row]
     # expected = re.sub(r"{[A-Za-z0-9_]+}", "#Test#", fsc2.FSC2_CONFIG_TEMPLATE)
     expected = [
         "// Number of population samples (demes)", "2",
         "// Population effective sizes (number of genes)", "Test-1",
         "Test-2", "// Sample sizes", "Test-3", "Test-4",
         "// Growth rates: negative growth implies population expansion",
         "0", "0",
         "// Number of migration matrices : 0 implies no migration between demes",
         "0",
         "// Historical event: time, source, sink, migrants, new size, new growth rate, migr. matrix 4 historical event",
         "1  historical event", "Test-5 0 1 1 2 0 0",
         "// Number of independent loci [chromosome]; '0' => same structure for all loci",
         "1 0",
         "// Per chromosome: Number of contiguous linkage Block: a block is a set of contiguous loci",
         "1",
         "// Per Block:data type, number of loci, per generation recombination rate, per generation mutation rate and optional parameters",
         "DNA Test-6 Test-7 Test-8 Test-9", "// Command: test"
     ]
     self.assertEqual(len(expected), len(result))
     for v1, v2 in zip(expected, result):
         self.assertEqual(v1, v2)
Ejemplo n.º 4
0
 def __init__(self,
         name,
         model,
         task_queue,
         results_queue,
         fsc2_path,
         working_directory,
         run_logger,
         logging_frequency,
         messenger_lock,
         random_seed,
         is_calculate_single_population_sfs,
         is_calculate_joint_population_sfs,
         is_unfolded_site_frequency_spectrum,
         is_infinite_sites_model,
         is_concatenate_loci,
         is_normalize_by_concatenated_num_loci,
         is_normalize_by_site_counts,
         stat_label_prefix,
         is_include_model_id_field,
         supplemental_labels,
         is_debug_mode,
         is_store_raw_alignment,
         is_store_raw_mutation_tree,
         is_store_raw_true_tree,
         raw_data_output_prefix,
         raw_data_alignment_format,
         raw_data_tree_format,
         ):
     multiprocessing.Process.__init__(self, name=name)
     self.model = model
     self.rng = random.Random(random_seed)
     self.task_queue = task_queue
     self.results_queue = results_queue
     self.run_logger = run_logger
     self.logging_frequency = logging_frequency
     self.messenger_lock = messenger_lock
     self.is_unfolded_site_frequency_spectrum = is_unfolded_site_frequency_spectrum
     self.stat_label_prefix = stat_label_prefix
     self.is_include_model_id_field = is_include_model_id_field
     self.supplemental_labels = supplemental_labels
     self.is_debug_mode = is_debug_mode
     self.kill_received = False
     self.num_tasks_received = 0
     self.num_tasks_completed = 0
     self.is_store_raw_alignment = is_store_raw_alignment
     # self.is_store_concatenated_alignment = True # TODO
     self.is_concatenate_loci = is_concatenate_loci
     self.is_normalize_by_concatenated_num_loci = is_normalize_by_concatenated_num_loci
     self.is_store_raw_mutation_tree = is_store_raw_mutation_tree
     self.is_store_raw_true_tree = is_store_raw_true_tree
     self.raw_data_output_prefix = raw_data_output_prefix
     self.raw_data_alignment_format = raw_data_alignment_format
     self.raw_data_tree_format = raw_data_tree_format
     self.is_normalize_by_site_counts = is_normalize_by_site_counts,
     self.fsc2_handler = fsc2.Fsc2Handler(
             name=name,
             fsc2_path=fsc2_path,
             working_directory=working_directory,
             is_calculate_single_population_sfs=is_calculate_single_population_sfs,
             is_calculate_joint_population_sfs=is_calculate_joint_population_sfs,
             is_unfolded_site_frequency_spectrum=is_unfolded_site_frequency_spectrum,
             is_infinite_sites_model=is_infinite_sites_model,
             is_store_raw_alignment=self.is_store_raw_alignment,
             is_store_raw_mutation_tree=self.is_store_raw_mutation_tree,
             is_store_raw_true_tree=self.is_store_raw_true_tree,
             raw_data_alignment_format=self.raw_data_alignment_format,
             raw_data_tree_format=self.raw_data_tree_format,
             is_debug_mode=self.is_debug_mode,
             fsc2_params_adjustment_hack=model.fsc2_params_adjustment_hack
             )