def to_file_extra(self, output_filename): home_dir = support.get_home_dir() with open(os.path.join(home_dir, 'extra_params_template')) as t: string = t.readlines() string = ''.join(string) with open(output_filename, 'w') as out: out.write( string.format( str(self.min_N), str(self.max_N), str(self.min_T), str(self.max_T), str(self.min_M), str(self.max_M), str(self.ls_verbose), str(self.ls_flush_delay), str(self.ls_epsilon), str(self.ls_gtol), str(self.ls_maxiter), str(self.hc_mutation_rate), str(self.hc_const_for_mutation_rate), str(self.hc_stop_iter), str(self.random_N_A), str(self.multinom_cross), str(self.multinom_mutate), str(self.time_for_print), str(self.distribution), str(self.std) ))
def to_file(self, output_filename): def comma_sep_repr(l): if l is None: return 'None' if len(l) == 1: return str(l[0]) return ', '.join([str(x) for x in l]) home_dir = support.get_home_dir() with open(os.path.join(home_dir, "params_template")) as t: string = t.readlines() string = ''.join(string) with open(output_filename, 'w') as out: out.write( string.format( self.output_dir, self.resume_dir, self.only_models, self.input_file, comma_sep_repr(self.pop_labels), comma_sep_repr(self.ns), str(self.theta), str(self.gen_time), 'moments' if self.moments_scenario else 'dadi', str(self.multinom), comma_sep_repr(self.dadi_pts), comma_sep_repr(self.initial_structure), comma_sep_repr(self.final_structure), str(self.split_1_lim), str(self.split_2_lim), str(self.relative_params), str(self.no_mig), str(self.size_of_generation), comma_sep_repr(self.fracs), str(self.mutation_strength), str(self.const_for_mut_strength), str(self.mutation_rate), str(self.const_for_mut_rate), str(self.epsilon), str(self.stop_iter), str(self.optimize_name), str(self.draw_iter), str(self.code_iter), 'Thousand Years' if self.gen_time_units == 1000 else 'Years', str(self.silence), str(self.repeats), str(self.processes), str(self.only_sudden), str(self.model_func_file), comma_sep_repr(self.lower_bound), comma_sep_repr(self.upper_bound), comma_sep_repr(self.p_ids), str(self.linked_snp), str(self.boot_dir) ))
def test_args(): ''' Put default args for test case. ''' global options_storage import tempfile options_storage.output_dir = tempfile.mkdtemp("gadma_test_dir") options_storage.output_dir = support.ensure_dir_existence( options_storage.output_dir) options_storage.input_file = os.path.join(support.get_home_dir(), "..", "fs_examples", "test.fs") options_storage.input_data, options_storage.ns, options_storage.pop_labels = support.load_spectrum( options_storage.input_file, None, None) options_storage.ns = np.array(options_storage.ns) options_storage.number_of_populations = 1 options_storage.linked_snp = False options_storage.theta = 0.37976 options_storage.gen_time = 25 options_storage.initial_structure = np.array([1]) options_storage.final_structure = np.array([2]) options_storage.size_of_generation = 5 options_storage.fracs = [ float(x) for x in options_storage.fracs.split(",") ] options_storage.frac_of_old_models = options_storage.fracs[0] options_storage.frac_of_mutated_models = options_storage.fracs[1] options_storage.frac_of_crossed_models = options_storage.fracs[2] options_storage.optimize_name = 'hill_climbing' options_storage.moments_scenario = True options_storage.relative_params = False options_storage.dadi_pts = [20, 30, 40] options_storage.repeats = 2 options_storage.processes = 2 options_storage.epsilon = 1 options_storage.test = True options_storage.multinom = True options_storage.final_check() return options_storage