def verify(self, input_ts, cmd): with tempfile.TemporaryDirectory() as tmpdir: input_filename = pathlib.Path(tmpdir) / "input.trees" input_ts.dump(input_filename) output_filename = pathlib.Path(tmpdir) / "output.trees" full_cmd = str(input_filename) + f" {output_filename} " + cmd cli.tsdate_main(full_cmd.split()) output_ts = tskit.load(output_filename) self.assertEqual(input_ts.num_samples, output_ts.num_samples) self.ts_equal_except_times(input_ts, output_ts)
def preprocess_compare_python_api(self, input_ts): with tempfile.TemporaryDirectory() as tmpdir: input_filename = pathlib.Path(tmpdir) / "input.trees" input_ts.dump(input_filename) output_filename = pathlib.Path(tmpdir) / "output.trees" full_cmd = "preprocess " + str(input_filename) + f" {output_filename}" print(full_cmd) cli.tsdate_main(full_cmd.split()) output_ts = tskit.load(output_filename) preprocessed_ts = tsdate.preprocess_ts(input_ts) self.ts_equal(output_ts, preprocessed_ts, times_equal=True)
def compare_python_api(self, input_ts, cmd, Ne, mutation_rate, method): with tempfile.TemporaryDirectory() as tmpdir: input_filename = pathlib.Path(tmpdir) / "input.trees" input_ts.dump(input_filename) output_filename = pathlib.Path(tmpdir) / "output.trees" full_cmd = "date " + str(input_filename) + f" {output_filename} " + cmd cli.tsdate_main(full_cmd.split()) output_ts = tskit.load(output_filename) dated_ts = tsdate.date(input_ts, Ne=Ne, mutation_rate=mutation_rate, method=method) print(dated_ts.tables.nodes.time, output_ts.tables.nodes.time) self.assertTrue(np.array_equal(dated_ts.tables.nodes.time, output_ts.tables.nodes.time))
def main(): cli.tsdate_main()