|
1 | | -""" |
2 | | -Script to automate verification of msprime against known statistical |
3 | | -results and benchmark programs such as ms and Seq-Gen. |
4 | | -
|
5 | | -Tests are structured in a similar way to Python unittests. Tests |
6 | | -are organised into classes of similar tests. Ideally, each test |
7 | | -in the class is a simple call to a general method with |
8 | | -different parameters (this is called ``_run``, by convention). |
9 | | -Tests must be *independent* and not depend on any shared |
10 | | -state within the test class, other than the ``self.output_dir`` |
11 | | -variable which is guaranteed to be set when the method is called. |
12 | | -
|
13 | | -The output directory is <output-dir>/<class name>/<test name>. |
14 | | -Each test should output one or more diagnostic plots, which have |
15 | | -a clear interpretation as "correct" or "incorrect". QQ-plots |
16 | | -are preferred, where possible. Numerical results can also be |
17 | | -output by using ``logging.debug()``, where appropriate; to |
18 | | -view these, append ``--debug`` to the comand line running |
19 | | -your tests. |
20 | | -
|
21 | | -Test classes must be a subclass of the ``Test`` class defined |
22 | | -in this module. |
23 | | -
|
24 | | -To run the tests, first get some help from the CLI: |
25 | | -
|
26 | | - python3 verification.py --help |
27 | | -
|
28 | | -This will output some basic help on the tests. Use |
29 | | -
|
30 | | - python3 verification.py --list |
31 | | -
|
32 | | -to show all the available tests. |
33 | | -
|
34 | | -If you run without any arguments, this will run all the tests |
35 | | -sequentially. The progress bar and output behaviour can be |
36 | | -controlled using command line parameters, and running over |
37 | | -multiple processes is possible. |
38 | | -
|
39 | | -If you wish to run a specific tests, you can provide the |
40 | | -test names as positional arguments, i.e., |
41 | | -
|
42 | | - python3 verification.py test_msdoc_outgroup_sequence test_msdoc_recomb_ex |
43 | | -
|
44 | | -will just run these two specific tests. |
45 | | -
|
46 | | -Using the ``-c`` option allows you to run all tests in a |
47 | | -given class. |
48 | | -
|
49 | | -Gotchas: |
50 | | -- Any test superclasses must be abstract. That is, you cannot |
51 | | - inherit from a test class that contains any tests. |
52 | | -- Test method names must be unique across *all* classes. |
53 | | -
|
54 | | -""" |
| 1 | +# Script to automate verification of msprime against known statistical |
| 2 | +# results and benchmark programs such as ms and Seq-Gen. |
| 3 | +# Tests are structured in a similar way to Python unittests. Tests |
| 4 | +# are organised into classes of similar tests. Ideally, each test |
| 5 | +# in the class is a simple call to a general method with |
| 6 | +# different parameters (this is called ``_run``, by convention). |
| 7 | +# Tests must be *independent* and not depend on any shared |
| 8 | +# state within the test class, other than the ``self.output_dir`` |
| 9 | +# variable which is guaranteed to be set when the method is called. |
| 10 | +# The output directory is <output-dir>/<class name>/<test name>. |
| 11 | +# Each test should output one or more diagnostic plots, which have |
| 12 | +# a clear interpretation as "correct" or "incorrect". QQ-plots |
| 13 | +# are preferred, where possible. Numerical results can also be |
| 14 | +# output by using ``logging.debug()``, where appropriate; to |
| 15 | +# view these, append ``--debug`` to the comand line running |
| 16 | +# your tests. |
| 17 | +# Test classes must be a subclass of the ``Test`` class defined |
| 18 | +# in this module. |
| 19 | +# To run the tests, first get some help from the CLI: |
| 20 | +# python3 verification.py --help |
| 21 | +# This will output some basic help on the tests. Use |
| 22 | +# python3 verification.py --list |
| 23 | +# to show all the available tests. |
| 24 | +# If you run without any arguments, this will run all the tests |
| 25 | +# sequentially. The progress bar and output behaviour can be |
| 26 | +# controlled using command line parameters, and running over |
| 27 | +# multiple processes is possible. |
| 28 | +# If you wish to run a specific tests, you can provide the |
| 29 | +# test names as positional arguments, i.e., |
| 30 | +# python3 verification.py test_msdoc_outgroup_sequence test_msdoc_recomb_ex |
| 31 | +# will just run these two specific tests. |
| 32 | +# Using the ``-c`` option allows you to run all tests in a |
| 33 | +# given class. |
| 34 | +# Gotchas: |
| 35 | +# - Any test superclasses must be abstract. That is, you cannot |
| 36 | +# inherit from a test class that contains any tests. |
| 37 | +# - Test method names must be unique across *all* classes. |
55 | 38 | import argparse |
56 | 39 | import ast |
57 | 40 | import collections |
@@ -5643,9 +5626,10 @@ def _run_seq_gen(self, tree, args, model, alleles, num_sites, mutation_rate, Q): |
5643 | 5626 | newick = tree.newick() |
5644 | 5627 | cmd = self._seq_gen_executable + args |
5645 | 5628 | num_sequences = 2 * ts.num_samples - 1 |
5646 | | - with tempfile.TemporaryFile("w+") as in_file, tempfile.TemporaryFile( |
5647 | | - "w+" |
5648 | | - ) as out_file: |
| 5629 | + with ( |
| 5630 | + tempfile.TemporaryFile("w+") as in_file, |
| 5631 | + tempfile.TemporaryFile("w+") as out_file, |
| 5632 | + ): |
5649 | 5633 | in_file.write(newick) |
5650 | 5634 | in_file.seek(0) |
5651 | 5635 | subprocess.call(cmd, stdin=in_file, stdout=out_file) |
|
0 commit comments