Skip to content

Commit

Permalink
Merge pull request #167 from benjeffery/preprocess
Browse files Browse the repository at this point in the history
Move preprocessing to separate step
  • Loading branch information
benjeffery authored Sep 13, 2024
2 parents 1f3bfbd + 65ef4c1 commit b3addbd
Show file tree
Hide file tree
Showing 15 changed files with 1,079 additions and 989 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ It is particularly useful to help evaluate ARGs that have been inferred using to
[KwARG](https://github.com/a-ignatieva/kwarg),
[Threads](https://pypi.org/project/threads-arg/), etc.

To view a tskit tree sequence or tszip file first pre-process it:

`python -m tsbrowse preprocess /path/to/trees-file`

This will write a `.tsbrowse` file

To launch the app use:

`python -m tsbrowse /path/to/trees-file`
`python -m tsbrowse serve /path/to/tsbrowse-file`

On WSL, it may be necessary to disable Numba's CUDA support:

`NUMBA_DISABLE_CUDA=1 python -m tsbrowse /path/to/trees-file`
`NUMBA_DISABLE_CUDA=1 python -m tsbrowse serve /path/to/tsbrowse-file`

## Installation

Expand Down
31 changes: 31 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os

import tszip
from click.testing import CliRunner

from . import test_preprocess
from tsbrowse import __main__ as main


def test_preprocess_cli(tmpdir):
tszip_path = os.path.join(tmpdir, "test_input.tszip")
default_output_path = os.path.join(tmpdir, "test_input.tsbrowse")
custom_output_path = os.path.join(tmpdir, "custom_input.tsbrowse")

ts = test_preprocess.single_tree_example_ts()
tszip.compress(ts, tszip_path)

runner = CliRunner()
result = runner.invoke(main.cli, ["preprocess", tszip_path])
assert result.exit_code == 0
assert os.path.exists(default_output_path)
tszip.load(default_output_path).tables.assert_equals(ts.tables)

result = runner.invoke(
main.cli, ["preprocess", tszip_path, "--output", custom_output_path]
)
assert result.exit_code == 0
assert os.path.exists(custom_output_path)
tszip.load(custom_output_path).tables.assert_equals(ts.tables)

# TODO Load into model and check that the model is correct
Loading

0 comments on commit b3addbd

Please sign in to comment.