Showing preview only (7,725K chars total). Download the full file or copy to clipboard to get everything.
Repository: tskit-dev/tskit
Branch: main
Commit: 40698f504b6e
Files: 220
Total size: 7.3 MB
Directory structure:
gitextract_7z1tql5y/
├── .clang-format
├── .github/
│ ├── PULL_REQUEST_TEMPLATE.md
│ └── workflows/
│ ├── docs.yml
│ ├── lint.yml
│ ├── release-c.yml
│ ├── tests.yml
│ └── wheels.yml
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── c/
│ ├── .gitignore
│ ├── CHANGELOG.rst
│ ├── VERSION.txt
│ ├── examples/
│ │ ├── Makefile
│ │ ├── api_structure.c
│ │ ├── cpp_sorting_example.cpp
│ │ ├── error_handling.c
│ │ ├── haploid_wright_fisher.c
│ │ ├── json_struct_metadata.c
│ │ ├── multichrom_wright_fisher.c
│ │ ├── multichrom_wright_fisher_singlethreaded.c
│ │ ├── streaming.c
│ │ ├── take_ownership.c
│ │ ├── tree_iteration.c
│ │ └── tree_traversal.c
│ ├── meson.build
│ ├── meson_options.txt
│ ├── subprojects/
│ │ └── kastore/
│ │ ├── README.md
│ │ ├── VERSION.txt
│ │ ├── kastore.c
│ │ ├── kastore.h
│ │ └── meson.build
│ ├── tests/
│ │ ├── meson-subproject/
│ │ │ ├── example.c
│ │ │ └── meson.build
│ │ ├── test_convert.c
│ │ ├── test_core.c
│ │ ├── test_file_format.c
│ │ ├── test_genotypes.c
│ │ ├── test_haplotype_matching.c
│ │ ├── test_minimal_cpp.cpp
│ │ ├── test_stats.c
│ │ ├── test_tables.c
│ │ ├── test_trees.c
│ │ ├── testlib.c
│ │ └── testlib.h
│ ├── tskit/
│ │ ├── convert.c
│ │ ├── convert.h
│ │ ├── core.c
│ │ ├── core.h
│ │ ├── genotypes.c
│ │ ├── genotypes.h
│ │ ├── haplotype_matching.c
│ │ ├── haplotype_matching.h
│ │ ├── stats.c
│ │ ├── stats.h
│ │ ├── tables.c
│ │ ├── tables.h
│ │ ├── trees.c
│ │ └── trees.h
│ └── tskit.h
├── codecov.yml
├── docs/
│ ├── .gitignore
│ ├── Makefile
│ ├── _config.yml
│ ├── _static/
│ │ ├── README
│ │ └── bespoke.css
│ ├── _toc.yml
│ ├── build.sh
│ ├── c-api.rst
│ ├── changelogs.rst
│ ├── citation.md
│ ├── cli.md
│ ├── data/
│ │ └── basic_tree_seq.trees
│ ├── data-model.md
│ ├── development.md
│ ├── doxygen/
│ │ └── Doxyfile
│ ├── export.md
│ ├── file-formats.md
│ ├── glossary.md
│ ├── ibd.md
│ ├── installation.md
│ ├── introduction.md
│ ├── metadata.md
│ ├── numba.md
│ ├── provenance.md
│ ├── python-api.md
│ ├── quickstart.md
│ ├── stats.md
│ ├── substitutions/
│ │ ├── linear_traversal_warning.rst
│ │ ├── table_edit_warning.rst
│ │ ├── table_keep_rows_main.rst
│ │ ├── tree_array_warning.rst
│ │ └── virtual_root_array_note.rst
│ └── topological-analysis.md
├── prek.toml
└── python/
├── .gitignore
├── CHANGELOG.rst
├── MANIFEST.in
├── Makefile
├── README.rst
├── _tskitmodule.c
├── benchmark/
│ ├── config.yaml
│ ├── run-for-all-releases.py
│ └── run.py
├── lwt_interface/
│ ├── CHANGELOG.rst
│ ├── Makefile
│ ├── README.md
│ ├── cython_example/
│ │ ├── Makefile
│ │ ├── _lwtc.c
│ │ ├── example.pyx
│ │ ├── pyproject.toml
│ │ └── setup.py
│ ├── dict_encoding_testlib.py
│ ├── example_c_module.c
│ ├── setup.py
│ ├── test_example_c_module.py
│ └── tskit_lwt_interface.h
├── pyproject.toml
├── setup.py
├── stress_lowlevel.py
├── tests/
│ ├── __init__.py
│ ├── conftest.py
│ ├── data/
│ │ ├── SLiM/
│ │ │ ├── README
│ │ │ ├── minimal-example.trees
│ │ │ ├── minimal-example.txt
│ │ │ ├── single-locus-example.trees
│ │ │ └── single-locus-example.txt
│ │ ├── dict-encodings/
│ │ │ ├── generate_msprime.py
│ │ │ └── msprime-0.7.4.pkl
│ │ ├── hdf5-formats/
│ │ │ ├── msprime-0.3.0_v2.0.hdf5
│ │ │ ├── msprime-0.4.0_v3.1.hdf5
│ │ │ └── msprime-0.5.0_v10.0.hdf5
│ │ ├── old-formats/
│ │ │ └── tskit-0.3.3.trees
│ │ └── simplify-bugs/
│ │ ├── 01-edges.txt
│ │ ├── 01-mutations.txt
│ │ ├── 01-nodes.txt
│ │ ├── 01-sites.txt
│ │ ├── 02-edges.txt
│ │ ├── 02-mutations.txt
│ │ ├── 02-nodes.txt
│ │ ├── 02-sites.txt
│ │ ├── 03-edges.txt
│ │ ├── 03-mutations.txt
│ │ ├── 03-nodes.txt
│ │ ├── 03-sites.txt
│ │ ├── 04-edges.txt
│ │ ├── 04-mutations.txt
│ │ ├── 04-nodes.txt
│ │ ├── 04-sites.txt
│ │ ├── 05-edges.txt
│ │ ├── 05-mutations.txt
│ │ ├── 05-nodes.txt
│ │ └── 05-sites.txt
│ ├── ibd.py
│ ├── simplify.py
│ ├── test_avl_tree.py
│ ├── test_balance_metrics.py
│ ├── test_cli.py
│ ├── test_coalrate.py
│ ├── test_combinatorics.py
│ ├── test_dict_encoding.py
│ ├── test_distance_metrics.py
│ ├── test_divmat.py
│ ├── test_drawing.py
│ ├── test_extend_haplotypes.py
│ ├── test_file_format.py
│ ├── test_fileobj.py
│ ├── test_genotype_matching.py
│ ├── test_genotypes.py
│ ├── test_haplotype_matching.py
│ ├── test_highlevel.py
│ ├── test_ibd.py
│ ├── test_immutable_table_collection.py
│ ├── test_intervals.py
│ ├── test_jit.py
│ ├── test_ld_matrix.py
│ ├── test_metadata.py
│ ├── test_ms.py
│ ├── test_parsimony.py
│ ├── test_phylo_formats.py
│ ├── test_provenance.py
│ ├── test_python_c.py
│ ├── test_reference_sequence.py
│ ├── test_relatedness_vector.py
│ ├── test_stats.py
│ ├── test_table_transforms.py
│ ├── test_tables.py
│ ├── test_text_formats.py
│ ├── test_threads.py
│ ├── test_topology.py
│ ├── test_tree_positioning.py
│ ├── test_tree_stats.py
│ ├── test_util.py
│ ├── test_utilities.py
│ ├── test_vcf.py
│ ├── test_version.py
│ ├── test_wright_fisher.py
│ └── tsutil.py
└── tskit/
├── __init__.py
├── __main__.py
├── _version.py
├── cli.py
├── combinatorics.py
├── drawing.py
├── exceptions.py
├── genotypes.py
├── intervals.py
├── jit/
│ ├── __init__.py
│ └── numba.py
├── metadata.py
├── metadata_schema.schema.json
├── provenance.py
├── provenance.schema.json
├── stats.py
├── tables.py
├── text_formats.py
├── trees.py
├── util.py
└── vcf.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .clang-format
================================================
Language: Cpp
BasedOnStyle: GNU
SortIncludes: false
AllowShortIfStatementsOnASingleLine: false
BreakBeforeBraces: Linux
TabWidth: 4
IndentWidth: 4
ColumnLimit: 89
SpaceBeforeParens:
ControlStatements
SpacesInCStyleCastParentheses: false
SpaceAfterCStyleCast: true
IndentCaseLabels: true
AlignAfterOpenBracket: DontAlign
BinPackArguments: true
BinPackParameters: true
AlwaysBreakAfterReturnType: AllDefinitions
StatementMacros: ["PyObject_HEAD", "Py_BEGIN_ALLOW_THREADS", "Py_END_ALLOW_THREADS"]
AlignConsecutiveMacros: true
================================================
FILE: .github/PULL_REQUEST_TEMPLATE.md
================================================
## Description
Thanks for contributing to tskit! :heart:
A guide to the PR process is [here](https://tskit.dev/tskit/docs/stable/development.html#git-workflow)
Please replace this text with a summary of the change and which issue is fixed, if any. Please also include relevant motivation and context.
Fixes #(issue) <- Putting the issue number here will auto-close the issue when this PR is merged
# PR Checklist:
- [ ] Tests that fully cover new/changed functionality.
- [ ] Documentation including tutorial content if appropriate.
- [ ] Changelogs, if there are API changes.
================================================
FILE: .github/workflows/docs.yml
================================================
name: Build Docs
on:
pull_request:
merge_group:
push:
branches: [main]
tags:
- '*'
env:
FORCE_COLOR: 1
jobs:
Docs:
uses: tskit-dev/.github/.github/workflows/docs.yml@v15
with:
pyproject-directory: python
additional-apt-packages: doxygen
pre-build-command: cd docs/doxygen && doxygen
================================================
FILE: .github/workflows/lint.yml
================================================
name: Lint
on:
pull_request:
merge_group:
jobs:
Lint:
uses: tskit-dev/.github/.github/workflows/lint.yml@v15
with:
pyproject-directory: python
================================================
FILE: .github/workflows/release-c.yml
================================================
name: Publish C API release
on:
push:
branches: [main, test]
tags: ['*']
env:
FORCE_COLOR: 1
jobs:
build:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: "0.10.0"
- name: Install system deps
run: |
sudo apt-get update
sudo apt-get install -y ninja-build libcunit1-dev
- name: Install meson
run: uv tool install meson==1.10.1
- name: Build tarball
run: |
git rm -rf c/tests/meson-subproject
git config --global user.email "CI@CI.com"
git config --global user.name "Mr Robot"
git add -A
git commit -m "dummy commit to make meson not add in the symlinked directory"
meson c build-gcc
meson dist -C build-gcc
- name: C Release
uses: softprops/action-gh-release@v2.5.0
if: startsWith(github.ref, 'refs/tags/') && contains(github.event.ref, 'C_')
with:
draft: True
files: build-gcc/meson-dist/*
================================================
FILE: .github/workflows/tests.yml
================================================
name: Tests
on:
pull_request:
merge_group:
push:
branches: [main, test]
env:
FORCE_COLOR: 1
jobs:
packaging:
name: Python packaging
uses: tskit-dev/.github/.github/workflows/python-packaging.yml@v15
with:
pyproject-directory: python
cli-test-cmd: tskit --help
test-c:
name: C tests
uses: tskit-dev/.github/.github/workflows/c-tests.yml@v15
with:
library-directory: c
secrets: inherit
test-python-c:
name: Python-C tests
uses: tskit-dev/.github/.github/workflows/python-c-tests.yml@v15
with:
tests: python/tests/test_python_c.py python/tests/test_dict_encoding.py
pyproject-directory: python
secrets: inherit
test:
name: Python
uses: tskit-dev/.github/.github/workflows/python-tests.yml@v15
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python }}
pyproject-directory: python
coverage-directory: python/tskit
secrets: inherit
strategy:
matrix:
python: [ 3.11, 3.13 ]
os: [ macos-latest, ubuntu-24.04, windows-latest ]
msys2:
runs-on: windows-latest
strategy:
matrix:
include:
- { sys: mingw32, env: i686 }
- { sys: mingw64, env: x86_64 }
name: Windows (${{ matrix.sys }}, ${{ matrix.env }})
defaults:
run:
shell: msys2 {0}
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.13.0
with:
access_token: ${{ github.token }}
- name: 'Checkout'
uses: actions/checkout@v6.0.2
- name: Setup MSYS2 ${{matrix.sys}}
uses: msys2/setup-msys2@v2.27.0
with:
msystem: ${{matrix.sys}}
update: true
install: >-
git
mingw-w64-${{matrix.env}}-toolchain
mingw-w64-${{matrix.env}}-ninja
mingw-w64-${{matrix.env}}-meson
mingw-w64-${{matrix.env}}-cunit
- name: Build
working-directory: c
run: |
meson build -Dbuild_examples=false
ninja -C build
- name: Run tests
working-directory: c
run: |
ninja -C build test
bespoke-python-test:
name: Bespoke Python tests
runs-on: ubuntu-24.04
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.13.0
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v6.0.2
with:
submodules: true
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v6
with:
python-version: 3.11
version: "0.10.0"
- name: Install Python dependencies
working-directory: python
run: uv sync --locked --group test --no-default-groups
- name: Minidom test
working-directory: python
# Importing either IPython or pytest causes import of xml.dom.minidom
# So to actually test that tskit imports it, we need a minimal test
run: |
uv run --locked --group test --no-default-groups \
python -c "import tskit;tskit.Tree.generate_star(5).tree_sequence.draw_svg(path='test.svg')"
- name: Run JIT code coverage
run: |
NUMBA_DISABLE_JIT=1 uv run --locked --project=python --no-default-groups\
pytest --cov=python/tskit --cov-report=xml --cov-branch \
python/tests/test_jit.py
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
files: coverage.xml
disable_search: true
verbose: true
flags: python-tests-no-jit
- name: Build example LWT interface code and test
working-directory: python/lwt_interface/
run: |
make allchecks
uv run --project=../ --group=test pytest -vs
- name: Build cython example LWT interface code and run
working-directory: python/lwt_interface/cython_example
run: make
bespoke-c-test:
name: Bespoke C tests
runs-on: ubuntu-24.04
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.13.0
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v6.0.2
with:
submodules: true
- name: Install system deps
run: |
sudo apt-get update
sudo apt-get install -y libcunit1-dev ninja-build clang
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: "0.10.0"
- name: Install uv deps
run: |
uv tool install meson==1.10.1
- name: Configure code
run: CFLAGS=-D_TSK_BIG_TABLES CPPFLAGS=-D_TSK_BIG_TABLES meson setup build-bt c/
- name: Compile
run: ninja -C build-bt
- name: Run tests
run: ninja -C build-bt test
- name: Test building with meson subproject
run: |
meson build-subproject c/tests/meson-subproject
ninja -C build-subproject
./build-subproject/example
- name: Install shared library and hand-compile program.
run: |
meson build-install c --prefix=/usr
sudo ninja -C build-install install
clang c/examples/api_structure.c -I c/subprojects/kastore -o api_structure -ltskit
./api_structure
- name: Run example make file
run: |
make -C c/examples
================================================
FILE: .github/workflows/wheels.yml
================================================
name: Publish Python release
on:
push:
branches: [test-publish]
release:
types: [published]
jobs:
build-wheels:
if: "!startsWith(github.ref, 'refs/tags/C_')"
uses: tskit-dev/.github/.github/workflows/build-wheels.yml@v15
with:
pyproject-directory: python
publish:
runs-on: ubuntu-24.04
environment: release
needs: [ 'build-wheels' ]
permissions:
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v7.0.0
with:
pattern: build-*
path: dist
merge-multiple: true
- name: Show artifacts
run: ls -lah dist
- name: Publish distribution to Test PyPI
if: github.event_name == 'push' && github.ref_name == 'test-publish'
uses: pypa/gh-action-pypi-publish@v1.13.0
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
- name: Publish distribution to Production PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@v1.13.0
================================================
FILE: .gitignore
================================================
build-gcc
.DS_Store
python/benchmark/*.trees
python/benchmark/*.json
python/benchmark/*.html
.venv
.env
.vscode
env
================================================
FILE: CONTRIBUTING.md
================================================
# Contributing
Tskit is a free and open-source project that welcomes contributions from everyone.
The [Developer documentation](https://tskit.dev/tskit/docs/latest/development.html)
will help you get started.
We have an active slack group where tskit and associated projects are discussed.
If you wish to join email [admin@tskit.dev](mailto:admin@tskit.dev).
We ask all users to follow our [code of conduct](https://github.com/tskit-dev/.github/blob/main/CODE_OF_CONDUCT.md)
when interacting with the project.
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2018-2019 Tskit Developers
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# tskit <img align="right" width="145" height="90" src="https://github.com/tskit-dev/administrative/blob/main/tskit_logo.svg">
[](https://github.com/tskit-dev/tskit/blob/main/LICENSE)
[](https://github.com/tskit-dev/tskit/graphs/contributors)
[](https://github.com/tskit-dev/tskit/commits/main)
[](https://codecov.io/gh/tskit-dev/tskit)

[Documentation (stable)](https://tskit.dev/tskit/docs/stable/) • [Documentation (latest)](https://tskit.dev/tskit/docs/latest/)
[](https://github.com/tskit-dev/tskit/actions/workflows/docs.yml)[](https://github.com/tskit-dev/tskit/actions/workflows/tests.yml)
The succinct tree sequence (`tskit`) format is an efficient way of representing
the genetic history - sometimes known as an
[Ancestral Recombination Graph or ARG](https://doi.org/10.1093/genetics/iyae100) -
of a set of related DNA sequences. `Tskit` is used
by a number of software libraries and programs (such as
[msprime](https://github.com/tskit-dev/msprime),
[SLiM](https://github.com/MesserLab/SLiM),
[fwdpp](http://molpopgen.github.io/fwdpp/), and
[tsinfer](https://tskit.dev/tsinfer/docs/stable/)) that either simulate or infer
the evolutionary ancestry of genetic sequences.
The `tskit` library provides the underlying functionality used to load, examine, and
manipulate ARGs in the tree sequence format, including efficient access to the
sequence of correlated trees along a genome and general methods to calculate
genetic statistics. `Tskit` often forms part of an installation of other
software packages such as those listed above. Please see the
[documentation](https://tskit.dev/tskit/docs/stable/) for further details, which
includes
[installation instructions](https://tskit.dev/tskit/docs/stable/installation.html).
To get started with tskit, tutorials and other content are at http://tskit.dev. For help
and support from the community you can use
[discussions](https://github.com/tskit-dev/tskit/discussions) here on github, or raise an
issue for a specific bug or feature request.
We warmly welcome contributions from the community. Raise an issue if you have an
idea you'd like to work on, or submit a PR for comments and help.
The base `tskit` library provides both a [Python](https://tskit.dev/tskit/docs/stable/python-api.html)
and [C](https://tskit.dev/tskit/docs/stable/c-api.html) API. A Rust API is provided in the
[tskit-rust](https://github.com/tskit-dev/tskit-rust) repository.
#### Python API
[](https://pypi.org/project/tskit/)
[](https://pypi.org/project/tskit/)
[](https://pypi.org/project/tskit/)
[](https://github.com/psf/black)
Most users of `tskit` will use the python API as it provides a convenient, high-level API
to access, analyse and create tree sequences. Full documentation is
[here](https://tskit.dev/tskit/docs/stable/python-api.html).
#### C API
[](https://en.wikipedia.org/wiki/C99)
The `tskit` C API provides comprehensive, low-level methods for manipulating and
processing tree-sequences. Written to the C99 standard and fully thread-safe, it can be
used with either C or C++. Full documentation is
[here](https://tskit.dev/tskit/docs/stable/c-api.html).
## Installation
```bash
python -m pip install tskit
# or
conda install -c conda-forge tskit
```
================================================
FILE: c/.gitignore
================================================
build
.*.swp
.*.swo
================================================
FILE: c/CHANGELOG.rst
================================================
--------------------
[1.3.2] - 2026-XX-XX
--------------------
In development
- Add ``tsk_json_struct_metadata_get_blob`` function
(:user:`benjeffery`, :pr:`3306`)
--------------------
[1.3.1] - 2026-03-06
--------------------
Maintenance release.
- Update to kastore 2.1.2
- Fix doc typo for file uuid (:pr:`3399`)
- Migrate linting to clang-format 21.1.8 (:pr:`3389`)
- Support compile time setting of debug stream (:pr:`3364`)
--------------------
[1.3.0] - 2025-11-27
--------------------
**Breaking changes**
- ``trees.c`` now depends on ``genotypes.c`` (via ``tskit/genotypes.h``) and must
be built and linked together with it.
(:user:`benjeffery`, :pr:`3324`)
**Features**
- ``tsk_variant_init`` and associated variant decoding methods now
fully support ``TSK_ISOLATED_NOT_MISSING`` not being set for internal nodes.
(:user:`benjeffery`, :pr:`3313`)
- Add ``tsk_treeseq_decode_alignments`` to decode full-length reference-based
sequence alignments for specified nodes over a genomic interval, respecting
``TSK_ISOLATED_NOT_MISSING`` semantics.
(:user:`benjeffery`, :pr:`3324`, :issue:`3319`)
--------------------
[1.2.0] - 2025-09-24
--------------------
**Breaking changes**
- Remove ``tsk_diff_iter_t`` and associated functions.
(:user:`benjeffery`, :pr:`3221`, :issue:`2797`).
- ``tsk_treeseq_init`` now requires that mutation parents in the table collection
are correct and consistent with the topology of the tree at each mutation site.
Returns ``TSK_ERR_BAD_MUTATION_PARENT`` if this is not the case, or
``TSK_ERR_MUTATION_PARENT_AFTER_CHILD`` if the mutations are not in an order
compatible with the correct mutation parent.
(:user:`benjeffery`, :issue:`2729`, :issue:`2732`, :pr:`3212`).
**Features**
- Add ``TSK_TS_INIT_COMPUTE_MUTATION_PARENTS`` to ``tsk_treeseq_init``
to compute mutation parents from the tree sequence topology.
Note that the mutations must be in the correct order.
(:user:`benjeffery`, :issue:`2757`, :pr:`3212`).
- Add ``TSK_CHECK_MUTATION_PARENTS`` option to ``tsk_table_collection_check_integrity``
to check that mutation parents are consistent with the tree sequence topology.
This option implies ``TSK_CHECK_TREES``.
(:user:`benjeffery`, :issue:`2729`, :issue:`2732`, :pr:`3212`).
- Add the ``TSK_NO_CHECK_INTEGRITY`` option to ``tsk_table_collection_compute_mutation_parents``
to skip the integrity checks that are normally run when computing mutation parents.
This is useful for speeding up the computation of mutation parents when the
tree sequence is certainly known to be valid.
(:user:`benjeffery`, :pr:`3212`).
- Mutations returned by ``tsk_treeseq_get_mutation`` now include pre-computed
``inherited_state`` and ``inherited_state_length`` fields. The inherited state
is computed during tree sequence initialization and represents the state that
existed at the site before each mutation occurred (either the ancestral state
if the mutation is the root mutation or the derived state of the parent mutation).
Note that this breaks ABI compatibility due to the addition of these fields
to the ``tsk_mutation_t`` struct.
(:user:`benjeffery`, :pr:`3277`, :issue:`2631`).
--------------------
[1.1.4] - 2025-03-31
--------------------
**Changes**
- Added the TSK_TRACE_ERRORS macro to enable tracing of errors in the C library.
This is useful for debugging as errors will print to stderr when set.
(:user:`jeromekelleher`, :pr:`3095`).
--------------------
[1.1.3] - 2024-10-16
--------------------
**Features**
- Add the `tsk_treeseq_extend_haplotypes` method that can compress a tree sequence
by extending edges into adjacent trees and thus creating unary nodes in those
trees (:user:`petrelharp`, :user:`hfr1tze`, :user:`avabamf`, :pr:`2651`, :pr:`2938`).
--------------------
[1.1.2] - 2023-05-17
--------------------
**Performance improvements**
- tsk_tree_seek is now much faster at seeking to arbitrary points along
the sequence from the null tree (:user:`molpopgen`, :pr:`2661`).
**Features**
- The struct ``tsk_treeseq_t`` now has the variables ``min_time`` and ``max_time``,
which are the minimum and maximum among the node times and mutation times,
respectively. ``min_time`` and ``max_time`` can be accessed using the functions
``tsk_treeseq_get_min_time`` and ``tsk_treeseq_get_max_time``, respectively.
(:user:`szhan`, :pr:`2612`, :issue:`2271`)
- Add the `TSK_SIMPLIFY_NO_FILTER_NODES` option to simplify to allow unreferenced
nodes be kept in the output (:user:`jeromekelleher`, :user:`hyanwong`,
:issue:`2606`, :pr:`2619`).
- Add the `TSK_SIMPLIFY_NO_UPDATE_SAMPLE_FLAGS` option to simplify which ensures
no node sample flags are changed to allow calling code to manage sample status.
(:user:`jeromekelleher`, :issue:`2662`, :pr:`2663`).
- Guarantee that unfiltered tables are not written to unnecessarily
during simplify (:user:`jeromekelleher`, :pr:`2619`).
- Add `x_table_keep_rows` methods to provide efficient in-place table subsetting
(:user:`jeromekelleher`, :pr:`2700`).
- Add `tsk_tree_seek_index` function
--------------------
[1.1.1] - 2022-07-29
--------------------
**Bug fixes**
- Fix segfault in tsk_variant_restricted_copy in tree sequences with large
numbers of alleles or very long alleles
(:user:`jeromekelleher`, :pr:`2437`, :issue:`2429`).
--------------------
[1.1.0] - 2022-07-14
--------------------
**Features**
- Add ``num_children`` to ``tsk_tree_t`` an array which contains counts of the number of child
nodes of each node in the tree. (:user:`GertjanBisschop`, :issue:`2274`, :pr:`2316`)
- Add ``edge`` to ``tsk_tree_t`` an array which contains the ``edge_id`` of the edge encoding
the relationship between the child node and its parent for each (child) node in the tree.
(:user:`GertjanBisschop`, :issue:`2304`, :pr:`2340`)
**Changes**
- Reduce the maximum number of rows in a table by 1. This removes edge cases so that a ``tsk_id_t`` can be
used to count the number of rows. (:user:`benjeffery`, :issue:`2336`, :pr:`2337`)
- Samples are now copied by ``tsk_variant_restricted_copy``. (:user:`benjeffery`, :issue:`2400`, :pr:`2401`)
--------------------
[1.0.0] - 2022-05-24
--------------------
This major release marks the point at which the documented API becomes stable and supported.
**Breaking changes**
- Change the type of genotypes to ``int32_t``, removing the TSK_16_BIT_GENOTYPES flag option.
(:user:`benjeffery`, :issue:`463`, :pr:`2108`)
- ``tsk_variant_t`` now includes its ``tsk_site_t`` rather than pointing to it.
(:user:`benjeffery`, :issue:`2161`, :pr:`2162`)
- Rename ``TSK_TAKE_TABLES`` to ``TSK_TAKE_OWNERSHIP``.
(:user:`benjeffery`, :issue:`2221`, :pr:`2222`)
- ``TSK_DEBUG``, ``TSK_NO_INIT``, ``TSK_NO_CHECK_INTEGRITY`` and ``TSK_TAKE_OWNERSHIP`` have moved to ``core.h``
(:user:`benjeffery`, :issue:`2218`, :pr:`2230`))
- Rename several flags:
- All flags to ``simplify`` for example ``TSK_KEEP_INPUT_ROOTS`` becomes ``TSK_SIMPLIFY_KEEP_INPUT_ROOTS``.
- All flags to ``subset`` for example ``TSK_KEEP_UNREFERENCED`` becomes ``TSK_SUBSET_KEEP_UNREFERENCED``.
- ``TSK_BUILD_INDEXES`` -> ``TSK_TS_INIT_BUILD_INDEXES``
- ``TSK_NO_METADATA`` -> ``TSK_TABLE_NO_METADATA``
- ``TSK_NO_EDGE_METADATA`` -> ``TSK_TC_NO_EDGE_METADATA``
(:user:`benjeffery`, :issue:`1720`, :pr:`2226`, :pr:`2229`, :pr:`2224`)
- Remove the generic ``TSK_ERR_OUT_OF_BOUNDS`` - replacing with specific errors.
Remove ``TSK_ERR_NON_SINGLE_CHAR_MUTATION`` which was unused.
(:user:`benjeffery`, :pr:`2260`)
- Reorder stats API methods to place ``result`` as the last argument. (:user:`benjeffery`, :pr:`2292`, :issue:`2285`)
**Features**
- Make dumping of tables and tree sequences to disk a zero-copy operation.
(:user:`benjeffery`, :issue:`2111`, :pr:`2124`)
- Add ``edge`` attribute to ``mutation_t`` struct and make available in tree sequence.
(:user:`jeromekelleher`, :issue:`685`, :pr:`2279`)
- Reduce peak memory usage in ``tsk_treeseq_simplify``.
(:user:`jeromekelleher`, :issue:`2287`, :pr:`2288`)
----------------------
[0.99.15] - 2021-12-07
----------------------
**Breaking changes**
- The ``tables`` argument to ``tsk_treeseq_init`` is no longer ``const``, to allow for future no-copy tree sequence creation.
(:user:`benjeffery`, :issue:`1718`, :pr:`1719`)
- Additional consistency checks for mutation tables are now run by ``tsk_table_collection_check_integrity``
even when ``TSK_CHECK_MUTATION_ORDERING`` is not passed in. (:user:`petrelharp`, :issue:`1713`, :pr:`1722`)
- ``num_tracked_samples`` and ``num_samples`` in ``tsk_tree_t`` are now typed as ``tsk_size_t``
(:user:`benjeffery`, :issue:`1723`, :pr:`1727`)
- The previously deprecated option ``TSK_SAMPLE_COUNTS`` has been removed. (:user:`benjeffery`, :issue:`1744`, :pr:`1761`).
- Individuals are no longer guaranteed or required to be topologically sorted in a tree sequence.
``tsk_table_collection_sort`` no longer sorts individuals.
(:user:`benjeffery`, :issue:`1774`, :pr:`1789`)
- The ``tsk_tree_t.left_root`` member has been removed. Client code can be updated
most easily by using the equivalent ``tsk_tree_get_left_root`` function. However,
it may be worth considering updating code to use either the standard traversal
functions (which automatically iterate over roots) or to use the ``virtual_root``
member (which may lead to more concise code). (:user:`jeromekelleher`, :issue:`1796`,
:pr:`1862`)
- Rename ``tsk_tree_t.left`` and ``tsk_tree_t.right`` members to
``tsk_tree_t.interval.left`` and ``tsk_tree_t.interval.right`` respectively.
(:user:`jeromekelleher`, :issue:`1686`, :pr:`1913`)
- ``kastore`` is now vendored into this repo instead of being a git submodule. Developers need to run
``git submodule update``. (:user:`jeromekelleher`, :issue:`1687`, :pr:`1973`)
- ``Tree`` arrays such as ``left_sib``, ``right_child`` etc. now have an additional
"virtual root" node at the end. (:user:`jeromekelleher`, :issue:`1691`, :pr:`1704`)
- ``marked`` and ``mark`` have been removed from ``tsk_tree_t``. (:user:`jeromekelleher`, :pr:`1936`)
**Features**
- Add ``tsk_table_collection_individual_topological_sort`` to sort the individuals as this is no longer done by the
default sort. (:user:`benjeffery`, :issue:`1774`, :pr:`1789`)
- The default behaviour for table size growth is now to double the current size of the table,
up to a threshold. To keep the previous behaviour, use (e.g.)
``tsk_edge_table_set_max_rows_increment(tables->edges, 1024)``, which results in adding
space for 1024 additional rows each time we run out of space in the edge table.
(:user:`benjeffery`, :issue:`5`, :pr:`1683`)
- ``tsk_table_collection_check_integrity`` now has a ``TSK_CHECK_MIGRATION_ORDERING`` flag. (:user:`petrelharp`, :pr:`1722`)
- The default behaviour for ragged column growth is now to double the current size of the column,
up to a threshold. To keep the previous behaviour, use (e.g.)
``tsk_node_table_set_max_metadata_length_increment(tables->nodes, 1024)``, which results in adding
space for 1024 additional entries each time we run out of space in the ragged column.
(:user:`benjeffery`, :issue:`1703`, :pr:`1709`)
- Support for compiling the C library on Windows using msys2 (:user:`jeromekelleher`,
:pr:`1742`).
- Add ``time_units`` to ``tsk_table_collection_t`` to describe the units of the time dimension of the
tree sequence. This is then used to geerate an error if ``time_units`` is ``uncalibrated`` when
using the branch lengths in statistics. (:user:`benjeffery`, :issue:`1644`, :pr:`1760`)
- Add the ``TSK_LOAD_SKIP_TABLES`` option to load just the top-level information from a
file. Also add the ``TSK_CMP_IGNORE_TABLES`` option to compare only the top-level
information in two table collections. (:user:`clwgg`, :pr:`1882`, :issue:`1854`).
- Add reference sequence.
(:user:`jeromekelleher`, :user:`benjeffery`, :issue:`146`, :pr:`1911`, :pr:`1944`, :pr:`1911`)
- Add the ``TSK_LOAD_SKIP_REFERENCE_SEQUENCE`` option to load a table collection
without the reference sequence. Also add the TSK_CMP_IGNORE_REFERENCE_SEQUENCE
option to compare two table collections without comparing their reference
sequence. (:user:`clwgg`, :pr:`2019`, :issue:`1971`).
- Add a "virtual root" to ``Tree`` arrays such as ``left_sib``, ``right_child`` etc.
The virtual root is appended to each array, has all real roots as its children,
but is not the parent of any node. Simplifies traversal algorithms.
(:user:`jeromekelleher`, :issue:`1691`, :pr:`1704`)
- Add ``num_edges`` to ``tsk_tree_t`` to count the edges that define the topology of
the tree. (:user:`jeromekelleher`, :pr:`1704`)
- Add the ``tsk_tree_get_size_bound`` function which returns an upper bound on the number of nodes reachable from
the roots of a tree. Useful for tree stack allocations (:user:`jeromekelleher`, :pr:`1704`).
- Add ``MetadataSchema.permissive_json`` for an easy way to get the simplest schema.
----------------------
[0.99.14] - 2021-09-03
----------------------
**Breaking changes**
- 64 bits are now used to store the sizes of ragged table columns such as metadata,
allowing them to hold more data. As such ``tsk_size_t`` is now 64 bits wide.
This change is fully backwards and forwards compatible for all tree-sequences whose
ragged column sizes fit into 32 bits. New tree-sequences with
large offset arrays that require 64 bits will fail to load in previous versions with
error ``TSK_ERR_BAD_COLUMN_TYPE``.
(:user:`jeromekelleher`, :issue:`343`, :issue:`1527`, :issue:`1528`, :issue:`1530`,
:issue:`1554`, :issue:`1573`, :issue:`1589`,:issue:`1598`,:issue:`1628`, :pr:`1571`,
:pr:`1579`, :pr:`1585`, :pr:`1590`, :pr:`1602`, :pr:`1618`, :pr:`1620`, :pr:`1652`).
**Features**
- Add `tsk_X_table_update_row` methods which allow modifying single rows of tables
(:user:`jeromekelleher`, :issue:`1545`, :pr:`1552`).
----------------------
[0.99.13] - 2021-07-08
----------------------
**Fixes**
- Fix segfault when very large columns overflow
(:user:`bhaller`, :user:`benjeffery`, :issue:`1509`, :pr:`1511`).
----------------------
[0.99.12] - 2021-05-14
----------------------
**Breaking changes**
- Removed ``TSK_NO_BUILD_INDEXES``.
Not building indexes is now the default behaviour of `tsk_table_collection_dump` and related functions.
(:user:`molpopgen`, :issue:`1327`, :pr:`1337`).
**Features**
- Add ``tsk_*_table_extend`` methods to append to a table from another
(:user:`benjeffery`, :issue:`1271`, :pr:`1287`).
**Fixes**
----------------------
[0.99.11] - 2021-03-16
----------------------
**Features**
- Add ``parents`` to the individual table to enable recording of pedigrees
(:user:`ivan-krukov`, :user:`benjeffery`, :issue:`852`, :pr:`1125`, :pr:`866`, :pr:`1153`, :pr:`1177`, :pr:`1199`).
- Added a ``tsk_table_collection_canonicalise`` method, that allows checking for equality between
tables that are equivalent up to reordering (:user:`petrelharp`, :user:`mufernando`, :pr:`1108`).
- Removed a previous requirement on ``tsk_table_collection_union``, allowing for unioning of
new information both above and below shared history (:user:`petrelharp`, :user:`mufernando`, :pr:`1108`).
- Support migrations in tsk_table_collection_sort. (:user:`jeromekelleher`,
:issue:`22`, :issue:`117`, :pr:`1131`).
**Breaking changes**
- Method ``tsk_individual_table_add_row`` has an extra arguments ``parents`` and ``parents_length``.
- Add an ``options`` argument to ``tsk_table_collection_subset`` (:user:`petrelharp`, :pr:`1108`),
to allow for retaining the order of populations.
- Mutation error codes have changed
**Changes**
- Allow mutations that have the same derived state as their parent mutation.
(:user:`benjeffery`, :issue:`1180`, :pr:`1233`)
- File minor version change to support individual parents
----------------------
[0.99.10] - 2021-01-25
----------------------
Minor bugfix on internal APIs
---------------------
[0.99.9] - 2021-01-22
---------------------
**Features**
- Add ``TSK_SIMPLIFY_KEEP_UNARY_IN_INDIVIDUALS`` flag to simplify, which allows the user to
keep unary nodes only if they belong to a tabled individual. This is useful for
simplification in forwards simulations (:user:`hyanwong`, :issue:`1113`, :pr:`1119`).
---------------------
[0.99.8] - 2020-11-27
---------------------
**Features**
- Add ``tsk_treeseq_genetic_relatedness`` for calculating genetic relatedness between
pairs of sets of nodes (:user:`brieuclehmann`, :issue:`1021`, :pr:`1023`, :issue:`974`,
:issue:`973`, :pr:`898`).
- Exposed ``tsk_table_collection_set_indexes`` to the API
(:user:`benjeffery`, :issue:`870`, :pr:`921`).
**Breaking changes**
- Added an ``options`` argument to ``tsk_table_collection_equals``
and table equality methods to allow for more flexible equality criteria
(e.g., ignore top-level metadata and schema or provenance tables).
Existing code should add an extra final parameter ``0`` to retain the
current behaviour (:user:`mufernando`, :user:`jeromekelleher`,
:issue:`896`, :pr:`897`, :issue:`913`, :pr:`917`).
- Changed default behaviour of ``tsk_table_collection_clear`` to not clear
provenances and added ``options`` argument to optionally clear provenances
and schemas (:user:`benjeffery`, :issue:`929`, :pr:`1001`).
- Renamed ``ts.trait_regression`` to ``ts.trait_linear_model``.
---------------------
[0.99.7] - 2020-09-29
---------------------
- Added ``TSK_INCLUDE_TERMINAL`` option to ``tsk_diff_iter_init`` to output the last edges
at the end of a tree sequence (:user:`hyanwong`, :issue:`783`, :pr:`787`).
- Added ``tsk_bug_assert`` for assertions that should be compiled into release binaries
(:user:`benjeffery`, :pr:`860`).
---------------------
[0.99.6] - 2020-09-04
---------------------
**Bugfixes**
- :issue:`823` - Fix mutation time error when using
``tsk_table_collection_simplify`` with ``TSK_SIMPLIFY_KEEP_INPUT_ROOTS``
(:user:`petrelharp`, :pr:`823`).
---------------------
[0.99.5] - 2020-08-27
---------------------
**Breaking changes**
- The macro ``TSK_IMPUTE_MISSING_DATA`` is renamed to ``TSK_ISOLATED_NOT_MISSING``
(:user:`benjeffery`, :issue:`716`, :pr:`794`)
**New features**
- Add a ``TSK_SIMPLIFY_KEEP_INPUT_ROOTS`` option to simplify which, if enabled, adds edges
from the MRCAs of samples in the simplified tree sequence back to the roots
in the input tree sequence (:user:`jeromekelleher`, :issue:`775`, :pr:`782`).
**Bugfixes**
- :issue:`777` - Mutations over isolated samples were incorrectly decoded as
missing data. (:user:`jeromekelleher`, :pr:`778`)
- :issue:`776` - Fix a segfault when a partial list of samples
was provided to the ``variants`` iterator. (:user:`jeromekelleher`, :pr:`778`)
---------------------
[0.99.4] - 2020-08-12
---------------------
**Note**
- The ``TSK_VERSION_PATCH`` macro was incorrectly set to ``4`` for 0.99.3, so both
0.99.4 and 0.99.3 have the same value.
**Changes**
- Mutation times can be a mixture of known and unknown as long as for each
individual site they are either all known or all unknown (:user:`benjeffery`, :pr:`761`).
**Bugfixes**
- Fix for including core.h under C++ (:user:`petrelharp`, :pr:`755`).
---------------------
[0.99.3] - 2020-07-27
---------------------
**Breaking changes**
- ``tsk_mutation_table_add_row`` has an extra ``time`` argument. If the time
is unknown ``TSK_UNKNOWN_TIME`` should be passed.
(:user:`benjeffery`, :pr:`672`)
- Change genotypes from unsigned to signed to accommodate missing data
(see :issue:`144` for discussion). This only affects users of the
``tsk_vargen_t`` class. Genotypes are now stored as int8_t and int16_t
types rather than the former unsigned types. The field names in the
genotypes union of the ``tsk_variant_t`` struct returned by ``tsk_vargen_next``
have been renamed to ``i8`` and ``i16`` accordingly; care should be
taken when updating client code to ensure that types are correct. The number
of distinct alleles supported by 8 bit genotypes has therefore dropped
from 255 to 127, with a similar reduction for 16 bit genotypes.
- Change the ``tsk_vargen_init`` method to take an extra parameter ``alleles``.
To keep the current behaviour, set this parameter to NULL.
- Edges can now have metadata. Hence edge methods now take two extra arguments:
metadata and metadata length. The file format has also changed to accommodate this,
but is backwards compatible. Edge metadata can be disabled for a table collection with
the TSK_NO_EDGE_METADATA flag.
(:user:`benjeffery`, :pr:`496`, :pr:`712`)
- Migrations can now have metadata. Hence migration methods now take two extra arguments:
metadata and metadata length. The file format has also changed to accommodate this,
but is backwards compatible.
(:user:`benjeffery`, :pr:`505`)
- The text dump of tables with metadata now includes the metadata schema as a header.
(:user:`benjeffery`, :pr:`493`)
- Bad tree topologies are detected earlier, so that it is no longer possible
to create a tsk_treeseq_t object which contains a parent with contradictory
children on an interval. Previously an error occured when some operation
building the trees was attempted (:user:`jeromekelleher`, :pr:`709`).
**New features**
- New methods to perform set operations on table collections.
``tsk_table_collection_subset`` subsets and reorders table collections by nodes
(:user:`mufernando`, :user:`petrelharp`, :pr:`663`, :pr:`690`).
``tsk_table_collection_union`` forms the node-wise union of two table collections
(:user:`mufernando`, :user:`petrelharp`, :issue:`381`, :pr:`623`).
- Mutations now have an optional double-precision floating-point ``time`` column.
If not specified, this defaults to a particular NaN value (``TSK_UNKNOWN_TIME``)
indicating that the time is unknown. For a tree sequence to be considered valid
it must meet new criteria for mutation times, see :ref:`sec_mutation_requirements`.
Add ``tsk_table_collection_compute_mutation_times`` and new flag to
``tsk_table_collection_check_integrity``:``TSK_CHECK_MUTATION_TIME``. Table sorting
orders mutations by non-increasing time per-site, which is also a requirement for a
valid tree sequence.
(:user:`benjeffery`, :pr:`672`)
- Add ``metadata`` and ``metadata_schema`` fields to table collection, with accessors on
tree sequence. These store arbitrary bytes and are optional in the file format.
(:user: `benjeffery`, :pr:`641`)
- Add the ``TSK_SIMPLIFY_KEEP_UNARY`` option to simplify (:user:`gtsambos`). See :issue:`1`
and :pr:`143`.
- Add a ``set_root_threshold`` option to tsk_tree_t which allows us to set the
number of samples a node must be an ancestor of to be considered a root
(:pr:`462`).
- Change the semantics of tsk_tree_t so that sample counts are always
computed, and add a new ``TSK_NO_SAMPLE_COUNTS`` option to turn this
off (:pr:`462`).
- Tables with metadata now have an optional `metadata_schema` field that can contain
arbitrary bytes. (:user:`benjeffery`, :pr:`493`)
- Tables loaded from a file can now be edited in the same way as any other
table collection (:user:`jeromekelleher`, :issue:`536`, :pr:`530`.
- Support for reading/writing to arbitrary file streams with the loadf/dumpf
variants for tree sequence and table collection load/dump
(:user:`jeromekelleher`, :user:`grahamgower`, :issue:`565`, :pr:`599`).
- Add low-level sorting API and ``TSK_NO_CHECK_INTEGRITY`` flag
(:user:`jeromekelleher`, :pr:`627`, :issue:`626`).
- Add extension of Kendall-Colijn tree distance metric for tree sequences
computed by ``tsk_treeseq_kc_distance``
(:user:`daniel-goldstein`, :pr:`548`)
**Deprecated**
- The ``TSK_SAMPLE_COUNTS`` options is now ignored and will print out a warning
if used (:pr:`462`).
---------------------
[0.99.2] - 2019-03-27
---------------------
Bugfix release. Changes:
- Fix incorrect errors on tbl_collection_dump (#132)
- Catch table overflows (#157)
---------------------
[0.99.1] - 2019-01-24
---------------------
Refinements to the C API as we move towards 1.0.0. Changes:
- Change the ``_tbl_`` abbreviation to ``_table_`` to improve readability.
Hence, we now have, e.g., ``tsk_node_table_t`` etc.
- Change ``tsk_tbl_size_t`` to ``tsk_size_t``.
- Standardise public API to use ``tsk_size_t`` and ``tsk_id_t`` as appropriate.
- Add ``tsk_flags_t`` typedef and consistently use this as the type used to
encode bitwise flags. To avoid confusion, functions now have an ``options``
parameter.
- Rename ``tsk_table_collection_position_t`` to ``tsk_bookmark_t``.
- Rename ``tsk_table_collection_reset_position`` to ``tsk_table_collection_truncate``
and ``tsk_table_collection_record_position`` to ``tsk_table_collection_record_num_rows``.
- Generalise ``tsk_table_collection_sort`` to take a bookmark as start argument.
- Relax restriction that nodes in the ``samples`` argument to simplify must
currently be marked as samples. (https://github.com/tskit-dev/tskit/issues/72)
- Allow ``tsk_table_collection_simplify`` to take a NULL samples argument to
specify "all samples in the current tables".
- Add support for building as a meson subproject.
---------------------
[0.99.0] - 2019-01-14
---------------------
Initial alpha version of the tskit C API tagged. Version 0.99.x
represents the series of releases leading to version 1.0.0 which
will be the first stable release. After 1.0.0, semver rules
regarding API/ABI breakage will apply; however, in the 0.99.x
series arbitrary changes may happen.
--------------------
[0.0.0] - 2019-01-10
--------------------
Initial extraction of tskit code from msprime. Relicense to MIT.
Code copied at hash 29921408661d5fe0b1a82b1ca302a8b87510fd23
================================================
FILE: c/VERSION.txt
================================================
1.3.1
================================================
FILE: c/examples/Makefile
================================================
# Simple Makefile for building examples.
# This will build the examples in the current directory by compiling in the
# full tskit source into each of the examples. This is *not* recommended for
# real projects!
#
# To use, type "make" in the this directory. If you have GSL installed you
# should then get two example programs built.
#
# **Note**: This repo uses git submodules, and these must be checked out
# correctly for this makefile to work, e.g.:
#
# $ git clone git@github.com:tskit-dev/tskit.git --recurse-submodules
#
# See the documentation (https://tskit.dev/tskit/docs/stable/c-api.html)
# for more details on how to use the C API, and the tskit build examples
# repo (https://github.com/tskit-dev/tskit-build-examples) for examples
# of how to set up a production-ready build with tskit.
#
CFLAGS=-I../ -I../subprojects/kastore
TSKIT_SOURCE=../tskit/*.c ../subprojects/kastore/kastore.c
targets = api_structure error_handling \
haploid_wright_fisher streaming \
tree_iteration tree_traversal \
take_ownership \
json_struct_metadata
all: $(targets)
$(targets): %: %.c
${CC} ${CFLAGS} -o $@ $< ${TSKIT_SOURCE} -lm
clean:
rm -f $(targets)
================================================
FILE: c/examples/api_structure.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <tskit/tables.h>
#define check_tsk_error(val) \
if (val < 0) { \
fprintf(stderr, "line %d: %s", __LINE__, tsk_strerror(val)); \
exit(EXIT_FAILURE); \
}
int
main(int argc, char **argv)
{
int j, ret;
tsk_edge_table_t edges;
ret = tsk_edge_table_init(&edges, 0);
check_tsk_error(ret);
for (j = 0; j < 5; j++) {
ret = tsk_edge_table_add_row(&edges, 0, 1, j + 1, j, NULL, 0);
check_tsk_error(ret);
}
tsk_edge_table_print_state(&edges, stdout);
tsk_edge_table_free(&edges);
return EXIT_SUCCESS;
}
================================================
FILE: c/examples/cpp_sorting_example.cpp
================================================
#include <cstddef>
#include <vector>
#include <algorithm>
#include <stdexcept>
#include <sstream>
#include <iostream>
#include <type_traits>
#include <tskit.h>
static void
handle_tskit_return_code(int code)
{
if (code != 0) {
std::ostringstream o;
o << tsk_strerror(code);
throw std::runtime_error(o.str());
}
}
struct edge_plus_time {
double time;
tsk_id_t parent, child;
double left, right;
};
int
sort_edges(tsk_table_sorter_t *sorter, tsk_size_t start)
{
if (sorter->tables->edges.metadata_length != 0) {
throw std::invalid_argument(
"the sorter does not currently handle edge metadata");
}
if (start != 0) {
throw std::invalid_argument("the sorter requires start==0");
}
std::vector<edge_plus_time> temp;
temp.reserve(static_cast<std::size_t>(sorter->tables->edges.num_rows));
auto edges = &sorter->tables->edges;
auto nodes = &sorter->tables->nodes;
for (tsk_size_t i = 0; i < sorter->tables->edges.num_rows; ++i) {
temp.push_back(edge_plus_time{ nodes->time[edges->parent[i]], edges->parent[i],
edges->child[i], edges->left[i], edges->right[i] });
}
std::sort(begin(temp), end(temp),
[](const edge_plus_time &lhs, const edge_plus_time &rhs) {
if (lhs.time == rhs.time) {
if (lhs.parent == rhs.parent) {
if (lhs.child == rhs.child) {
return lhs.left < rhs.left;
}
return lhs.child < rhs.child;
}
return lhs.parent < rhs.parent;
}
return lhs.time < rhs.time;
});
for (std::size_t i = 0; i < temp.size(); ++i) {
edges->left[i] = temp[i].left;
edges->right[i] = temp[i].right;
edges->parent[i] = temp[i].parent;
edges->child[i] = temp[i].child;
}
return 0;
}
int
main(int argc, char **argv)
{
if (argc != 3) {
std::cerr << "Usage: " << argv[0] << " input.trees output.trees\n";
std::exit(0);
}
const char *infile = argv[1];
const char *outfile = argv[2];
tsk_table_collection_t tables;
auto ret = tsk_table_collection_load(&tables, infile, 0);
handle_tskit_return_code(ret);
tsk_table_sorter_t sorter;
ret = tsk_table_sorter_init(&sorter, &tables, 0);
handle_tskit_return_code(ret);
sorter.sort_edges = sort_edges;
try {
ret = tsk_table_sorter_run(&sorter, NULL);
} catch (std::exception &e) {
std::cerr << e.what() << '\n';
std::exit(1);
}
handle_tskit_return_code(ret);
ret = tsk_table_collection_dump(&tables, outfile, 0);
handle_tskit_return_code(ret);
ret = tsk_table_collection_free(&tables);
handle_tskit_return_code(ret);
}
================================================
FILE: c/examples/error_handling.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <tskit.h>
int
main(int argc, char **argv)
{
int ret;
tsk_treeseq_t ts;
if (argc != 2) {
fprintf(stderr, "usage: <tree sequence file>");
exit(EXIT_FAILURE);
}
ret = tsk_treeseq_load(&ts, argv[1], 0);
if (ret < 0) {
/* Error condition. Free and exit */
tsk_treeseq_free(&ts);
fprintf(stderr, "%s", tsk_strerror(ret));
exit(EXIT_FAILURE);
}
printf("Loaded tree sequence with %lld nodes and %lld edges from %s\n",
(long long) tsk_treeseq_get_num_nodes(&ts),
(long long) tsk_treeseq_get_num_edges(&ts), argv[1]);
tsk_treeseq_free(&ts);
return EXIT_SUCCESS;
}
================================================
FILE: c/examples/haploid_wright_fisher.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <err.h>
#include <tskit/tables.h>
#define check_tsk_error(val) \
if (val < 0) { \
errx(EXIT_FAILURE, "line %d: %s", __LINE__, tsk_strerror(val)); \
}
void
simulate(tsk_table_collection_t *tables, int N, int T, int simplify_interval)
{
tsk_id_t *buffer, *parents, *children, child, left_parent, right_parent;
double breakpoint;
int ret, j, t, b;
assert(simplify_interval != 0); // leads to division by zero
buffer = malloc(2 * N * sizeof(tsk_id_t));
if (buffer == NULL) {
errx(EXIT_FAILURE, "Out of memory");
}
tables->sequence_length = 1.0;
parents = buffer;
for (j = 0; j < N; j++) {
parents[j]
= tsk_node_table_add_row(&tables->nodes, 0, T, TSK_NULL, TSK_NULL, NULL, 0);
check_tsk_error(parents[j]);
}
b = 0;
for (t = T - 1; t >= 0; t--) {
/* Alternate between using the first and last N values in the buffer */
parents = buffer + (b * N);
b = (b + 1) % 2;
children = buffer + (b * N);
for (j = 0; j < N; j++) {
child = tsk_node_table_add_row(
&tables->nodes, 0, t, TSK_NULL, TSK_NULL, NULL, 0);
check_tsk_error(child);
/* NOTE: the use of rand() is discouraged for
* research code and proper random number generator
* libraries should be preferred.
*/
left_parent = parents[(size_t) ((rand() / (1. + RAND_MAX)) * N)];
right_parent = parents[(size_t) ((rand() / (1. + RAND_MAX)) * N)];
do {
breakpoint = rand() / (1. + RAND_MAX);
} while (breakpoint == 0); /* tiny proba of breakpoint being 0 */
ret = tsk_edge_table_add_row(
&tables->edges, 0, breakpoint, left_parent, child, NULL, 0);
check_tsk_error(ret);
ret = tsk_edge_table_add_row(
&tables->edges, breakpoint, 1, right_parent, child, NULL, 0);
check_tsk_error(ret);
children[j] = child;
}
if (t % simplify_interval == 0) {
printf("Simplify at generation %lld: (%lld nodes %lld edges)", (long long) t,
(long long) tables->nodes.num_rows, (long long) tables->edges.num_rows);
/* Note: Edges must be sorted for simplify to work, and we use a brute force
* approach of sorting each time here for simplicity. This is inefficient. */
ret = tsk_table_collection_sort(tables, NULL, 0);
check_tsk_error(ret);
ret = tsk_table_collection_simplify(tables, children, N, 0, NULL);
check_tsk_error(ret);
printf(" -> (%lld nodes %lld edges)\n", (long long) tables->nodes.num_rows,
(long long) tables->edges.num_rows);
for (j = 0; j < N; j++) {
children[j] = j;
}
}
}
free(buffer);
}
int
main(int argc, char **argv)
{
int ret;
tsk_table_collection_t tables;
if (argc != 6) {
errx(EXIT_FAILURE, "usage: N T simplify-interval output-file seed");
}
ret = tsk_table_collection_init(&tables, 0);
check_tsk_error(ret);
srand((unsigned) atoi(argv[5]));
simulate(&tables, atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
/* Sort and index so that the result can be opened as a tree sequence */
ret = tsk_table_collection_sort(&tables, NULL, 0);
check_tsk_error(ret);
ret = tsk_table_collection_build_index(&tables, 0);
check_tsk_error(ret);
ret = tsk_table_collection_dump(&tables, argv[4], 0);
check_tsk_error(ret);
tsk_table_collection_free(&tables);
return 0;
}
================================================
FILE: c/examples/json_struct_metadata.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <err.h>
#include <string.h>
#include <tskit.h>
// these are properties of the ``json+struct`` codec, documented in tskit
#define JSON_STRUCT_HEADER_SIZE 21
const uint8_t json_struct_codec_magic[4] = { 'J', 'B', 'L', 'B' };
const uint8_t json_struct_codec_version = 1;
// little-endian read of a uint64_t from an address
static uint64_t
load_u64_le(const uint8_t *p)
{
uint64_t value = (uint64_t) p[0];
value |= (uint64_t) p[1] << 8;
value |= (uint64_t) p[2] << 16;
value |= (uint64_t) p[3] << 24;
value |= (uint64_t) p[4] << 32;
value |= (uint64_t) p[5] << 40;
value |= (uint64_t) p[6] << 48;
value |= (uint64_t) p[7] << 56;
return value;
}
// little-endian write of a uint64_t to an address
static void
set_u64_le(uint8_t *dest, uint64_t value)
{
dest[0] = (uint8_t) (value & 0xFF);
dest[1] = (uint8_t) ((value >> 8) & 0xFF);
dest[2] = (uint8_t) ((value >> 16) & 0xFF);
dest[3] = (uint8_t) ((value >> 24) & 0xFF);
dest[4] = (uint8_t) ((value >> 32) & 0xFF);
dest[5] = (uint8_t) ((value >> 40) & 0xFF);
dest[6] = (uint8_t) ((value >> 48) & 0xFF);
dest[7] = (uint8_t) ((value >> 56) & 0xFF);
}
// Extract the json and binary payloads from the `json+struct` codec data buffer.
// Note that the output pointers `json` and `binary` reference memory
// inside the `metadata` buffer passed in.
void
json_struct_codec_get_components(uint8_t *metadata, tsk_size_t metadata_length,
uint8_t **json, tsk_size_t *json_length, uint8_t **binary, tsk_size_t *binary_length)
{
// check the structure of the codec header and the sizes it specifies
if (metadata == NULL || json == NULL || json_length == NULL || binary == NULL
|| binary_length == NULL)
errx(EXIT_FAILURE, "bad parameter value.");
if (metadata_length < JSON_STRUCT_HEADER_SIZE)
errx(EXIT_FAILURE, "metadata truncated.");
if (memcmp(metadata, json_struct_codec_magic, sizeof(json_struct_codec_magic)) != 0)
errx(EXIT_FAILURE, "bad magic bytes.");
uint8_t version = metadata[4];
if (version != json_struct_codec_version)
errx(EXIT_FAILURE, "bad version number.");
uint64_t json_length_u64 = load_u64_le(metadata + 5);
uint64_t binary_length_u64 = load_u64_le(metadata + 13);
if (json_length_u64 > UINT64_MAX - (uint64_t) JSON_STRUCT_HEADER_SIZE)
errx(EXIT_FAILURE, "invalid length.");
// determine the number of padding bytes and do more safety checks
uint64_t length = (uint64_t) JSON_STRUCT_HEADER_SIZE + json_length_u64;
uint64_t padding_length = (8 - (length & 0x07)) % 8;
if (padding_length > UINT64_MAX - length)
errx(EXIT_FAILURE, "invalid length.");
length += padding_length;
if (binary_length_u64 > UINT64_MAX - length)
errx(EXIT_FAILURE, "invalid length.");
length += binary_length_u64;
if ((uint64_t) metadata_length != length)
errx(EXIT_FAILURE, "unexpected size.");
uint8_t *padding_start = metadata + JSON_STRUCT_HEADER_SIZE + json_length_u64;
for (uint64_t j = 0; j < padding_length; ++j)
if (*(padding_start + j) != 0)
errx(EXIT_FAILURE, "padding bytes are nonzero.");
// the structure of the codec data seems valid; return components
*json = metadata + JSON_STRUCT_HEADER_SIZE;
*json_length = (tsk_size_t) json_length_u64;
*binary = metadata + JSON_STRUCT_HEADER_SIZE + json_length_u64 + padding_length;
*binary_length = (tsk_size_t) binary_length_u64;
}
// malloc and return a data buffer for the `json+struct` codec
// that contains the given components
void
json_struct_codec_create_buffer(const uint8_t *json, tsk_size_t json_length,
const uint8_t *binary, tsk_size_t binary_length, uint8_t **buffer,
tsk_size_t *buffer_length)
{
// figure out the total length of the codec's data and allocate the buffer for it
tsk_size_t header_length = JSON_STRUCT_HEADER_SIZE;
tsk_size_t padding_length = (8 - ((header_length + json_length) & 0x07)) % 8;
tsk_size_t total_length
= header_length + json_length + padding_length + binary_length;
uint8_t *bytes = malloc(total_length);
if (!bytes)
errx(EXIT_FAILURE, "memory for buffer could not be allocated.");
// then set up the bytes for the codec header
memcpy(bytes, json_struct_codec_magic, 4);
bytes[4] = json_struct_codec_version;
set_u64_le(bytes + 5, (uint64_t) json_length);
set_u64_le(bytes + 13, (uint64_t) binary_length);
// copy in the JSON and binary data, separated by the padding bytes; the goal of the
// padding bytes is to ensure that the binary data is 8-byte-aligned relative to the
// start of the buffer
memcpy(bytes + header_length, json, json_length);
memset(bytes + header_length + json_length, 0, padding_length);
memcpy(bytes + header_length + json_length + padding_length, binary, binary_length);
// return the buffer and its length; the caller takes ownership of the buffer
*buffer = bytes;
*buffer_length = total_length;
}
int
main(int argc, char **argv)
{
// we start with JSON and binary payloads that we encode into a new buffer
// note that the JSON payload does not have to end with a trailing NULL
const char json_payload[] = { '{', '"', 'a', '"', ':', '1', '}' };
const uint8_t binary_payload[] = { 0x01, 0x02, 0x03, 0x04 };
uint8_t *metadata;
tsk_size_t metadata_length;
json_struct_codec_create_buffer((const uint8_t *) json_payload, sizeof(json_payload),
binary_payload, sizeof(binary_payload), &metadata, &metadata_length);
// then we decode that buffer to recover the json and binary data
uint8_t *decoded_json, *decoded_binary;
tsk_size_t decoded_json_length, decoded_binary_length;
json_struct_codec_get_components(metadata, metadata_length, &decoded_json,
&decoded_json_length, &decoded_binary, &decoded_binary_length);
// print the recovered data to demonstrate that the round-trip worked
// note that the JSON data is not NULL-terminated unless you put a NULL there!
printf("JSON: %.*s\n", (int) decoded_json_length, decoded_json);
printf("Binary data:");
for (tsk_size_t j = 0; j < decoded_binary_length; j++)
printf(" %#04x", decoded_binary[j]);
printf("\n");
free(metadata);
return EXIT_SUCCESS;
}
================================================
FILE: c/examples/multichrom_wright_fisher.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <err.h>
#include <string.h>
#include <pthread.h>
#include <tskit/tables.h>
#define check_tsk_error(val) \
if (val < 0) { \
errx(EXIT_FAILURE, "line %d: %s\n", __LINE__, tsk_strerror(val)); \
}
static void
init_tables(tsk_table_collection_t *tcs, int num_chroms)
{
int j, ret;
for (j = 0; j < num_chroms; j++) {
ret = tsk_table_collection_init(&tcs[j], 0);
check_tsk_error(ret);
if (j > 0) {
tsk_node_table_free(&tcs[j].nodes);
}
}
}
static void
free_tables(tsk_table_collection_t *tcs, int num_chroms)
{
int j;
for (j = 0; j < num_chroms; j++) {
if (j > 0) {
/* Must not double free node table columns. */
memset(&tcs[j].nodes, 0, sizeof(tcs[j].nodes));
}
tsk_table_collection_free(&tcs[j]);
}
}
static void
join_tables(tsk_table_collection_t *tcs, int num_chroms)
{
int j, ret;
for (j = 1; j < num_chroms; j++) {
ret = tsk_edge_table_extend(
&tcs[0].edges, &tcs[j].edges, tcs[j].edges.num_rows, NULL, 0);
check_tsk_error(ret);
}
/* Get all the squashable edges next to each other */
ret = tsk_table_collection_sort(&tcs[0], NULL, 0);
check_tsk_error(ret);
ret = tsk_edge_table_squash(&tcs[0].edges);
check_tsk_error(ret);
/* We need to sort again after squash */
ret = tsk_table_collection_sort(&tcs[0], NULL, 0);
check_tsk_error(ret);
ret = tsk_table_collection_build_index(&tcs[0], 0);
check_tsk_error(ret);
}
struct chunk_work {
int chunk;
tsk_table_collection_t *tc;
int *samples;
int N;
};
void *
simplify_chunk(void *arg)
{
int ret;
struct chunk_work *work = (struct chunk_work *) arg;
tsk_size_t edges_before = work->tc->edges.num_rows;
ret = tsk_table_collection_sort(work->tc, NULL, 0);
check_tsk_error(ret);
ret = tsk_table_collection_simplify(work->tc, work->samples, work->N,
TSK_SIMPLIFY_NO_FILTER_NODES | TSK_SIMPLIFY_NO_UPDATE_SAMPLE_FLAGS, NULL);
check_tsk_error(ret);
/* NOTE: this printf makes helgrind complain */
printf("\tchunk %d: %lld -> %lld\n", work->chunk, (long long) edges_before,
(long long) work->tc->edges.num_rows);
return NULL;
}
void
sort_and_simplify_all(tsk_table_collection_t *tcs, int num_chroms, int *samples, int N)
{
int j, ret;
struct chunk_work work[num_chroms];
pthread_t threads[num_chroms];
for (j = 1; j < num_chroms; j++) {
tcs[j].nodes = tcs[0].nodes;
}
for (j = 0; j < num_chroms; j++) {
work[j].chunk = j;
work[j].tc = &tcs[j];
work[j].samples = samples;
work[j].N = N;
ret = pthread_create(&threads[j], NULL, simplify_chunk, (void *) &work[j]);
if (ret != 0) {
errx(EXIT_FAILURE, "Pthread create failed");
}
/* simplify_chunk((void *) &work[j]); */
}
for (j = 0; j < num_chroms; j++) {
ret = pthread_join(threads[j], NULL);
if (ret != 0) {
errx(EXIT_FAILURE, "Pthread join failed");
}
}
}
void
simplify_tables(tsk_table_collection_t *tcs, int num_chroms, int *samples, int N)
{
int j, k, num_edges, ret;
const tsk_size_t num_nodes = tcs[0].nodes.num_rows;
tsk_bool_t *keep_nodes = malloc(num_nodes * sizeof(*keep_nodes));
tsk_id_t *node_id_map = malloc(num_nodes * sizeof(*node_id_map));
tsk_id_t *edge_child, *edge_parent;
if (keep_nodes == NULL || node_id_map == NULL) {
errx(EXIT_FAILURE, "Out of memory");
}
printf("Simplify %lld nodes\n", (long long) tcs[0].nodes.num_rows);
sort_and_simplify_all(tcs, num_chroms, samples, N);
for (j = 0; j < num_nodes; j++) {
keep_nodes[j] = false;
tcs[0].nodes.flags[j] &= (~TSK_NODE_IS_SAMPLE);
}
for (j = 0; j < N; j++) {
keep_nodes[samples[j]] = true;
tcs[0].nodes.flags[samples[j]] |= TSK_NODE_IS_SAMPLE;
}
for (j = 0; j < num_chroms; j++) {
edge_child = tcs[j].edges.child;
edge_parent = tcs[j].edges.parent;
num_edges = tcs[j].edges.num_rows;
for (k = 0; k < num_edges; k++) {
keep_nodes[edge_child[k]] = true;
keep_nodes[edge_parent[k]] = true;
}
}
tsk_node_table_keep_rows(&tcs[0].nodes, keep_nodes, 0, node_id_map);
printf("\tdone: %lld nodes\n", (long long) tcs[0].nodes.num_rows);
/* Remap node references */
for (j = 0; j < num_chroms; j++) {
edge_child = tcs[j].edges.child;
edge_parent = tcs[j].edges.parent;
num_edges = tcs[j].edges.num_rows;
for (k = 0; k < num_edges; k++) {
edge_child[k] = node_id_map[edge_child[k]];
edge_parent[k] = node_id_map[edge_parent[k]];
}
ret = tsk_table_collection_check_integrity(&tcs[j], 0);
check_tsk_error(ret);
}
for (j = 0; j < N; j++) {
samples[j] = node_id_map[samples[j]];
}
free(keep_nodes);
free(node_id_map);
}
void
simulate(
tsk_table_collection_t *tcs, int num_chroms, int N, int T, int simplify_interval)
{
tsk_id_t *buffer, *parents, *children, child, left_parent, right_parent;
bool left_is_first;
double chunk_left, chunk_right;
int ret, j, t, b, k;
assert(simplify_interval != 0); // leads to division by zero
buffer = malloc(2 * N * sizeof(tsk_id_t));
if (buffer == NULL) {
errx(EXIT_FAILURE, "Out of memory");
}
for (k = 0; k < num_chroms; k++) {
tcs[k].sequence_length = num_chroms;
}
parents = buffer;
for (j = 0; j < N; j++) {
parents[j]
= tsk_node_table_add_row(&tcs[0].nodes, 0, T, TSK_NULL, TSK_NULL, NULL, 0);
check_tsk_error(parents[j]);
}
b = 0;
for (t = T - 1; t >= 0; t--) {
/* Alternate between using the first and last N values in the buffer */
parents = buffer + (b * N);
b = (b + 1) % 2;
children = buffer + (b * N);
for (j = 0; j < N; j++) {
child = tsk_node_table_add_row(
&tcs[0].nodes, 0, t, TSK_NULL, TSK_NULL, NULL, 0);
check_tsk_error(child);
/* NOTE: the use of rand() is discouraged for
* research code and proper random number generator
* libraries should be preferred.
*/
left_parent = parents[(size_t) ((rand() / (1. + RAND_MAX)) * N)];
right_parent = parents[(size_t) ((rand() / (1. + RAND_MAX)) * N)];
left_is_first = rand() < 0.5;
chunk_left = 0.0;
for (k = 0; k < num_chroms; k++) {
chunk_right = chunk_left + rand() / (1. + RAND_MAX);
/* a very tiny chance that right and left are equal */
if (chunk_right > chunk_left) {
ret = tsk_edge_table_add_row(&tcs[k].edges, chunk_left, chunk_right,
left_is_first ? left_parent : right_parent, child, NULL, 0);
check_tsk_error(ret);
}
chunk_left += 1.0;
if (chunk_right < chunk_left) {
ret = tsk_edge_table_add_row(&tcs[k].edges, chunk_right, chunk_left,
left_is_first ? right_parent : left_parent, child, NULL, 0);
check_tsk_error(ret);
}
}
children[j] = child;
}
if (t % simplify_interval == 0) {
simplify_tables(tcs, num_chroms, children, N);
}
}
/* Set the sample flags for final generation */
for (j = 0; j < N; j++) {
tcs[0].nodes.flags[children[j]] = TSK_NODE_IS_SAMPLE;
}
free(buffer);
}
int
main(int argc, char **argv)
{
int ret;
int num_chroms;
if (argc != 7) {
errx(EXIT_FAILURE, "usage: N T simplify-interval output seed num-chroms");
}
num_chroms = atoi(argv[6]);
tsk_table_collection_t tcs[num_chroms];
srand((unsigned) atoi(argv[5]));
init_tables(tcs, num_chroms);
simulate(tcs, num_chroms, atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
join_tables(tcs, num_chroms);
ret = tsk_table_collection_dump(&tcs[0], argv[4], 0);
check_tsk_error(ret);
free_tables(tcs, num_chroms);
return 0;
}
================================================
FILE: c/examples/multichrom_wright_fisher_singlethreaded.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <err.h>
#include <string.h>
#include <tskit/tables.h>
#define check_tsk_error(val) \
if (val < 0) { \
errx(EXIT_FAILURE, "line %d: %s\n", __LINE__, tsk_strerror(val)); \
}
void
simulate(
tsk_table_collection_t *tables, int num_chroms, int N, int T, int simplify_interval)
{
tsk_id_t *buffer, *parents, *children, child, left_parent, right_parent;
bool left_is_first;
double chunk_left, chunk_right;
int ret, j, t, b, k;
assert(simplify_interval != 0); // leads to division by zero
buffer = malloc(2 * N * sizeof(tsk_id_t));
if (buffer == NULL) {
errx(EXIT_FAILURE, "Out of memory");
}
tables->sequence_length = num_chroms;
parents = buffer;
for (j = 0; j < N; j++) {
parents[j]
= tsk_node_table_add_row(&tables->nodes, 0, T, TSK_NULL, TSK_NULL, NULL, 0);
check_tsk_error(parents[j]);
}
b = 0;
for (t = T - 1; t >= 0; t--) {
/* Alternate between using the first and last N values in the buffer */
parents = buffer + (b * N);
b = (b + 1) % 2;
children = buffer + (b * N);
for (j = 0; j < N; j++) {
child = tsk_node_table_add_row(
&tables->nodes, 0, t, TSK_NULL, TSK_NULL, NULL, 0);
check_tsk_error(child);
/* NOTE: the use of rand() is discouraged for
* research code and proper random number generator
* libraries should be preferred.
*/
left_parent = parents[(size_t) ((rand() / (1. + RAND_MAX)) * N)];
right_parent = parents[(size_t) ((rand() / (1. + RAND_MAX)) * N)];
left_is_first = rand() < 0.5;
chunk_left = 0.0;
for (k = 0; k < num_chroms; k++) {
chunk_right = chunk_left + rand() / (1. + RAND_MAX);
/* a very tiny chance that right and left are equal */
if (chunk_right > chunk_left) {
ret = tsk_edge_table_add_row(&tables->edges, chunk_left, chunk_right,
left_is_first ? left_parent : right_parent, child, NULL, 0);
check_tsk_error(ret);
}
chunk_left += 1.0;
if (chunk_right < chunk_left) {
ret = tsk_edge_table_add_row(&tables->edges, chunk_right, chunk_left,
left_is_first ? right_parent : left_parent, child, NULL, 0);
check_tsk_error(ret);
}
}
children[j] = child;
}
if (t % simplify_interval == 0) {
printf("Simplify at generation %lld: (%lld nodes %lld edges)", (long long) t,
(long long) tables->nodes.num_rows, (long long) tables->edges.num_rows);
/* Note: Edges must be sorted for simplify to work, and we use a brute force
* approach of sorting each time here for simplicity. This is inefficient. */
ret = tsk_table_collection_sort(tables, NULL, 0);
check_tsk_error(ret);
ret = tsk_table_collection_simplify(tables, children, N, 0, NULL);
check_tsk_error(ret);
printf(" -> (%lld nodes %lld edges)\n", (long long) tables->nodes.num_rows,
(long long) tables->edges.num_rows);
for (j = 0; j < N; j++) {
children[j] = j;
}
}
}
/* Set the sample flags for final generation */
for (j = 0; j < N; j++) {
tables->nodes.flags[children[j]] = TSK_NODE_IS_SAMPLE;
}
free(buffer);
}
int
main(int argc, char **argv)
{
int ret;
tsk_table_collection_t tables;
if (argc != 7) {
errx(EXIT_FAILURE, "usage: N T simplify-interval output seed num-chroms");
}
ret = tsk_table_collection_init(&tables, 0);
check_tsk_error(ret);
srand((unsigned) atoi(argv[5]));
simulate(&tables, atoi(argv[6]), atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
/* Sort and index so that the result can be opened as a tree sequence */
ret = tsk_table_collection_sort(&tables, NULL, 0);
check_tsk_error(ret);
ret = tsk_table_collection_build_index(&tables, 0);
check_tsk_error(ret);
ret = tsk_table_collection_dump(&tables, argv[4], 0);
check_tsk_error(ret);
tsk_table_collection_free(&tables);
return 0;
}
================================================
FILE: c/examples/streaming.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <tskit/tables.h>
#define check_tsk_error(val) \
if (val < 0) { \
fprintf(stderr, "Error: line %d: %s\n", __LINE__, tsk_strerror(val)); \
exit(EXIT_FAILURE); \
}
int
main(int argc, char **argv)
{
int ret;
int j = 0;
tsk_table_collection_t tables;
ret = tsk_table_collection_init(&tables, 0);
check_tsk_error(ret);
while (true) {
ret = tsk_table_collection_loadf(&tables, stdin, TSK_NO_INIT);
if (ret == TSK_ERR_EOF) {
break;
}
check_tsk_error(ret);
fprintf(stderr, "Tree sequence %d had %lld mutations\n", j,
(long long) tables.mutations.num_rows);
ret = tsk_mutation_table_truncate(&tables.mutations, 0);
check_tsk_error(ret);
ret = tsk_table_collection_dumpf(&tables, stdout, 0);
check_tsk_error(ret);
j++;
}
tsk_table_collection_free(&tables);
return EXIT_SUCCESS;
}
================================================
FILE: c/examples/take_ownership.c
================================================
#include <err.h>
#include <stdlib.h>
#include <tskit/tables.h>
#include <tskit/trees.h>
#define check_tsk_error(val) \
if (val < 0) { \
errx(EXIT_FAILURE, "line %d: %s", __LINE__, tsk_strerror(val)); \
}
int
main(int argc, char **argv)
{
tsk_table_collection_t *tables;
tsk_treeseq_t treeseq;
int rv;
tables = malloc(sizeof(*tables));
rv = tsk_table_collection_init(tables, 0);
check_tsk_error(rv);
/* NOTE: you must set sequence length AFTER initialization */
tables->sequence_length = 1.0;
/* Do your regular table operations */
rv = tsk_node_table_add_row(&tables->nodes, 0, 0.0, -1, -1, NULL, 0);
check_tsk_error(rv);
/* Initalize the tree sequence, transferring all responsibility
* for the table collection's memory managment
*/
rv = tsk_treeseq_init(
&treeseq, tables, TSK_TS_INIT_BUILD_INDEXES | TSK_TAKE_OWNERSHIP);
check_tsk_error(rv);
/* WARNING: calling tsk_table_collection_free is now a memory error! */
tsk_treeseq_free(&treeseq);
}
================================================
FILE: c/examples/tree_iteration.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <err.h>
#include <tskit.h>
#define check_tsk_error(val) \
if (val < 0) { \
errx(EXIT_FAILURE, "line %d: %s", __LINE__, tsk_strerror(val)); \
}
int
main(int argc, char **argv)
{
int ret;
tsk_treeseq_t ts;
tsk_tree_t tree;
if (argc != 2) {
errx(EXIT_FAILURE, "usage: <tree sequence file>");
}
ret = tsk_treeseq_load(&ts, argv[1], 0);
check_tsk_error(ret);
ret = tsk_tree_init(&tree, &ts, 0);
check_tsk_error(ret);
printf("Iterate forwards\n");
for (ret = tsk_tree_first(&tree); ret == TSK_TREE_OK; ret = tsk_tree_next(&tree)) {
printf("\ttree %lld has %lld roots\n", (long long) tree.index,
(long long) tsk_tree_get_num_roots(&tree));
}
check_tsk_error(ret);
printf("Iterate backwards\n");
for (ret = tsk_tree_last(&tree); ret == TSK_TREE_OK; ret = tsk_tree_prev(&tree)) {
printf("\ttree %lld has %lld roots\n", (long long) tree.index,
(long long) tsk_tree_get_num_roots(&tree));
}
check_tsk_error(ret);
tsk_tree_free(&tree);
tsk_treeseq_free(&ts);
return 0;
}
================================================
FILE: c/examples/tree_traversal.c
================================================
#include <stdio.h>
#include <stdlib.h>
#include <err.h>
#include <tskit.h>
#define check_tsk_error(val) \
if (val < 0) { \
errx(EXIT_FAILURE, "line %d: %s", __LINE__, tsk_strerror(val)); \
}
static void
traverse_standard(const tsk_tree_t *tree)
{
int ret;
tsk_size_t num_nodes, j;
tsk_id_t *nodes = malloc(tsk_tree_get_size_bound(tree) * sizeof(*nodes));
if (nodes == NULL) {
errx(EXIT_FAILURE, "Out of memory");
}
ret = tsk_tree_preorder(tree, nodes, &num_nodes);
check_tsk_error(ret);
for (j = 0; j < num_nodes; j++) {
printf("Visit preorder %lld\n", (long long) nodes[j]);
}
ret = tsk_tree_postorder(tree, nodes, &num_nodes);
check_tsk_error(ret);
for (j = 0; j < num_nodes; j++) {
printf("Visit postorder %lld\n", (long long) nodes[j]);
}
free(nodes);
}
static void
_traverse(const tsk_tree_t *tree, tsk_id_t u, int depth)
{
tsk_id_t v;
int j;
for (j = 0; j < depth; j++) {
printf(" ");
}
printf("Visit recursive %lld\n", (long long) u);
for (v = tree->left_child[u]; v != TSK_NULL; v = tree->right_sib[v]) {
_traverse(tree, v, depth + 1);
}
}
static void
traverse_recursive(const tsk_tree_t *tree)
{
_traverse(tree, tree->virtual_root, -1);
}
static void
traverse_stack(const tsk_tree_t *tree)
{
int stack_top;
tsk_id_t u, v;
tsk_id_t *stack = malloc(tsk_tree_get_size_bound(tree) * sizeof(*stack));
if (stack == NULL) {
errx(EXIT_FAILURE, "Out of memory");
}
stack_top = 0;
stack[stack_top] = tree->virtual_root;
while (stack_top >= 0) {
u = stack[stack_top];
stack_top--;
printf("Visit stack %lld\n", (long long) u);
/* Put nodes on the stack right-to-left, so we visit in left-to-right */
for (v = tree->right_child[u]; v != TSK_NULL; v = tree->left_sib[v]) {
stack_top++;
stack[stack_top] = v;
}
}
free(stack);
}
static void
traverse_upwards(const tsk_tree_t *tree)
{
const tsk_id_t *samples = tsk_treeseq_get_samples(tree->tree_sequence);
tsk_size_t num_samples = tsk_treeseq_get_num_samples(tree->tree_sequence);
tsk_size_t j;
tsk_id_t u;
for (j = 0; j < num_samples; j++) {
u = samples[j];
while (u != TSK_NULL) {
printf("Visit upwards: %lld\n", (long long) u);
u = tree->parent[u];
}
}
}
int
main(int argc, char **argv)
{
int ret;
tsk_treeseq_t ts;
tsk_tree_t tree;
if (argc != 2) {
errx(EXIT_FAILURE, "usage: <tree sequence file>");
}
ret = tsk_treeseq_load(&ts, argv[1], 0);
check_tsk_error(ret);
ret = tsk_tree_init(&tree, &ts, 0);
check_tsk_error(ret);
ret = tsk_tree_first(&tree);
check_tsk_error(ret);
traverse_standard(&tree);
traverse_recursive(&tree);
traverse_stack(&tree);
traverse_upwards(&tree);
tsk_tree_free(&tree);
tsk_treeseq_free(&ts);
return 0;
}
================================================
FILE: c/meson.build
================================================
project('tskit', ['c', 'cpp'],
version: files('VERSION.txt'),
default_options: ['c_std=c99', 'cpp_std=c++11']
)
debug_c_args = []
if get_option('buildtype').startswith('debug')
debug_c_args = ['-DTSK_TRACE_ERRORS']
endif
kastore_proj = subproject('kastore')
kastore_dep = kastore_proj.get_variable('kastore_dep')
kastore_inc = kastore_proj.get_variable('kastore_inc')
cc = meson.get_compiler('c')
m_dep = cc.find_library('m', required: false)
lib_deps = [m_dep, kastore_dep]
extra_c_args = [
'-Wall', '-Wextra', '-Werror', '-Wpedantic', '-W',
'-Wmissing-prototypes', '-Wstrict-prototypes',
'-Wconversion', '-Wshadow', '-Wpointer-arith', '-Wcast-align',
'-Wcast-qual', '-Wwrite-strings', '-Wnested-externs',
'-fshort-enums', '-fno-common'] + debug_c_args
lib_sources = [
'tskit/core.c', 'tskit/tables.c', 'tskit/trees.c',
'tskit/genotypes.c', 'tskit/stats.c', 'tskit/convert.c', 'tskit/haplotype_matching.c']
lib_headers = [
'tskit/core.h', 'tskit/tables.h', 'tskit/trees.h',
'tskit/genotypes.h', 'tskit/stats.h', 'tskit/convert.h', 'tskit/haplotype_matching.h']
# Subprojects use the static library for simplicity.
tskit_inc = [kastore_inc, include_directories(['.'])]
tskit_lib = static_library('tskit',
sources: lib_sources, dependencies: lib_deps)
tskit_dep = declare_dependency(include_directories:tskit_inc, link_with: tskit_lib)
if not meson.is_subproject()
# Shared library install target.
shared_library('tskit',
sources: lib_sources, dependencies: lib_deps, c_args: extra_c_args, install: true)
install_headers('tskit.h')
install_headers(lib_headers, subdir: 'tskit')
cunit_dep = dependency('cunit')
# We don't specify extra C args here as CUnit won't pass the checks.
test_lib = static_library('testlib',
sources: ['tests/testlib.c'], dependencies: [cunit_dep, kastore_dep, tskit_dep])
test_core = executable('test_core',
sources: ['tests/test_core.c'],
link_with: [tskit_lib, test_lib],
c_args: extra_c_args+['-DMESON_PROJECT_VERSION="@0@"'.format(meson.project_version())],
dependencies: kastore_dep,
)
test('core', test_core)
test_tables = executable('test_tables',
sources: ['tests/test_tables.c'],
link_with: [tskit_lib, test_lib], c_args: extra_c_args, dependencies: kastore_dep)
test('tables', test_tables)
test_trees = executable('test_trees',
sources: ['tests/test_trees.c'],
link_with: [tskit_lib, test_lib], c_args: extra_c_args, dependencies: kastore_dep)
test('trees', test_trees)
test_genotypes = executable('test_genotypes',
sources: ['tests/test_genotypes.c'],
link_with: [tskit_lib, test_lib], c_args: extra_c_args, dependencies: kastore_dep)
test('genotypes', test_genotypes)
test_convert = executable('test_convert',
sources: ['tests/test_convert.c'],
link_with: [tskit_lib, test_lib], c_args: extra_c_args, dependencies: kastore_dep)
test('convert', test_convert)
test_stats = executable('test_stats',
sources: ['tests/test_stats.c'],
link_with: [tskit_lib, test_lib], c_args: extra_c_args, dependencies: kastore_dep)
test('stats', test_stats)
test_haplotype_matching = executable('test_haplotype_matching',
sources: ['tests/test_haplotype_matching.c'],
link_with: [tskit_lib, test_lib], c_args: extra_c_args, dependencies: kastore_dep)
test('haplotype_matching', test_haplotype_matching)
test_file_format = executable('test_file_format',
sources: ['tests/test_file_format.c'],
link_with: [tskit_lib, test_lib], c_args: extra_c_args, dependencies: kastore_dep)
test('file_format', test_file_format)
test_minimal_cpp = executable('test_minimal_cpp',
sources: ['tests/test_minimal_cpp.cpp'], link_with: [tskit_lib],
dependencies: kastore_dep)
test('minimal_cpp', test_minimal_cpp)
if get_option('build_examples')
# These example programs use less portable features,
# and we don't want to always compile them. Use, e.g.,
# meson build -Dbuild_examples=false
executable('api_structure',
sources: ['examples/api_structure.c'],
link_with: [tskit_lib], dependencies: lib_deps)
executable('error_handling',
sources: ['examples/error_handling.c'],
link_with: [tskit_lib], dependencies: lib_deps)
executable('tree_iteration',
sources: ['examples/tree_iteration.c'],
link_with: [tskit_lib], dependencies: lib_deps)
executable('tree_traversal',
sources: ['examples/tree_traversal.c'],
link_with: [tskit_lib], dependencies: lib_deps)
executable('streaming',
sources: ['examples/streaming.c'],
link_with: [tskit_lib], dependencies: lib_deps)
executable('cpp_sorting_example',
sources: ['examples/cpp_sorting_example.cpp'],
link_with: [tskit_lib], dependencies: lib_deps)
executable('haploid_wright_fisher',
sources: ['examples/haploid_wright_fisher.c'],
link_with: [tskit_lib], dependencies: lib_deps)
executable('multichrom_wright_fisher_singlethreaded',
sources: ['examples/multichrom_wright_fisher_singlethreaded.c'],
link_with: [tskit_lib], dependencies: lib_deps)
executable('json_struct_metadata',
sources: ['examples/json_struct_metadata.c'],
link_with: [tskit_lib], dependencies: lib_deps)
thread_dep = dependency('threads')
executable('multichrom_wright_fisher',
sources: ['examples/multichrom_wright_fisher.c'],
link_with: [tskit_lib], dependencies: [m_dep, kastore_dep, thread_dep])
endif
endif
================================================
FILE: c/meson_options.txt
================================================
option('build_examples', type : 'boolean', value : true)
================================================
FILE: c/subprojects/kastore/README.md
================================================
This directory is an abbreviated version of the kastore distribution source.
All files should be updated when we are updating to a new kastore version.
================================================
FILE: c/subprojects/kastore/VERSION.txt
================================================
2.1.2
================================================
FILE: c/subprojects/kastore/kastore.c
================================================
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
#include <stdbool.h>
#include "kastore.h"
/* Private flag used to indicate when we have opened the file ourselves
* and need to free it. */
/* Note: we use 1<<14 to keep this flag at the end of the flag space,
* and this is the highest bit that can be guaranteed to fit into
* an int. */
#define OWN_FILE (1 << 14)
const char *
kas_strerror(int err)
{
const char *ret = "Unknown error";
switch (err) {
case KAS_ERR_GENERIC:
ret = "Generic error; please file a bug report";
break;
case KAS_ERR_IO:
if (errno != 0) {
ret = strerror(errno);
} else {
ret = "I/O error with errno unset. Please file a bug report";
}
break;
case KAS_ERR_BAD_MODE:
ret = "Bad open mode; must be \"r\", \"w\", or \"a\"";
break;
case KAS_ERR_BAD_FLAGS:
ret = "Unknown flags specified. Only (KAS_GET_TAKES_OWNERSHIP and/or"
"KAS_READ_ALL) or 0 can be specified "
"for open, and KAS_BORROWS_ARRAY or 0 for put";
break;
case KAS_ERR_NO_MEMORY:
ret = "Out of memory";
break;
case KAS_ERR_BAD_FILE_FORMAT:
ret = "File not in KAS format";
break;
case KAS_ERR_VERSION_TOO_OLD:
ret = "File format version is too old. Please upgrade using "
"'kas upgrade <filename>'";
break;
case KAS_ERR_VERSION_TOO_NEW:
ret = "File format version is too new. Please upgrade your "
"kastore library version";
break;
case KAS_ERR_BAD_TYPE:
ret = "Unknown data type";
break;
case KAS_ERR_DUPLICATE_KEY:
ret = "Duplicate key provided";
break;
case KAS_ERR_KEY_NOT_FOUND:
ret = "Key not found";
break;
case KAS_ERR_EMPTY_KEY:
ret = "Keys cannot be empty";
break;
case KAS_ERR_ILLEGAL_OPERATION:
ret = "Cannot perform the requested operation in the current mode";
break;
case KAS_ERR_TYPE_MISMATCH:
ret = "Mismatch between requested and stored types for array";
break;
case KAS_ERR_EOF:
ret = "End of file";
break;
}
return ret;
}
kas_version_t
kas_version(void)
{
kas_version_t version;
version.major = KAS_VERSION_MAJOR;
version.minor = KAS_VERSION_MINOR;
version.patch = KAS_VERSION_PATCH;
return version;
}
static size_t
type_size(int type)
{
const size_t type_size_map[] = { 1, 1, 2, 2, 4, 4, 8, 8, 4, 8 };
assert(type < KAS_NUM_TYPES);
return type_size_map[type];
}
/* Compare item keys lexicographically. */
static int
compare_items(const void *a, const void *b)
{
const kaitem_t *ia = (const kaitem_t *) a;
const kaitem_t *ib = (const kaitem_t *) b;
size_t len = ia->key_len < ib->key_len ? ia->key_len : ib->key_len;
int ret = memcmp(ia->key, ib->key, len);
if (ret == 0) {
ret = (ia->key_len > ib->key_len) - (ia->key_len < ib->key_len);
}
return ret;
}
/* When a read error occurs we don't know whether this is because the file
* ended unexpectedly or an IO error occured. If the file ends unexpectedly
* this is a file format error.
*/
static int KAS_WARN_UNUSED
kastore_get_read_io_error(kastore_t *self)
{
int ret = KAS_ERR_IO;
if (feof(self->file) || errno == 0) {
ret = KAS_ERR_BAD_FILE_FORMAT;
}
return ret;
}
static int KAS_WARN_UNUSED
kastore_write_header(kastore_t *self)
{
int ret = 0;
char header[KAS_HEADER_SIZE];
uint16_t version_major = KAS_FILE_VERSION_MAJOR;
uint16_t version_minor = KAS_FILE_VERSION_MINOR;
uint32_t num_items = (uint32_t) self->num_items;
uint64_t file_size = (uint64_t) self->file_size;
memset(header, 0, sizeof(header));
memcpy(header, KAS_MAGIC, 8);
memcpy(header + 8, &version_major, 2);
memcpy(header + 10, &version_minor, 2);
memcpy(header + 12, &num_items, 4);
memcpy(header + 16, &file_size, 8);
/* Rest of header is reserved */
if (fwrite(header, KAS_HEADER_SIZE, 1, self->file) != 1) {
ret = KAS_ERR_IO;
goto out;
}
out:
return ret;
}
static int KAS_WARN_UNUSED
kastore_read_header(kastore_t *self)
{
int ret = 0;
char header[KAS_HEADER_SIZE];
uint16_t version_major, version_minor;
uint32_t num_items;
uint64_t file_size;
size_t count;
count = fread(header, 1, KAS_HEADER_SIZE, self->file);
if (count == 0 && feof(self->file)) {
ret = KAS_ERR_EOF;
goto out;
} else if (count != KAS_HEADER_SIZE) {
ret = kastore_get_read_io_error(self);
goto out;
}
if (strncmp(header, KAS_MAGIC, 8) != 0) {
ret = KAS_ERR_BAD_FILE_FORMAT;
goto out;
}
memcpy(&version_major, header + 8, 2);
memcpy(&version_minor, header + 10, 2);
memcpy(&num_items, header + 12, 4);
memcpy(&file_size, header + 16, 8);
self->file_version[0] = (int) version_major;
self->file_version[1] = (int) version_minor;
if (self->file_version[0] < KAS_FILE_VERSION_MAJOR) {
ret = KAS_ERR_VERSION_TOO_OLD;
goto out;
} else if (self->file_version[0] > KAS_FILE_VERSION_MAJOR) {
ret = KAS_ERR_VERSION_TOO_NEW;
goto out;
}
self->num_items = num_items;
self->file_size = (size_t) file_size;
if (self->file_size < KAS_HEADER_SIZE) {
ret = KAS_ERR_BAD_FILE_FORMAT;
goto out;
}
out:
return ret;
}
/* Compute the locations of the keys and arrays in the file. */
static void
kastore_pack_items(kastore_t *self)
{
size_t j, offset, remainder;
/* Pack the keys */
offset = KAS_HEADER_SIZE + self->num_items * KAS_ITEM_DESCRIPTOR_SIZE;
for (j = 0; j < self->num_items; j++) {
self->items[j].key_start = offset;
offset += self->items[j].key_len;
}
/* Pack the arrays */
for (j = 0; j < self->num_items; j++) {
remainder = offset % KAS_ARRAY_ALIGN;
if (remainder != 0) {
offset += KAS_ARRAY_ALIGN - remainder;
}
self->items[j].array_start = offset;
offset += self->items[j].array_len * type_size(self->items[j].type);
}
self->file_size = offset;
}
static int KAS_WARN_UNUSED
kastore_write_descriptors(kastore_t *self)
{
int ret = 0;
size_t j;
uint8_t type;
uint64_t key_start, key_len, array_start, array_len;
char descriptor[KAS_ITEM_DESCRIPTOR_SIZE];
for (j = 0; j < self->num_items; j++) {
memset(descriptor, 0, KAS_ITEM_DESCRIPTOR_SIZE);
type = (uint8_t) self->items[j].type;
key_start = (uint64_t) self->items[j].key_start;
key_len = (uint64_t) self->items[j].key_len;
array_start = (uint64_t) self->items[j].array_start;
array_len = (uint64_t) self->items[j].array_len;
memcpy(descriptor, &type, 1);
/* Bytes 1-8 are reserved */
memcpy(descriptor + 8, &key_start, 8);
memcpy(descriptor + 16, &key_len, 8);
memcpy(descriptor + 24, &array_start, 8);
memcpy(descriptor + 32, &array_len, 8);
/* Rest of descriptor is reserved */
if (fwrite(descriptor, sizeof(descriptor), 1, self->file) != 1) {
ret = KAS_ERR_IO;
goto out;
}
}
out:
return ret;
}
static int KAS_WARN_UNUSED
kastore_read_descriptors(kastore_t *self)
{
int ret = KAS_ERR_BAD_FILE_FORMAT;
size_t j;
uint8_t type;
uint64_t key_start, key_len, array_start, array_len;
char *descriptor;
size_t descriptor_offset, offset, remainder, size, count;
char *read_buffer = NULL;
size = self->num_items * KAS_ITEM_DESCRIPTOR_SIZE;
if (size + KAS_HEADER_SIZE > self->file_size) {
goto out;
}
read_buffer = (char *) malloc(size);
if (read_buffer == NULL) {
ret = KAS_ERR_NO_MEMORY;
goto out;
}
count = fread(read_buffer, size, 1, self->file);
if (count == 0) {
ret = kastore_get_read_io_error(self);
goto out;
}
descriptor_offset = 0;
for (j = 0; j < self->num_items; j++) {
descriptor = read_buffer + descriptor_offset;
descriptor_offset += KAS_ITEM_DESCRIPTOR_SIZE;
memcpy(&type, descriptor, 1);
memcpy(&key_start, descriptor + 8, 8);
memcpy(&key_len, descriptor + 16, 8);
memcpy(&array_start, descriptor + 24, 8);
memcpy(&array_len, descriptor + 32, 8);
if (type >= KAS_NUM_TYPES) {
ret = KAS_ERR_BAD_TYPE;
goto out;
}
self->items[j].type = (int) type;
if (key_start + key_len > self->file_size) {
goto out;
}
self->items[j].key_start = (size_t) key_start;
self->items[j].key_len = (size_t) key_len;
if (array_start + array_len * type_size(type) > self->file_size) {
goto out;
}
self->items[j].array_start = (size_t) array_start;
self->items[j].array_len = (size_t) array_len;
}
/* Check the integrity of the key and array packing. Keys must
* be packed sequentially starting immediately after the descriptors. */
offset = KAS_HEADER_SIZE + self->num_items * KAS_ITEM_DESCRIPTOR_SIZE;
for (j = 0; j < self->num_items; j++) {
if (self->items[j].key_start != offset) {
ret = KAS_ERR_BAD_FILE_FORMAT;
goto out;
}
offset += self->items[j].key_len;
}
for (j = 0; j < self->num_items; j++) {
/* Arrays are 8 byte aligned and adjacent */
remainder = offset % KAS_ARRAY_ALIGN;
if (remainder != 0) {
offset += KAS_ARRAY_ALIGN - remainder;
}
if (self->items[j].array_start != offset) {
ret = KAS_ERR_BAD_FILE_FORMAT;
goto out;
}
offset += self->items[j].array_len * type_size(self->items[j].type);
}
if (offset != self->file_size) {
ret = KAS_ERR_BAD_FILE_FORMAT;
goto out;
}
ret = 0;
out:
kas_safe_free(read_buffer);
return ret;
}
static int KAS_WARN_UNUSED
kastore_write_data(kastore_t *self)
{
int ret = 0;
size_t j, size, offset, padding;
char pad[KAS_ARRAY_ALIGN] = { 0, 0, 0, 0, 0, 0, 0 };
const void *write_array;
offset = KAS_HEADER_SIZE + self->num_items * KAS_ITEM_DESCRIPTOR_SIZE;
/* Write the keys. */
for (j = 0; j < self->num_items; j++) {
assert(offset == self->items[j].key_start);
if (fwrite(self->items[j].key, self->items[j].key_len, 1, self->file) != 1) {
ret = KAS_ERR_IO;
goto out;
}
offset += self->items[j].key_len;
}
/* Write the arrays. */
for (j = 0; j < self->num_items; j++) {
padding = self->items[j].array_start - offset;
assert(padding < KAS_ARRAY_ALIGN);
if (padding > 0 && fwrite(pad, padding, 1, self->file) != 1) {
ret = KAS_ERR_IO;
goto out;
}
size = self->items[j].array_len * type_size(self->items[j].type);
write_array = self->items[j].borrowed_array != NULL
? self->items[j].borrowed_array
: self->items[j].array;
assert(write_array != NULL);
if (size > 0 && fwrite(write_array, size, 1, self->file) != 1) {
ret = KAS_ERR_IO;
goto out;
}
offset = self->items[j].array_start + size;
}
out:
return ret;
}
static int KAS_WARN_UNUSED
kastore_read_file(kastore_t *self)
{
int ret = 0;
size_t count, size, offset, j;
bool read_all = !!(self->flags & KAS_READ_ALL);
offset = KAS_HEADER_SIZE + self->num_items * KAS_ITEM_DESCRIPTOR_SIZE;
/* Read in up to the start of first array. This will contain all the keys. */
size = self->items[0].array_start;
assert(size > offset);
size -= offset;
self->key_read_buffer = (char *) malloc(size);
if (self->key_read_buffer == NULL) {
ret = KAS_ERR_NO_MEMORY;
goto out;
}
count = fread(self->key_read_buffer, size, 1, self->file);
if (count == 0) {
ret = kastore_get_read_io_error(self);
goto out;
}
/* Assign the pointers for the keys and arrays */
for (j = 0; j < self->num_items; j++) {
/* keys are already loaded in the read buffer */
self->items[j].key = self->key_read_buffer + self->items[j].key_start - offset;
if (read_all) {
if (j == self->num_items - 1) {
size = self->file_size - self->items[j].array_start;
} else {
size = self->items[j + 1].array_start - self->items[j].array_start;
}
self->items[j].array = (char *) malloc(size == 0 ? 1 : size);
if (self->items[j].array == NULL) {
ret = KAS_ERR_NO_MEMORY;
goto out;
}
if (size > 0) {
count = fread(self->items[j].array, size, 1, self->file);
if (count == 0) {
ret = kastore_get_read_io_error(self);
goto out;
}
}
}
}
out:
return ret;
}
static int KAS_WARN_UNUSED
kastore_read_item(kastore_t *self, kaitem_t *item)
{
int ret = 0;
int err;
size_t size = item->array_len * type_size(item->type);
size_t count;
item->array = malloc(size == 0 ? 1 : size);
if (item->array == NULL) {
ret = KAS_ERR_NO_MEMORY;
goto out;
}
if (size > 0) {
err = fseek(self->file, self->file_offset + (long) item->array_start, SEEK_SET);
if (err != 0) {
ret = KAS_ERR_IO;
goto out;
}
count = fread(item->array, size, 1, self->file);
if (count == 0) {
ret = kastore_get_read_io_error(self);
goto out;
}
}
out:
return ret;
}
static int KAS_WARN_UNUSED
kastore_write_file(kastore_t *self)
{
int ret = 0;
qsort(self->items, self->num_items, sizeof(kaitem_t), compare_items);
kastore_pack_items(self);
ret = kastore_write_header(self);
if (ret != 0) {
goto out;
}
ret = kastore_write_descriptors(self);
if (ret != 0) {
goto out;
}
ret = kastore_write_data(self);
if (ret != 0) {
goto out;
}
out:
return ret;
}
static int KAS_WARN_UNUSED
kastore_read(kastore_t *self)
{
int ret = 0;
if (!(self->flags & KAS_READ_ALL)) {
/* Record the current file offset, in case this is a multi-store file,
* so that we can seek to the correct location in kastore_read_item().
*/
self->file_offset = ftell(self->file);
if (self->file_offset == -1) {
ret = KAS_ERR_IO;
goto out;
}
}
ret = kastore_read_header(self);
if (ret != 0) {
goto out;
}
if (self->num_items > 0) {
self->items = (kaitem_t *) calloc(self->num_items, sizeof(*self->items));
if (self->items == NULL) {
ret = KAS_ERR_NO_MEMORY;
goto out;
}
ret = kastore_read_descriptors(self);
if (ret != 0) {
goto out;
}
ret = kastore_read_file(self);
if (ret != 0) {
goto out;
}
} else if (self->file_size != KAS_HEADER_SIZE) {
ret = KAS_ERR_BAD_FILE_FORMAT;
goto out;
}
out:
return ret;
}
static int KAS_WARN_UNUSED
kastore_insert_all(kastore_t *self, kastore_t *other)
{
size_t j;
int ret = 0;
kaitem_t item;
for (j = 0; j < other->num_items; j++) {
item = other->items[j];
ret = kastore_put(
self, item.key, item.key_len, item.array, item.array_len, item.type, 0);
if (ret != 0) {
goto out;
}
}
out:
return ret;
}
int KAS_WARN_UNUSED
kastore_open(kastore_t *self, const char *filename, const char *mode, int flags)
{
int ret = 0;
const char *file_mode;
bool appending = false;
kastore_t tmp;
FILE *file;
int err;
memset(self, 0, sizeof(*self));
memset(&tmp, 0, sizeof(tmp));
if (strlen(mode) != 1) {
ret = KAS_ERR_BAD_MODE;
goto out;
}
if (strncmp(mode, "r", 1) == 0) {
file_mode = "rb";
} else if (strncmp(mode, "w", 1) == 0) {
file_mode = "wb";
} else if (strncmp(mode, "a", 1) == 0) {
mode = "w";
file_mode = "wb";
appending = true;
} else {
ret = KAS_ERR_BAD_MODE;
goto out;
}
if (appending) {
ret = kastore_open(&tmp, filename, "r", KAS_READ_ALL);
if (ret != 0) {
goto out;
}
/* tmp will now have read all of the data into memory. We can now
* close its file. We have to do this for Windows. */
err = fclose(tmp.file);
tmp.file = NULL;
if (err != 0) {
ret = KAS_ERR_IO;
goto out;
}
}
file = fopen(filename, file_mode);
if (file == NULL) {
ret = KAS_ERR_IO;
goto out;
}
ret = kastore_openf(self, file, mode, flags);
if (ret != 0) {
(void) fclose(file);
} else {
self->flags |= OWN_FILE;
if (appending) {
ret = kastore_insert_all(self, &tmp);
}
}
out:
if (appending) {
kastore_close(&tmp);
}
return ret;
}
int KAS_WARN_UNUSED
kastore_openf(kastore_t *self, FILE *file, const char *mode, int flags)
{
int ret = 0;
memset(self, 0, sizeof(*self));
if (strlen(mode) != 1) {
ret = KAS_ERR_BAD_MODE;
goto out;
}
if (strncmp(mode, "r", 1) == 0) {
self->mode = KAS_READ;
} else if (strncmp(mode, "w", 1) == 0) {
self->mode = KAS_WRITE;
} else {
ret = KAS_ERR_BAD_MODE;
goto out;
}
if (flags > (KAS_READ_ALL | KAS_GET_TAKES_OWNERSHIP) || flags < 0) {
ret = KAS_ERR_BAD_FLAGS;
goto out;
}
self->flags = flags;
self->file = file;
if (self->mode == KAS_READ) {
ret = kastore_read(self);
}
out:
return ret;
}
int KAS_WARN_UNUSED
kastore_close(kastore_t *self)
{
int ret = 0;
int err;
size_t j;
if (self->mode == KAS_WRITE) {
if (self->file != NULL) {
ret = kastore_write_file(self);
if (ret != 0) {
/* Ignore errors on close now */
if (self->flags & OWN_FILE) {
fclose(self->file);
}
self->file = NULL;
}
}
if (self->items != NULL) {
/* We only alloc memory for the keys and arrays in write mode */
for (j = 0; j < self->num_items; j++) {
kas_safe_free(self->items[j].key);
kas_safe_free(self->items[j].array);
}
}
} else {
kas_safe_free(self->key_read_buffer);
if (self->items != NULL) {
for (j = 0; j < self->num_items; j++) {
kas_safe_free(self->items[j].array);
}
}
}
kas_safe_free(self->items);
if (self->file != NULL && (self->flags & OWN_FILE)) {
err = fclose(self->file);
if (err != 0) {
ret = KAS_ERR_IO;
}
}
memset(self, 0, sizeof(*self));
return ret;
}
static int
kastore_find_item(kastore_t *self, const char *key, size_t key_len, kaitem_t **item)
{
int ret = KAS_ERR_KEY_NOT_FOUND;
kaitem_t search;
search.key = (char *) malloc(key_len);
search.key_len = key_len;
if (self->mode != KAS_READ) {
ret = KAS_ERR_ILLEGAL_OPERATION;
goto out;
}
if (search.key == NULL) {
ret = KAS_ERR_NO_MEMORY;
goto out;
}
memcpy(search.key, key, key_len);
*item = bsearch(
&search, self->items, self->num_items, sizeof(kaitem_t), compare_items);
if (*item == NULL) {
goto out;
}
ret = 0;
out:
kas_safe_free(search.key);
return ret;
}
int KAS_WARN_UNUSED
kastore_contains(kastore_t *self, const char *key, size_t key_len)
{
kaitem_t *item;
int ret = kastore_find_item(self, key, key_len, &item);
if (ret == 0) {
ret = 1;
} else if (ret == KAS_ERR_KEY_NOT_FOUND) {
ret = 0;
}
return ret;
}
int KAS_WARN_UNUSED
kastore_containss(kastore_t *self, const char *key)
{
return kastore_contains(self, key, strlen(key));
}
int KAS_WARN_UNUSED
kastore_get(kastore_t *self, const char *key, size_t key_len, void **array,
size_t *array_len, int *type)
{
kaitem_t *item;
int ret = kastore_find_item(self, key, key_len, &item);
if (ret != 0) {
goto out;
}
if (item->array == NULL) {
ret = kastore_read_item(self, item);
if (ret != 0) {
goto out;
}
}
*array = item->array;
*array_len = item->array_len;
*type = item->type;
if (self->flags & KAS_GET_TAKES_OWNERSHIP) {
item->array = NULL;
}
ret = 0;
out:
return ret;
}
int KAS_WARN_UNUSED
kastore_gets(
kastore_t *self, const char *key, void **array, size_t *array_len, int *type)
{
return kastore_get(self, key, strlen(key), array, array_len, type);
}
static int KAS_WARN_UNUSED
kastore_gets_type(
kastore_t *self, const char *key, void **array, size_t *array_len, int type)
{
int loaded_type = -1;
int ret;
ret = kastore_get(self, key, strlen(key), array, array_len, &loaded_type);
if (ret != 0) {
goto out;
}
if (type != loaded_type) {
ret = KAS_ERR_TYPE_MISMATCH;
goto out;
}
out:
return ret;
}
int KAS_WARN_UNUSED
kastore_gets_int8(kastore_t *self, const char *key, int8_t **array, size_t *array_len)
{
return kastore_gets_type(self, key, (void **) array, array_len, KAS_INT8);
}
int KAS_WARN_UNUSED
kastore_gets_uint8(kastore_t *self, const char *key, uint8_t **array, size_t *array_len)
{
return kastore_gets_type(self, key, (void **) array, array_len, KAS_UINT8);
}
int KAS_WARN_UNUSED
kastore_gets_int16(kastore_t *self, const char *key, int16_t **array, size_t *array_len)
{
return kastore_gets_type(self, key, (void **) array, array_len, KAS_INT16);
}
int KAS_WARN_UNUSED
kastore_gets_uint16(
kastore_t *self, const char *key, uint16_t **array, size_t *array_len)
{
return kastore_gets_type(self, key, (void **) array, array_len, KAS_UINT16);
}
int KAS_WARN_UNUSED
kastore_gets_int32(kastore_t *self, const char *key, int32_t **array, size_t *array_len)
{
return kastore_gets_type(self, key, (void **) array, array_len, KAS_INT32);
}
int KAS_WARN_UNUSED
kastore_gets_uint32(
kastore_t *self, const char *key, uint32_t **array, size_t *array_len)
{
return kastore_gets_type(self, key, (void **) array, array_len, KAS_UINT32);
}
int KAS_WARN_UNUSED
kastore_gets_int64(kastore_t *self, const char *key, int64_t **array, size_t *array_len)
{
return kastore_gets_type(self, key, (void **) array, array_len, KAS_INT64);
}
int KAS_WARN_UNUSED
kastore_gets_uint64(
kastore_t *self, const char *key, uint64_t **array, size_t *array_len)
{
return kastore_gets_type(self, key, (void **) array, array_len, KAS_UINT64);
}
int KAS_WARN_UNUSED
kastore_gets_float32(kastore_t *self, const char *key, float **array, size_t *array_len)
{
return kastore_gets_type(self, key, (void **) array, array_len, KAS_FLOAT32);
}
int KAS_WARN_UNUSED
kastore_gets_float64(kastore_t *self, const char *key, double **array, size_t *array_len)
{
return kastore_gets_type(self, key, (void **) array, array_len, KAS_FLOAT64);
}
static int KAS_WARN_UNUSED
kastore_put_item(kastore_t *self, kaitem_t **ret_item, const char *key, size_t key_len,
int type, int KAS_UNUSED(flags))
{
int ret = 0;
kaitem_t *new_item;
kaitem_t *p;
size_t j;
if (self->mode != KAS_WRITE) {
ret = KAS_ERR_ILLEGAL_OPERATION;
goto out;
}
if (type < 0 || type >= KAS_NUM_TYPES) {
ret = KAS_ERR_BAD_TYPE;
goto out;
}
if (key_len == 0) {
ret = KAS_ERR_EMPTY_KEY;
goto out;
}
/* This isn't terribly efficient, but we're not expecting large
* numbers of items. */
p = (kaitem_t *) realloc(self->items, (self->num_items + 1) * sizeof(*self->items));
if (p == NULL) {
ret = KAS_ERR_NO_MEMORY;
goto out;
}
self->items = p;
new_item = self->items + self->num_items;
memset(new_item, 0, sizeof(*new_item));
new_item->type = type;
new_item->key_len = key_len;
new_item->key = (char *) malloc(key_len);
if (new_item->key == NULL) {
kas_safe_free(new_item->key);
ret = KAS_ERR_NO_MEMORY;
goto out;
}
self->num_items++;
memcpy(new_item->key, key, key_len);
/* Check if this key is already in here. OK, this is a quadratic time
* algorithm, but we're not expecting to have lots of items (< 100). In
* this case, the simple algorithm is probably better. If/when we ever
* deal with more items than this, then we will need a better algorithm.
*/
for (j = 0; j < self->num_items - 1; j++) {
if (compare_items(new_item, self->items + j) == 0) {
/* Free the key memory and remove this item */
self->num_items--;
kas_safe_free(new_item->key);
ret = KAS_ERR_DUPLICATE_KEY;
goto out;
}
}
*ret_item = new_item;
out:
return ret;
}
static int KAS_WARN_UNUSED
kastore_bput(kastore_t *self, const char *key, size_t key_len, const void *array,
size_t array_len, int type, int flags)
{
int ret = 0;
kaitem_t *item;
ret = kastore_put_item(self, &item, key, key_len, type, flags);
if (ret != 0) {
goto out;
}
if (array == NULL) {
/* Both can't be null, so assign a dummy array */
item->array = malloc(1);
} else {
item->borrowed_array = array;
}
item->borrowed_array = array;
item->array_len = array_len;
out:
return ret;
}
int KAS_WARN_UNUSED
kastore_put(kastore_t *self, const char *key, size_t key_len, const void *array,
size_t array_len, int type, int flags)
{
int ret;
size_t array_size;
void *array_copy = NULL;
if (flags != KAS_BORROWS_ARRAY && flags != 0) {
ret = KAS_ERR_BAD_FLAGS;
goto out;
}
if (type < 0 || type >= KAS_NUM_TYPES) {
ret = KAS_ERR_BAD_TYPE;
goto out;
}
if (flags & KAS_BORROWS_ARRAY) {
ret = kastore_bput(self, key, key_len, array, array_len, type, flags);
} else {
array_size = type_size(type) * array_len;
array_copy = malloc(array_size == 0 ? 1 : array_size);
if (array_copy == NULL) {
ret = KAS_ERR_NO_MEMORY;
goto out;
}
memcpy(array_copy, array, array_size);
ret = kastore_oput(self, key, key_len, array_copy, array_len, type, flags);
if (ret == 0) {
/* Kastore has taken ownership of the array, so we don't need to free it */
array_copy = NULL;
}
}
out:
kas_safe_free(array_copy);
return ret;
}
int KAS_WARN_UNUSED
kastore_oput(kastore_t *self, const char *key, size_t key_len, void *array,
size_t array_len, int type, int flags)
{
int ret = 0;
kaitem_t *item;
if (flags != 0) {
ret = KAS_ERR_BAD_FLAGS;
goto out;
}
ret = kastore_put_item(self, &item, key, key_len, type, flags);
if (ret != 0) {
goto out;
}
item->array = array;
item->array_len = array_len;
out:
return ret;
}
int KAS_WARN_UNUSED
kastore_puts(kastore_t *self, const char *key, const void *array, size_t array_len,
int type, int flags)
{
return kastore_put(self, key, strlen(key), array, array_len, type, flags);
}
int KAS_WARN_UNUSED
kastore_puts_int8(
kastore_t *self, const char *key, const int8_t *array, size_t array_len, int flags)
{
return kastore_puts(self, key, (const void *) array, array_len, KAS_INT8, flags);
}
int KAS_WARN_UNUSED
kastore_puts_uint8(
kastore_t *self, const char *key, const uint8_t *array, size_t array_len, int flags)
{
return kastore_puts(self, key, (const void *) array, array_len, KAS_UINT8, flags);
}
int KAS_WARN_UNUSED
kastore_puts_int16(
kastore_t *self, const char *key, const int16_t *array, size_t array_len, int flags)
{
return kastore_puts(self, key, (const void *) array, array_len, KAS_INT16, flags);
}
int KAS_WARN_UNUSED
kastore_puts_uint16(
kastore_t *self, const char *key, const uint16_t *array, size_t array_len, int flags)
{
return kastore_puts(self, key, (const void *) array, array_len, KAS_UINT16, flags);
}
int KAS_WARN_UNUSED
kastore_puts_int32(
kastore_t *self, const char *key, const int32_t *array, size_t array_len, int flags)
{
return kastore_puts(self, key, (const void *) array, array_len, KAS_INT32, flags);
}
int KAS_WARN_UNUSED
kastore_puts_uint32(
kastore_t *self, const char *key, const uint32_t *array, size_t array_len, int flags)
{
return kastore_puts(self, key, (const void *) array, array_len, KAS_UINT32, flags);
}
int KAS_WARN_UNUSED
kastore_puts_int64(
kastore_t *self, const char *key, const int64_t *array, size_t array_len, int flags)
{
return kastore_puts(self, key, (const void *) array, array_len, KAS_INT64, flags);
}
int KAS_WARN_UNUSED
kastore_puts_uint64(
kastore_t *self, const char *key, const uint64_t *array, size_t array_len, int flags)
{
return kastore_puts(self, key, (const void *) array, array_len, KAS_UINT64, flags);
}
int KAS_WARN_UNUSED
kastore_puts_float32(
kastore_t *self, const char *key, const float *array, size_t array_len, int flags)
{
return kastore_puts(self, key, (const void *) array, array_len, KAS_FLOAT32, flags);
}
int KAS_WARN_UNUSED
kastore_puts_float64(
kastore_t *self, const char *key, const double *array, size_t array_len, int flags)
{
return kastore_puts(self, key, (const void *) array, array_len, KAS_FLOAT64, flags);
}
int KAS_WARN_UNUSED
kastore_oputs(
kastore_t *self, const char *key, void *array, size_t array_len, int type, int flags)
{
return kastore_oput(self, key, strlen(key), array, array_len, type, flags);
}
int KAS_WARN_UNUSED
kastore_oputs_int8(
kastore_t *self, const char *key, int8_t *array, size_t array_len, int flags)
{
return kastore_oputs(self, key, (void *) array, array_len, KAS_INT8, flags);
}
int KAS_WARN_UNUSED
kastore_oputs_uint8(
kastore_t *self, const char *key, uint8_t *array, size_t array_len, int flags)
{
return kastore_oputs(self, key, (void *) array, array_len, KAS_UINT8, flags);
}
int KAS_WARN_UNUSED
kastore_oputs_int16(
kastore_t *self, const char *key, int16_t *array, size_t array_len, int flags)
{
return kastore_oputs(self, key, (void *) array, array_len, KAS_INT16, flags);
}
int KAS_WARN_UNUSED
kastore_oputs_uint16(
kastore_t *self, const char *key, uint16_t *array, size_t array_len, int flags)
{
return kastore_oputs(self, key, (void *) array, array_len, KAS_UINT16, flags);
}
int KAS_WARN_UNUSED
kastore_oputs_int32(
kastore_t *self, const char *key, int32_t *array, size_t array_len, int flags)
{
return kastore_oputs(self, key, (void *) array, array_len, KAS_INT32, flags);
}
int KAS_WARN_UNUSED
kastore_oputs_uint32(
kastore_t *self, const char *key, uint32_t *array, size_t array_len, int flags)
{
return kastore_oputs(self, key, (void *) array, array_len, KAS_UINT32, flags);
}
int KAS_WARN_UNUSED
kastore_oputs_int64(
kastore_t *self, const char *key, int64_t *array, size_t array_len, int flags)
{
return kastore_oputs(self, key, (void *) array, array_len, KAS_INT64, flags);
}
int KAS_WARN_UNUSED
kastore_oputs_uint64(
kastore_t *self, const char *key, uint64_t *array, size_t array_len, int flags)
{
return kastore_oputs(self, key, (void *) array, array_len, KAS_UINT64, flags);
}
int KAS_WARN_UNUSED
kastore_oputs_float32(
kastore_t *self, const char *key, float *array, size_t array_len, int flags)
{
return kastore_oputs(self, key, (void *) array, array_len, KAS_FLOAT32, flags);
}
int KAS_WARN_UNUSED
kastore_oputs_float64(
kastore_t *self, const char *key, double *array, size_t array_len, int flags)
{
return kastore_oputs(self, key, (void *) array, array_len, KAS_FLOAT64, flags);
}
void
kastore_print_state(kastore_t *self, FILE *out)
{
kaitem_t *item;
size_t j;
fprintf(out, "============================\n");
fprintf(out, "kastore state\n");
fprintf(out, "file_version = %d.%d\n", self->file_version[0], self->file_version[1]);
fprintf(out, "mode = %d\n", self->mode);
fprintf(out, "flags = %d\n", self->flags);
fprintf(out, "num_items = %zu\n", self->num_items);
fprintf(out, "file_size = %zu\n", self->file_size);
fprintf(out, "own_file = %d\n", !!(self->flags & OWN_FILE));
fprintf(out, "file = '%p'\n", (void *) self->file);
fprintf(out, "============================\n");
for (j = 0; j < self->num_items; j++) {
item = self->items + j;
fprintf(out,
"%.*s: type=%d, key_start=%zu, key_len=%zu, key=%p, "
"array_start=%zu, array_len=%zu, array=%p\n",
(int) item->key_len, item->key, item->type, item->key_start, item->key_len,
(void *) item->key, item->array_start, item->array_len,
(void *) item->array);
}
fprintf(out, "============================\n");
}
================================================
FILE: c/subprojects/kastore/kastore.h
================================================
/**
* @file kastore.h
* @brief Public API for kastore.
*
* This is the API documentation for kastore.
*/
#ifndef KASTORE_H
#define KASTORE_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __GNUC__
#define KAS_WARN_UNUSED __attribute__((warn_unused_result))
#define KAS_UNUSED(x) KAS_UNUSED_##x __attribute__((__unused__))
#else
#define KAS_WARN_UNUSED
#define KAS_UNUSED(x) KAS_UNUSED_##x
#endif
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
/**
@defgroup ERROR_GROUP Error return values.
@{
*/
// clang-format off
/**
Generic error thrown when no other message can be generated.
*/
#define KAS_ERR_GENERIC -1
/**
An error occured during IO.
*/
#define KAS_ERR_IO -2
/**
An unrecognised mode string was passed to open().
*/
#define KAS_ERR_BAD_MODE -3
/**
Out-of-memory condition.
*/
#define KAS_ERR_NO_MEMORY -4
/**
Attempt to read an unknown file format.
*/
#define KAS_ERR_BAD_FILE_FORMAT -5
/**
The file is in kastore format, but the version is too old for this
version of the library to read.
*/
#define KAS_ERR_VERSION_TOO_OLD -6
/**
The file is in kastore format, but the version is too new for this
version of the library to read.
*/
#define KAS_ERR_VERSION_TOO_NEW -7
/**
An unknown type key was specified.
*/
#define KAS_ERR_BAD_TYPE -8
/**
A zero-length key was specified.
*/
#define KAS_ERR_EMPTY_KEY -9
/**
A duplicate key was specified.
*/
#define KAS_ERR_DUPLICATE_KEY -10
/**
The requested key does not exist in the store.
*/
#define KAS_ERR_KEY_NOT_FOUND -11
/**
The requestion function cannot be called in the current mode.
*/
#define KAS_ERR_ILLEGAL_OPERATION -12
/**
The requested type does not match the type of the stored values.
*/
#define KAS_ERR_TYPE_MISMATCH -13
/**
End of file was reached while reading data.
*/
#define KAS_ERR_EOF -14
/**
Unknown flags were provided to open.
*/
#define KAS_ERR_BAD_FLAGS -15
/** @} */
/* Flags for open */
#define KAS_READ_ALL (1 << 0)
#define KAS_GET_TAKES_OWNERSHIP (1 << 1)
/* Flags for put */
#define KAS_BORROWS_ARRAY (1 << 8)
/**
@defgroup TYPE_GROUP Data types.
@{
*/
#define KAS_INT8 0
#define KAS_UINT8 1
#define KAS_INT16 2
#define KAS_UINT16 3
#define KAS_INT32 4
#define KAS_UINT32 5
#define KAS_INT64 6
#define KAS_UINT64 7
#define KAS_FLOAT32 8
#define KAS_FLOAT64 9
/** @} */
#define KAS_NUM_TYPES 10
#define KAS_READ 1
#define KAS_WRITE 2
/**
@defgroup FILE_VERSION_GROUP File version macros.
@{
*/
/**
The file version major number. Incremented when any breaking changes are made
to the file format.
*/
#define KAS_FILE_VERSION_MAJOR 1
/**
The file version minor number. Incremented when non-breaking backward-compatible
changes are made to the file format.
*/
#define KAS_FILE_VERSION_MINOR 0
/** @} */
/**
@defgroup API_VERSION_GROUP API version macros.
@{
*/
/**
The library major version. Incremented when breaking changes to the API or ABI are
introduced. This includes any changes to the signatures of functions and the
sizes and types of externally visible structs.
*/
#define KAS_VERSION_MAJOR 2
/**
The library minor version. Incremented when non-breaking backward-compatible changes
to the API or ABI are introduced, i.e., the addition of a new function.
*/
#define KAS_VERSION_MINOR 1
/**
The library patch version. Incremented when any changes not relevant to the
to the API or ABI are introduced, i.e., internal refactors of bugfixes.
*/
#define KAS_VERSION_PATCH 2
/** @} */
#define KAS_HEADER_SIZE 64
#define KAS_ITEM_DESCRIPTOR_SIZE 64
#define KAS_MAGIC "\211KAS\r\n\032\n"
#define KAS_ARRAY_ALIGN 8
// clang-format on
#ifndef KAS_BUG_ASSERT_MESSAGE
#define KAS_BUG_ASSERT_MESSAGE \
"If you are using kastore directly please open an issue on" \
" GitHub, ideally with a reproducible example." \
" (https://github.com/tskit-dev/kastore/issues) If you are" \
" using software that uses kastore, please report an issue" \
" to that software's issue tracker, at least initially."
#endif
/**
We often wish to assert a condition that is unexpected, but using the normal `assert`
means compiling without NDEBUG. This macro still asserts when NDEBUG is defined.
*/
#define kas_bug_assert(condition) \
do { \
if (!(condition)) { \
fprintf(stderr, "Bug detected in %s at line %d. %s\n", __FILE__, __LINE__, \
KAS_BUG_ASSERT_MESSAGE); \
abort(); \
} \
} while (0)
typedef struct {
int type;
size_t key_len;
size_t array_len;
char *key;
/* Used when KAS_BORROWS_ARRAY is set */
const void *borrowed_array;
void *array;
size_t key_start;
size_t array_start;
} kaitem_t;
/**
@brief A file-backed store of key-array values.
*/
typedef struct {
int flags;
int mode;
int file_version[2];
size_t num_items;
kaitem_t *items;
FILE *file;
size_t file_size;
long file_offset;
char *key_read_buffer;
} kastore_t;
/**
@brief Library version information.
*/
typedef struct {
/** @brief The major version number. */
int major;
/** @brief The minor version number. */
int minor;
/** @brief The patch version number. */
int patch;
} kas_version_t;
/**
@brief Open a store from a given file in read ("r"), write ("w") or
append ("a") mode.
@rst
In read mode, a store can be queried using the :ref:`get functions
<sec_c_api_get>` and any attempts to write to the store will return an error.
In write and append mode, the store can written to using the :ref:`put
functions <sec_c_api_put>` and any attempt to read will return an error.
After :c:func:`kastore_open` has been called on a particular store,
:c:func:`kastore_close` must be called to avoid leaking memory. This must also
be done when :c:func:`kastore_open` returns an error.
When opened in read-mode, the default is to read key/array values from file
on demand. This is useful when a subset of the data is required and we don't
wish to read the entire file. If the entire file is to be read, the
``KAS_READ_ALL`` flag may be specified to improve performance.
**Flags**
KAS_READ_ALL
If this option is specified, read the entire file at
open time. This will give slightly better performance as the file can
be read sequentially in a single pass.
KAS_GET_TAKES_OWNERSHIP
If this option is specified, all ``get`` operations will transfer
ownership of the array to the caller. ``kastore`` will not ``free``
the array memory and this is the responsibility of the caller.
If ``get`` is called on the same key multiple times, a new buffer will be
returned each time. Note that second and subsequent ``get`` calls
on a given key will result in ``seek`` operations even when the
KAS_READ_ALL flag is set, and will therefore fail on unseekable
streams.
@endrst
@param self A pointer to a kastore object.
@param filename The file path to open.
@param mode The open mode: can be read ("r"), write ("w") or append ("a").
@param flags The open flags.
@return Return 0 on success or a negative value on failure.
*/
int kastore_open(kastore_t *self, const char *filename, const char *mode, int flags);
/**
@brief Open a store from a given FILE pointer.
@rst
Behaviour, mode and flags follow that of :c:func:`kastore_open`,
except append mode is not supported.
The ``file`` argument must be opened in an appropriate mode (e.g. "r"
for a kastore in "r" mode). Files open with other modes will result
in KAS_ERR_IO being returned when read/write operations are attempted.
The FILE will not be closed when :c:func:`kastore_close` is called.
If the KAS_READ_ALL flag is supplied, no ``seek`` operations will be
performed on the FILE and so streams such as stdin, FIFOs etc are
supported. The FILE pointer will be positioned exactly at the end
of the kastore encoded bytes once reading is completed, and reading
multiple stores from the same FILE sequentially is fully supported.
@endrst
@param self A pointer to a kastore object.
@param file The FILE* to read/write the store from/to.
@param mode The open mode: can be read ("r") or write ("w").
@param flags The open flags.
@return Return 0 on success or a negative value on failure.
*/
int kastore_openf(kastore_t *self, FILE *file, const char *mode, int flags);
/**
@brief Close an opened store, freeing all resources.
Any store that has been opened must be closed to avoid memory leaks
(including cases in which errors have occured). It is not an error to
call ``kastore_close`` multiple times on the same object, but
``kastore_open`` must be called before ``kastore_close``.
@param self A pointer to a kastore object.
@return Return 0 on success or a negative value on failure.
*/
int kastore_close(kastore_t *self);
/**
@brief Return 1 if the store contains the specified key and 0 if it does not.
@rst
Queries the store for the specified key and returns 1 if it exists. If the
key does not exist, 0 is returned. If an error occurs (for example, if querying
the store while it is in write-mode), a negative value is returned.
For keys that are standard NULL terminated strings, the :c:func:`kastore_containss`
function may be more convenient.
@endrst
@param self A pointer to a kastore object.
@param key The key.
@param key_len The length of the key.
@return Return 1 if the key is present and 0 if it does not. If an error occurs,
return a negative value.
*/
int kastore_contains(kastore_t *self, const char *key, size_t key_len);
/**
@brief Return 1 if the store contains the specified NULL terminated key
and 0 if it does not.
@rst
Queries the store for the specified key, which must be a NULL terminated string,
and returns 1 if it exists. If the
key does not exist, 0 is returned. If an error occurs (for example, if querying
the store while it is in write-mode), a negative value is returned.
the array in the specified destination pointers.
@endrst
@param self A pointer to a kastore object.
@param key The key.
@return Return 1 if the key is present and 0 if it does not. If an error occurs,
return a negative value.
*/
int kastore_containss(kastore_t *self, const char *key);
/**
@brief Get the array for the specified key.
@rst
Queries the store for the specified key and stores pointers to the memory for
the corresponding array, the number of elements in this array and the type of
the array in the specified destination pointers. This is the most general form
of ``get`` query in kastore, as non NULL-terminated strings can be used as
keys and the resulting array is returned in a generic pointer. When standard C
strings are used as keys and the type of the array is known, it is more
convenient to use the :ref:`typed variants <sec_c_api_typed_get>` of this function.
The returned array points to memory that is internally managed by the store
and must not be freed or modified. The pointer is guaranteed to be valid
until :c:func:`kastore_close` is called.
@endrst
@param self A pointer to a kastore object.
@param key The key.
@param key_len The length of the key.
@param array The destination pointer for the array.
@param array_len The destination pointer for the number of elements
in the array.
@param type The destination pointer for the type code of the array.
@return Return 0 on success or a negative value on failure.
*/
int kastore_get(kastore_t *self, const char *key, size_t key_len, void **array,
size_t *array_len, int *type);
/**
@brief Get the array for the specified NULL-terminated key.
@rst
As for :c:func:`kastore_get()` except the key is a NULL-terminated string.
@endrst
@param self A pointer to a kastore object.
@param key The key.
@param array The destination pointer for the array.
@param array_len The destination pointer for the number of elements
in the array.
@param type The destination pointer for the type code of the array.
@return Return 0 on success or a negative value on failure.
*/
int kastore_gets(
kastore_t *self, const char *key, void **array, size_t *array_len, int *type);
/**
@defgroup TYPED_GETS_GROUP Typed get functions.
@{
*/
int kastore_gets_int8(
kastore_t *self, const char *key, int8_t **array, size_t *array_len);
int kastore_gets_uint8(
kastore_t *self, const char *key, uint8_t **array, size_t *array_len);
int kastore_gets_int16(
kastore_t *self, const char *key, int16_t **array, size_t *array_len);
int kastore_gets_uint16(
kastore_t *self, const char *key, uint16_t **array, size_t *array_len);
int kastore_gets_int32(
kastore_t *self, const char *key, int32_t **array, size_t *array_len);
int kastore_gets_uint32(
kastore_t *self, const char *key, uint32_t **array, size_t *array_len);
int kastore_gets_int64(
kastore_t *self, const char *key, int64_t **array, size_t *array_len);
int kastore_gets_uint64(
kastore_t *self, const char *key, uint64_t **array, size_t *array_len);
int kastore_gets_float32(
kastore_t *self, const char *key, float **array, size_t *array_len);
int kastore_gets_float64(
kastore_t *self, const char *key, double **array, size_t *array_len);
/** @} */
/**
@brief Insert the specified key-array pair into the store.
@rst
A key with the specified length is inserted into the store and associated with
an array of the specified type and number of elements. The contents of the
specified key and array are copied unless the KAS_BORROWS_ARRAY flag is specified.
If KAS_BORROWS_ARRAY is specified the array buffer must persist until the
kastore is closed.
Keys can be any sequence of bytes but must be at least one byte long and be
unique. There is no restriction on the contents of arrays. This is the most
general form of ``put`` operation in kastore; when the type of the array
is known and the keys are standard C strings, it is usually more convenient
to use the :ref:`typed variants <sec_c_api_typed_put>` of this function.
@endrst
@param self A pointer to a kastore object.
@param key The key.
@param key_len The length of the key.
@param array The array.
@param array_len The number of elements in the array.
@param type The type of the array.
@param flags The insertion flags, only KAS_BORROWS_ARRAY or 0 is a valid.
@return Return 0 on success or a negative value on failure.
*/
int kastore_put(kastore_t *self, const char *key, size_t key_len, const void *array,
size_t array_len, int type, int flags);
/**
@brief Insert the specified NULL terminated key and array pair into the store.
@rst
As for :c:func:`kastore_put` except the key must be NULL-terminated C string.
@endrst
@param self A pointer to a kastore object.
@param key The key.
@param array The array.
@param array_len The number of elements in the array.
@param type The type of the array.
@param flags The insertion flags, only KAS_BORROWS_ARRAY or 0 is a valid.
@return Return 0 on success or a negative value on failure.
*/
int kastore_puts(kastore_t *self, const char *key, const void *array, size_t array_len,
int type, int flags);
/**
@defgroup TYPED_PUTS_GROUP Typed put functions.
@{
*/
int kastore_puts_int8(
kastore_t *self, const char *key, const int8_t *array, size_t array_len, int flags);
int kastore_puts_uint8(
kastore_t *self, const char *key, const uint8_t *array, size_t array_len, int flags);
int kastore_puts_int16(
kastore_t *self, const char *key, const int16_t *array, size_t array_len, int flags);
int kastore_puts_uint16(kastore_t *self, const char *key, const uint16_t *array,
size_t array_len, int flags);
int kastore_puts_int32(
kastore_t *self, const char *key, const int32_t *array, size_t array_len, int flags);
int kastore_puts_uint32(kastore_t *self, const char *key, const uint32_t *array,
size_t array_len, int flags);
int kastore_puts_int64(
kastore_t *self, const char *key, const int64_t *array, size_t array_len, int flags);
int kastore_puts_uint64(kastore_t *self, const char *key, const uint64_t *array,
size_t array_len, int flags);
int kastore_puts_float32(
kastore_t *self, const char *key, const float *array, size_t array_len, int flags);
int kastore_puts_float64(
kastore_t *self, const char *key, const double *array, size_t array_len, int flags);
/** @} */
/**
@brief Insert the specified key-array pair into the store, transferring ownership
of the malloced array buffer to the store (own-put).
@rst
A key with the specified length is inserted into the store and associated with
an array of the specified type and number of elements. The contents of the
specified key is copied, but the array buffer is taken directly and freed when
the store is closed. The array buffer must be a pointer returned by ``malloc``
or ``calloc``. Ownership of the buffer is not taken unless the function returns
successfully.
Apart from taking ownership of the array buffer, the semantics of this
function are identical to :c:func:`kastore_put`.
@endrst
@param self A pointer to a kastore object.
@param key The key.
@param key_len The length of the key.
@param array The array. Must be a pointer returned by malloc/calloc.
@param array_len The number of elements in the array.
@param type The type of the array.
@param flags The insertion flags. Currently unused.
@return Return 0 on success or a negative value on failure.
*/
int kastore_oput(kastore_t *self, const char *key, size_t key_len, void *array,
size_t array_len, int type, int flags);
/**
@brief Insert the specified NULL terminated key and array pair into the store,
transferring ownership of the malloced array buffer to the store (own-put).
@rst
As for :c:func:`kastore_oput` except the key must be NULL-terminated C string.
@endrst
@param self A pointer to a kastore object.
@param key The key.
@param array The array. Must be a pointer returned by malloc/calloc.
@param array_len The number of elements in the array.
@param type The type of the array.
@param flags The insertion flags. Currently unused.
@return Return 0 on success or a negative value on failure.
*/
int kastore_oputs(kastore_t *self, const char *key, void *array, size_t array_len,
int type, int flags);
/**
@defgroup TYPED_OPUTS_GROUP Typed own-and-put functions.
@{
*/
int kastore_oputs_int8(
kastore_t *self, const char *key, int8_t *array, size_t array_len, int flags);
int kastore_oputs_uint8(
kastore_t *self, const char *key, uint8_t *array, size_t array_len, int flags);
int kastore_oputs_int16(
kastore_t *self, const char *key, int16_t *array, size_t array_len, int flags);
int kastore_oputs_uint16(
kastore_t *self, const char *key, uint16_t *array, size_t array_len, int flags);
int kastore_oputs_int32(
kastore_t *self, const char *key, int32_t *array, size_t array_len, int flags);
int kastore_oputs_uint32(
kastore_t *self, const char *key, uint32_t *array, size_t array_len, int flags);
int kastore_oputs_int64(
kastore_t *self, const char *key, int64_t *array, size_t array_len, int flags);
int kastore_oputs_uint64(
kastore_t *self, const char *key, uint64_t *array, size_t array_len, int flags);
int kastore_oputs_float32(
kastore_t *self, const char *key, float *array, size_t array_len, int flags);
int kastore_oputs_float64(
kastore_t *self, const char *key, double *array, size_t array_len, int flags);
/** @} */
void kastore_print_state(kastore_t *self, FILE *out);
/**
@brief Returns a description of the specified error code.
@param err The error code.
@return String describing the error code.
*/
const char *kas_strerror(int err);
/**
@brief Returns the API version.
@rst
The API follows the `semver convention <https://semver.org/>`_, where the
major, minor and patch numbers have specific meanings. The versioning
scheme here also takes into account ABI compatability.
@endrst
*/
kas_version_t kas_version(void);
#define kas_safe_free(pointer) \
do { \
if (pointer != NULL) { \
free(pointer); \
pointer = NULL; \
} \
} while (0)
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: c/subprojects/kastore/meson.build
================================================
project('kastore', ['c', 'cpp'],
version: files('VERSION.txt'),
default_options: [
'c_std=c99',
'cpp_std=c++11',
'warning_level=3',
'werror=true'])
if not meson.is_subproject()
add_global_arguments([
'-W', '-Wmissing-prototypes', '-Wstrict-prototypes',
'-Wconversion', '-Wshadow', '-Wpointer-arith', '-Wcast-align',
'-Wcast-qual', '-Wwrite-strings', '-Wnested-externs',
'-fshort-enums', '-fno-common'], language : 'c')
endif
# Subprojects should compile in the static library for simplicity.
kastore_inc = include_directories('.')
kastore = static_library('kastore', 'kastore.c')
kastore_dep = declare_dependency(link_with : kastore, include_directories: kastore_inc)
if not meson.is_subproject()
# The shared library can be installed into the system.
install_headers('kastore.h')
shared_library('kastore', 'kastore.c', install: true)
executable('example', ['example.c'], link_with: kastore)
cunit_dep = dependency('cunit')
src_root = meson.project_source_root()
tests_exe = executable('tests', ['tests.c', 'kastore.c'], dependencies: cunit_dep,
c_args: ['-DMESON_VERSION="@0@"'.format(meson.project_version())])
test('tests', tests_exe,
env: ['KAS_TEST_DATA_PREFIX=' + src_root + '/test-data/'])
cpp_tests_exe = executable('cpp_tests', ['cpp_tests.cpp'], link_with: kastore)
test('cpp_tests', cpp_tests_exe)
malloc_tests_exe = executable('malloc_tests', ['malloc_tests.c', 'kastore.c'],
dependencies: cunit_dep,
link_args:['-Wl,--wrap=malloc', '-Wl,--wrap=realloc', '-Wl,--wrap=calloc'])
test('malloc_tests', malloc_tests_exe, workdir: src_root)
io_tests_exe = executable('io_tests', ['io_tests.c', 'kastore.c'],
dependencies: cunit_dep,
link_args:[
'-Wl,--wrap=fwrite',
'-Wl,--wrap=fread',
'-Wl,--wrap=fclose',
'-Wl,--wrap=ftell',
'-Wl,--wrap=fseek'])
test('io_tests', io_tests_exe, workdir: src_root)
endif
================================================
FILE: c/tests/meson-subproject/example.c
================================================
/*
* MIT License
*
* Copyright (c) 2019-2022 Tskit Developers
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* Simple example testing that we compile and link in tskit and kastore
* when we use meson submodules.
*/
#include <stdio.h>
#include <tskit.h>
#include <assert.h>
#include <string.h>
void
test_kas_strerror()
{
printf("test_kas_strerror\n");
const char *str = kas_strerror(KAS_ERR_NO_MEMORY);
assert(strcmp(str, "Out of memory") == 0);
}
void
test_strerror()
{
printf("test_strerror\n");
const char *str = tsk_strerror(TSK_ERR_NO_MEMORY);
assert(strcmp(str, "Out of memory. (TSK_ERR_NO_MEMORY)") == 0);
}
void
test_load_error()
{
printf("test_open_error\n");
tsk_treeseq_t ts;
int ret = tsk_treeseq_load(&ts, "no such file", 0);
assert(ret == TSK_ERR_IO);
tsk_treeseq_free(&ts);
}
void
test_table_basics()
{
printf("test_table_basics\n");
tsk_table_collection_t tables;
int ret = tsk_table_collection_init(&tables, 0);
assert(ret == 0);
ret = tsk_node_table_add_row(&tables.nodes, 0, 1.0, TSK_NULL, TSK_NULL, NULL, 0);
assert(ret == 0);
ret = tsk_node_table_add_row(&tables.nodes, 0, 2.0, TSK_NULL, TSK_NULL, NULL, 0);
assert(ret == 1);
assert(tables.nodes.num_rows == 2);
tsk_table_collection_free(&tables);
}
int
main()
{
test_kas_strerror();
test_strerror();
test_load_error();
test_table_basics();
return 0;
}
================================================
FILE: c/tests/meson-subproject/meson.build
================================================
project('example', 'c')
tskit_proj = subproject('tskit')
tskit_dep = tskit_proj.get_variable('tskit_dep')
executable('example',
'example.c',
dependencies : [tskit_dep],
install : true)
================================================
FILE: c/tests/test_convert.c
================================================
/*
* MIT License
*
* Copyright (c) 2019-2022 Tskit Developers
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "testlib.h"
#include <tskit/convert.h>
#include <unistd.h>
#include <stdlib.h>
static void
test_single_tree_newick(void)
{
int ret;
tsk_treeseq_t ts;
tsk_tree_t t;
size_t buffer_size = 1024;
char newick[buffer_size];
tsk_treeseq_from_text(&ts, 1, single_tree_ex_nodes, single_tree_ex_edges, NULL, NULL,
NULL, NULL, NULL, 0);
ret = tsk_tree_init(&t, &ts, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0)
ret = tsk_tree_first(&t);
CU_ASSERT_EQUAL_FATAL(ret, TSK_TREE_OK)
ret = tsk_convert_newick(&t, 0, 0, TSK_NEWICK_LEGACY_MS_LABELS, buffer_size, newick);
CU_ASSERT_EQUAL_FATAL(ret, 0);
/* Seems odd, but this is what a single node newick tree looks like.
* Newick parsers seems to accept it in any case */
CU_ASSERT_STRING_EQUAL(newick, "1;");
ret = tsk_convert_newick(&t, 0, 0, 0, buffer_size, newick);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_STRING_EQUAL(newick, "n0;");
ret = tsk_convert_newick(&t, 4, 0, TSK_NEWICK_LEGACY_MS_LABELS, buffer_size, newick);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_STRING_EQUAL(newick, "(1:1,2:1);");
ret = tsk_convert_newick(&t, 4, 0, 0, buffer_size, newick);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_STRING_EQUAL(newick, "(n0:1,n1:1);");
ret = tsk_convert_newick(&t, 6, 0, TSK_NEWICK_LEGACY_MS_LABELS, buffer_size, newick);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_STRING_EQUAL(newick, "((1:1,2:1):2,(3:2,4:2):1);");
ret = tsk_convert_newick(&t, 6, 0, 0, buffer_size, newick);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_STRING_EQUAL(newick, "((n0:1,n1:1):2,(n2:2,n3:2):1);");
tsk_tree_free(&t);
tsk_treeseq_free(&ts);
}
static void
test_single_tree_newick_errors(void)
{
int ret;
tsk_treeseq_t ts;
tsk_tree_t t;
size_t j, len;
size_t buffer_size = 1024;
char newick[buffer_size];
tsk_treeseq_from_text(&ts, 1, single_tree_ex_nodes, single_tree_ex_edges, NULL, NULL,
NULL, NULL, NULL, 0);
ret = tsk_tree_init(&t, &ts, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0)
ret = tsk_tree_first(&t);
CU_ASSERT_EQUAL_FATAL(ret, TSK_TREE_OK)
ret = tsk_convert_newick(&t, -1, 1, 0, buffer_size, newick);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_NODE_OUT_OF_BOUNDS);
ret = tsk_convert_newick(&t, 7, 1, 0, buffer_size, newick);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_NODE_OUT_OF_BOUNDS);
ret = tsk_convert_newick(&t, 6, 0, 0, buffer_size, NULL);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BAD_PARAM_VALUE);
ret = tsk_convert_newick(&t, 6, 0, 0, buffer_size, newick);
CU_ASSERT_EQUAL_FATAL(ret, 0);
len = 1 + strlen(newick);
for (j = 0; j < len; j++) {
ret = tsk_convert_newick(&t, 6, 0, 0, j, newick);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BUFFER_OVERFLOW);
}
ret = tsk_convert_newick(&t, 6, 0, TSK_NEWICK_LEGACY_MS_LABELS, len, newick);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_STRING_EQUAL(newick, "((1:1,2:1):2,(3:2,4:2):1);");
tsk_tree_free(&t);
tsk_treeseq_free(&ts);
}
int
main(int argc, char **argv)
{
CU_TestInfo tests[] = {
{ "test_single_tree_newick", test_single_tree_newick },
{ "test_single_tree_newick_errors", test_single_tree_newick_errors },
{ NULL, NULL },
};
return test_main(tests, argc, argv);
}
================================================
FILE: c/tests/test_core.c
================================================
/*
* MIT License
*
* Copyright (c) 2019-2024 Tskit Developers
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "testlib.h"
#include <tskit/core.h>
#include <math.h>
#include <string.h>
#include <unistd.h>
static void
test_strerror(void)
{
int j;
const char *msg;
int max_error_code = 8192; /* totally arbitrary */
for (j = 0; j < max_error_code; j++) {
msg = tsk_strerror(-j);
CU_ASSERT_FATAL(msg != NULL);
CU_ASSERT(strlen(msg) > 0);
}
CU_ASSERT_STRING_EQUAL(
tsk_strerror(0), "Normal exit condition. This is not an error!");
}
static void
test_strerror_kastore(void)
{
int kastore_errors[]
= { KAS_ERR_NO_MEMORY, KAS_ERR_KEY_NOT_FOUND, KAS_ERR_BAD_FILE_FORMAT };
size_t j;
int err;
for (j = 0; j < sizeof(kastore_errors) / sizeof(*kastore_errors); j++) {
err = tsk_set_kas_error(kastore_errors[j]);
CU_ASSERT_TRUE(tsk_is_kas_error(err));
CU_ASSERT_EQUAL_FATAL(tsk_get_kas_error(err), kastore_errors[j]);
CU_ASSERT_STRING_EQUAL(tsk_strerror(err), kas_strerror(kastore_errors[j]));
}
}
static void
test_generate_uuid(void)
{
size_t uuid_size = 36;
char uuid[uuid_size + 1];
char other_uuid[uuid_size + 1];
int ret;
ret = tsk_generate_uuid(uuid, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_EQUAL_FATAL(strlen(uuid), uuid_size);
CU_ASSERT_EQUAL(uuid[8], '-');
CU_ASSERT_EQUAL(uuid[13], '-');
CU_ASSERT_EQUAL(uuid[18], '-');
CU_ASSERT_EQUAL(uuid[23], '-');
ret = tsk_generate_uuid(other_uuid, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_EQUAL_FATAL(strlen(other_uuid), uuid_size);
CU_ASSERT_STRING_NOT_EQUAL(uuid, other_uuid);
}
static void
test_double_round(void)
{
struct test_case {
double source;
unsigned int num_digits;
double result;
};
struct test_case test_cases[] = {
{ 1.555, 3, 1.555 },
{ 1.5555, 2, 1.56 },
/* catch the halfway between integers case */
{ 1.5555, 3, 1.556 },
{ 1.5111, 3, 1.511 },
{ 1.5112, 3, 1.511 },
{ 3.141592653589793, 0, 3.0 },
{ 3.141592653589793, 1, 3.1 },
{ 3.141592653589793, 2, 3.14 },
{ 3.141592653589793, 3, 3.142 },
{ 3.141592653589793, 4, 3.1416 },
{ 3.141592653589793, 5, 3.14159 },
{ 3.141592653589793, 6, 3.141593 },
{ 3.141592653589793, 7, 3.1415927 },
{ 3.141592653589793, 8, 3.14159265 },
{ 3.141592653589793, 9, 3.141592654 },
{ 3.141592653589793, 10, 3.1415926536 },
{ 3.141592653589793, 11, 3.14159265359 },
{ 3.141592653589793, 12, 3.14159265359 },
{ 3.141592653589793, 13, 3.1415926535898 },
{ 3.141592653589793, 14, 3.14159265358979 },
{ 3.141592653589793, 15, 3.141592653589793 },
{ 3.141592653589793, 16, 3.141592653589793 },
{ 3.141592653589793, 17, 3.141592653589793 },
{ 3.141592653589793, 18, 3.141592653589793 },
{ 3.141592653589793, 19, 3.141592653589793 },
/* We have tiny differences in precision at k=20; not worth worrying about. */
{ 3.141592653589793, 21, 3.141592653589793 },
{ 3.141592653589793, 22, 3.141592653589793 },
{ 3.141592653589793, 23, 3.141592653589793 },
{ 0.3333333333333333, 0, 0.0 },
{ 0.3333333333333333, 1, 0.3 },
{ 0.3333333333333333, 2, 0.33 },
{ 0.3333333333333333, 3, 0.333 },
{ 0.3333333333333333, 4, 0.3333 },
{ 0.3333333333333333, 5, 0.33333 },
{ 0.3333333333333333, 6, 0.333333 },
{ 0.3333333333333333, 7, 0.3333333 },
{ 0.3333333333333333, 8, 0.33333333 },
{ 0.3333333333333333, 9, 0.333333333 },
{ 0.3333333333333333, 10, 0.3333333333 },
{ 0.3333333333333333, 11, 0.33333333333 },
{ 0.3333333333333333, 12, 0.333333333333 },
{ 0.3333333333333333, 13, 0.3333333333333 },
{ 0.3333333333333333, 14, 0.33333333333333 },
{ 0.3333333333333333, 15, 0.333333333333333 },
{ 0.3333333333333333, 16, 0.3333333333333333 },
{ 0.3333333333333333, 17, 0.3333333333333333 },
{ 0.3333333333333333, 18, 0.3333333333333333 },
{ 0.3333333333333333, 19, 0.3333333333333333 },
{ 0.3333333333333333, 20, 0.3333333333333333 },
{ 0.3333333333333333, 21, 0.3333333333333333 },
{ 0.3333333333333333, 22, 0.3333333333333333 },
{ 0.3333333333333333, 23, 0.3333333333333333 },
{ 0.6666666666666666, 0, 1.0 },
{ 0.6666666666666666, 1, 0.7 },
{ 0.6666666666666666, 2, 0.67 },
{ 0.6666666666666666, 3, 0.667 },
{ 0.6666666666666666, 4, 0.6667 },
{ 0.6666666666666666, 5, 0.66667 },
{ 0.6666666666666666, 6, 0.666667 },
{ 0.6666666666666666, 7, 0.6666667 },
{ 0.6666666666666666, 8, 0.66666667 },
{ 0.6666666666666666, 9, 0.666666667 },
{ 0.6666666666666666, 10, 0.6666666667 },
{ 0.6666666666666666, 11, 0.66666666667 },
{ 0.6666666666666666, 12, 0.666666666667 },
{ 0.6666666666666666, 13, 0.6666666666667 },
{ 0.6666666666666666, 14, 0.66666666666667 },
{ 0.6666666666666666, 15, 0.666666666666667 },
{ 0.6666666666666666, 16, 0.6666666666666666 },
{ 0.6666666666666666, 17, 0.6666666666666666 },
{ 0.6666666666666666, 18, 0.6666666666666666 },
{ 0.6666666666666666, 19, 0.6666666666666666 },
{ 0.6666666666666666, 20, 0.6666666666666666 },
{ 0.6666666666666666, 21, 0.6666666666666666 },
{ 0.6666666666666666, 22, 0.6666666666666666 },
{ 0.6666666666666666, 23, 0.6666666666666666 },
{ 0.07692307692307693, 0, 0.0 },
{ 0.07692307692307693, 1, 0.1 },
{ 0.07692307692307693, 2, 0.08 },
{ 0.07692307692307693, 3, 0.077 },
{ 0.07692307692307693, 4, 0.0769 },
{ 0.07692307692307693, 5, 0.07692 },
{ 0.07692307692307693, 6, 0.076923 },
{ 0.07692307692307693, 7, 0.0769231 },
{ 0.07692307692307693, 8, 0.07692308 },
{ 0.07692307692307693, 9, 0.076923077 },
{ 0.07692307692307693, 10, 0.0769230769 },
{ 0.07692307692307693, 11, 0.07692307692 },
{ 0.07692307692307693, 12, 0.076923076923 },
{ 0.07692307692307693, 13, 0.0769230769231 },
{ 0.07692307692307693, 14, 0.07692307692308 },
{ 0.07692307692307693, 15, 0.076923076923077 },
{ 0.07692307692307693, 16, 0.0769230769230769 },
{ 0.07692307692307693, 17, 0.07692307692307693 },
{ 0.07692307692307693, 18, 0.07692307692307693 },
{ 0.07692307692307693, 19, 0.07692307692307693 },
{ 0.07692307692307693, 20, 0.07692307692307693 },
/* Tiny difference in precision at k=21 */
{ 0.07692307692307693, 22, 0.07692307692307693 },
{ 0.07692307692307693, 23, 0.07692307692307693 },
{ 1e-21, 0, 0.0 },
{ 1e-21, 1, 0.0 },
{ 1e-21, 2, 0.0 },
{ 1e-21, 3, 0.0 },
{ 1e-21, 4, 0.0 },
{ 1e-21, 5, 0.0 },
{ 1e-21, 6, 0.0 },
{ 1e-21, 7, 0.0 },
{ 1e-21, 8, 0.0 },
{ 1e-21, 9, 0.0 },
{ 1e-21, 10, 0.0 },
{ 1e-21, 11, 0.0 },
{ 1e-21, 12, 0.0 },
{ 1e-21, 13, 0.0 },
{ 1e-21, 14, 0.0 },
{ 1e-21, 15, 0.0 },
{ 1e-21, 16, 0.0 },
{ 1e-21, 17, 0.0 },
{ 1e-21, 18, 0.0 },
{ 1e-21, 19, 0.0 },
{ 1e-21, 20, 0.0 },
{ 1e-21, 21, 1e-21 },
{ 1e-21, 22, 1e-21 },
{ 1e-21, 23, 1e-21 },
{ 1e-10, 0, 0.0 },
{ 1e-10, 1, 0.0 },
{ 1e-10, 2, 0.0 },
{ 1e-10, 3, 0.0 },
{ 1e-10, 4, 0.0 },
{ 1e-10, 5, 0.0 },
{ 1e-10, 6, 0.0 },
{ 1e-10, 7, 0.0 },
{ 1e-10, 8, 0.0 },
{ 1e-10, 9, 0.0 },
{ 1e-10, 10, 1e-10 },
{ 1e-10, 11, 1e-10 },
{ 1e-10, 12, 1e-10 },
{ 1e-10, 13, 1e-10 },
{ 1e-10, 14, 1e-10 },
{ 1e-10, 15, 1e-10 },
{ 1e-10, 16, 1e-10 },
{ 1e-10, 17, 1e-10 },
{ 1e-10, 18, 1e-10 },
{ 1e-10, 19, 1e-10 },
{ 1e-10, 20, 1e-10 },
{ 1e-10, 21, 1e-10 },
{ 1e-10, 22, 1e-10 },
{ 1e-10, 23, 1e-10 },
{ 3.141592653589793e-08, 0, 0.0 },
{ 3.141592653589793e-08, 1, 0.0 },
{ 3.141592653589793e-08, 2, 0.0 },
{ 3.141592653589793e-08, 3, 0.0 },
{ 3.141592653589793e-08, 4, 0.0 },
{ 3.141592653589793e-08, 5, 0.0 },
{ 3.141592653589793e-08, 6, 0.0 },
{ 3.141592653589793e-08, 7, 0.0 },
{ 3.141592653589793e-08, 8, 3e-08 },
{ 3.141592653589793e-08, 9, 3.1e-08 },
{ 3.141592653589793e-08, 10, 3.14e-08 },
{ 3.141592653589793e-08, 11, 3.142e-08 },
{ 3.141592653589793e-08, 12, 3.1416e-08 },
{ 3.141592653589793e-08, 13, 3.14159e-08 },
{ 3.141592653589793e-08, 14, 3.141593e-08 },
{ 3.141592653589793e-08, 15, 3.1415927e-08 },
{ 3.141592653589793e-08, 16, 3.14159265e-08 },
{ 3.141592653589793e-08, 17, 3.141592654e-08 },
{ 3.141592653589793e-08, 18, 3.1415926536e-08 },
{ 3.141592653589793e-08, 19, 3.14159265359e-08 },
{ 3.141592653589793e-08, 20, 3.14159265359e-08 },
{ 3.141592653589793e-08, 21, 3.1415926535898e-08 },
/* Tiny precision mismatch at k=22 */
{ 3.141592653589793e-08, 23, 3.141592653589793e-08 },
};
size_t num_test_cases = sizeof(test_cases) / sizeof(*test_cases);
size_t j;
for (j = 0; j < num_test_cases; j++) {
CU_ASSERT_EQUAL_FATAL(tsk_round(test_cases[j].source, test_cases[j].num_digits),
test_cases[j].result);
}
}
static void
test_blkalloc(void)
{
tsk_blkalloc_t alloc;
int ret;
size_t j, block_size;
void *mem;
ret = tsk_blkalloc_init(&alloc, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BAD_PARAM_VALUE);
tsk_blkalloc_free(&alloc);
for (block_size = 1; block_size < 10; block_size++) {
ret = tsk_blkalloc_init(&alloc, block_size);
CU_ASSERT_EQUAL_FATAL(ret, 0);
for (j = 0; j < 10; j++) {
mem = tsk_blkalloc_get(&alloc, block_size);
CU_ASSERT_TRUE(mem != NULL);
CU_ASSERT_EQUAL(alloc.num_chunks, j + 1);
tsk_memset(mem, 0, block_size);
}
mem = tsk_blkalloc_get(&alloc, block_size + 1);
CU_ASSERT_EQUAL(mem, NULL);
mem = tsk_blkalloc_get(&alloc, block_size + 2);
CU_ASSERT_EQUAL(mem, NULL);
tsk_blkalloc_print_state(&alloc, _devnull);
tsk_blkalloc_free(&alloc);
}
/* Allocate awkward sized chunk */
ret = tsk_blkalloc_init(&alloc, 100);
CU_ASSERT_EQUAL_FATAL(ret, 0);
mem = tsk_blkalloc_get(&alloc, 90);
CU_ASSERT_FATAL(mem != NULL);
tsk_memset(mem, 0, 90);
mem = tsk_blkalloc_get(&alloc, 10);
CU_ASSERT_FATAL(mem != NULL);
tsk_memset(mem, 0, 10);
CU_ASSERT_EQUAL(alloc.num_chunks, 1);
mem = tsk_blkalloc_get(&alloc, 90);
CU_ASSERT_FATAL(mem != NULL);
tsk_memset(mem, 0, 90);
CU_ASSERT_EQUAL(alloc.num_chunks, 2);
mem = tsk_blkalloc_get(&alloc, 11);
CU_ASSERT_FATAL(mem != NULL);
tsk_memset(mem, 0, 11);
CU_ASSERT_EQUAL(alloc.num_chunks, 3);
tsk_blkalloc_free(&alloc);
}
static void
test_unknown_time(void)
{
CU_ASSERT_TRUE(tsk_isnan(TSK_UNKNOWN_TIME));
CU_ASSERT_TRUE(tsk_is_unknown_time(TSK_UNKNOWN_TIME));
CU_ASSERT_FALSE(tsk_is_unknown_time(NAN));
CU_ASSERT_FALSE(tsk_is_unknown_time(0));
CU_ASSERT_FALSE(tsk_is_unknown_time(INFINITY));
CU_ASSERT_FALSE(tsk_is_unknown_time(1));
}
static void
test_malloc_zero(void)
{
void *p = tsk_malloc(0);
CU_ASSERT_FATAL(p != NULL);
free(p);
p = tsk_calloc(0, 1);
CU_ASSERT_FATAL(p != NULL);
free(p);
}
static void
test_malloc_overflow(void)
{
#if TSK_MAX_SIZE > SIZE_MAX
tsk_size_t size_max = SIZE_MAX;
void *p = tsk_malloc(size_max + 1);
CU_ASSERT_FATAL(p == NULL);
p = tsk_calloc(size_max + 1, 1);
CU_ASSERT_FATAL(p == NULL);
#endif
}
static void
test_debug_stream(void)
{
FILE *f = fopen(_tmp_file_name, "w");
CU_ASSERT_FATAL(tsk_get_debug_stream() == stdout);
CU_ASSERT_FATAL(tsk_get_debug_stream() == stdout);
tsk_set_debug_stream(f);
CU_ASSERT_FATAL(tsk_get_debug_stream() == f);
tsk_set_debug_stream(stdout);
CU_ASSERT_FATAL(tsk_get_debug_stream() == stdout);
fclose(f);
}
static int
validate_avl_node(tsk_avl_node_int_t *node)
{
int height, lheight, rheight;
if (node == NULL) {
return 0;
}
lheight = validate_avl_node(node->llink);
rheight = validate_avl_node(node->rlink);
height = 1 + TSK_MAX(lheight, rheight);
if (lheight != 0 && rheight != 0) {
CU_ASSERT_FATAL(node->balance == rheight - lheight);
} else if (lheight == 0 && rheight == 0) {
CU_ASSERT_FATAL(height == 1);
CU_ASSERT_FATAL(node->balance == 0);
} else {
CU_ASSERT_FATAL(height == 2);
if (lheight == 0) {
CU_ASSERT_FATAL(node->balance == 1);
} else {
CU_ASSERT_FATAL(node->balance == -1);
}
}
return height;
}
static void
test_avl_empty(void)
{
int height;
tsk_avl_tree_int_t tree;
tsk_avl_tree_int_init(&tree);
height = validate_avl_node(tree.head.rlink);
CU_ASSERT_EQUAL((tsk_size_t) height, tree.height);
CU_ASSERT_EQUAL(0, tree.size);
tsk_avl_tree_int_print_state(&tree, _devnull);
CU_ASSERT_EQUAL(tsk_avl_tree_int_search(&tree, -1), NULL);
CU_ASSERT_EQUAL(tsk_avl_tree_int_search(&tree, 0), NULL);
CU_ASSERT_EQUAL(tsk_avl_tree_int_search(&tree, 1), NULL);
tsk_avl_tree_int_free(&tree);
}
static void
validate_avl(size_t num_keys, int64_t *keys)
{
size_t j, k;
int ret, height;
tsk_avl_tree_int_t tree;
tsk_avl_node_int_t *nodes = malloc(num_keys * sizeof(*nodes));
tsk_avl_node_int_t **ordered_nodes = malloc(num_keys * sizeof(*ordered_nodes));
tsk_avl_node_int_t *node;
tsk_avl_node_int_t tmp_node;
CU_ASSERT_FATAL(nodes != NULL);
CU_ASSERT_FATAL(ordered_nodes != NULL);
tsk_avl_tree_int_init(&tree);
/* Assumes the keys are unique */
for (j = 0; j < num_keys; j++) {
node = nodes + j;
node->key = keys[j];
CU_ASSERT_EQUAL(tsk_avl_tree_int_search(&tree, keys[j]), NULL);
ret = tsk_avl_tree_int_insert(&tree, node);
CU_ASSERT_FATAL(ret == 0);
CU_ASSERT_EQUAL(tsk_avl_tree_int_search(&tree, keys[j]), node);
tmp_node.key = keys[j];
ret = tsk_avl_tree_int_insert(&tree, &tmp_node);
CU_ASSERT_FATAL(ret == 1);
height = validate_avl_node(tree.head.rlink);
CU_ASSERT_EQUAL((tsk_size_t) height, tree.height);
CU_ASSERT_EQUAL(j + 1, tree.size);
tsk_avl_tree_int_print_state(&tree, _devnull);
for (k = j + 1; k < num_keys; k++) {
CU_ASSERT_EQUAL(tsk_avl_tree_int_search(&tree, keys[k]), NULL);
}
}
tsk_avl_tree_int_ordered_nodes(&tree, ordered_nodes);
for (j = 0; j < num_keys; j++) {
if (j > 0) {
CU_ASSERT_FATAL(ordered_nodes[j - 1]->key < ordered_nodes[j]->key);
}
}
tsk_avl_tree_int_free(&tree);
free(nodes);
free(ordered_nodes);
}
static void
test_avl_sequential(void)
{
int64_t keys[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
int64_t reversed_keys[] = { 7, 6, 5, 4, 3, 2, 1, 0 };
validate_avl(8, keys);
validate_avl(8, reversed_keys);
}
static void
test_avl_interleaved(void)
{
size_t num_keys = 100;
size_t j;
int64_t *keys = malloc(num_keys * sizeof(*keys));
CU_ASSERT_FATAL(keys != NULL);
for (j = 0; j < num_keys; j++) {
keys[j] = (int64_t) j;
if (j % 2 == 0) {
keys[j] *= -1;
}
}
validate_avl(num_keys, keys);
free(keys);
}
static void
test_avl_random(void)
{
/* This example goes through all the code paths in the AVL insert algorithm */
int64_t keys[] = { 2, 79, -8, -86, 6, -29, 88, -80, 21, -26, -13, 16, -1, 3, 51, 30,
49, -48, -99, 57, -63, 29, 91, 87, 60, -43, -79, -12, -52, -42, 69, 89, 74, -50,
7, -46, -37, 34, -28, 66, -83, 31, -41, -87, -92, -11, -17, -9, 10, 98, 71, -93,
-66, -20, 63, -51, 33, -47, 5, -97, 90, 45, -57, 61, -6, -53, 99, -61, -19, -77,
53, 23, -60, 56, -56, -36, -30, 28, 35, -38, 38, 62, -68, 22, -96, -73, -89,
50 };
validate_avl(sizeof(keys) / sizeof(*keys), keys);
}
static void
test_bit_arrays(void)
{
// NB: This test is only valid for the 32 bit implementation of bit arrays. If we
// were to change the chunk size of a bit array, we'd need to update these tests
tsk_bitset_t arr;
tsk_id_t items_truth[64] = { 0 }, items[64] = { 0 };
tsk_size_t n_items = 0, n_items_truth = 0;
// test item retrieval
tsk_bitset_init(&arr, 90, 1);
CU_ASSERT_EQUAL_FATAL(arr.len, 1);
CU_ASSERT_EQUAL_FATAL(arr.row_len, 3);
tsk_bitset_get_items(&arr, 0, items, &n_items);
assert_arrays_equal(n_items_truth, items, items_truth);
for (tsk_bitset_val_t i = 0; i < 20; i++) {
tsk_bitset_set_bit(&arr, 0, i);
items_truth[n_items_truth] = (tsk_id_t) i;
n_items_truth++;
}
tsk_bitset_set_bit(&arr, 0, 63);
tsk_bitset_set_bit(&arr, 0, 65);
// these assertions are only valid for 32-bit values
CU_ASSERT_EQUAL_FATAL(arr.data[0], 1048575);
CU_ASSERT_EQUAL_FATAL(arr.data[1], 2147483648);
CU_ASSERT_EQUAL_FATAL(arr.data[2], 2);
// verify our assumptions about bit array counting
CU_ASSERT_EQUAL_FATAL(tsk_bitset_count(&arr, 0), 22);
tsk_bitset_get_items(&arr, 0, items, &n_items);
assert_arrays_equal(n_items_truth, items, items_truth);
tsk_memset(items, 0, 64);
tsk_memset(items_truth, 0, 64);
n_items = n_items_truth = 0;
tsk_bitset_free(&arr);
// create a length-2 array with 64 bit capacity (two chunks per row)
tsk_bitset_init(&arr, 64, 2);
CU_ASSERT_EQUAL_FATAL(arr.len, 2);
CU_ASSERT_EQUAL_FATAL(arr.row_len, 2);
// fill the first 50 bits of the first row
for (tsk_bitset_val_t i = 0; i < 50; i++) {
tsk_bitset_set_bit(&arr, 0, i);
items_truth[n_items_truth] = (tsk_id_t) i;
n_items_truth++;
}
tsk_bitset_get_items(&arr, 0, items, &n_items);
assert_arrays_equal(n_items_truth, items, items_truth);
tsk_memset(items, 0, 64);
tsk_memset(items_truth, 0, 64);
n_items = n_items_truth = 0;
// fill bits 20-40 of the second row
for (tsk_bitset_val_t i = 20; i < 40; i++) {
tsk_bitset_set_bit(&arr, 1, i);
items_truth[n_items_truth] = (tsk_id_t) i;
n_items_truth++;
}
tsk_bitset_get_items(&arr, 1, items, &n_items);
assert_arrays_equal(n_items_truth, items, items_truth);
tsk_memset(items, 0, 64);
tsk_memset(items_truth, 0, 64);
n_items = n_items_truth = 0;
// verify our assumptions about row selection
CU_ASSERT_EQUAL_FATAL(arr.data[0], 4294967295); // row1 elem1
CU_ASSERT_EQUAL_FATAL(arr.data[1], 262143); // row1 elem2
CU_ASSERT_EQUAL_FATAL(arr.data[2], 4293918720); // row2 elem1
CU_ASSERT_EQUAL_FATAL(arr.data[3], 255); // row2 elem2
// subtract the second from the first row, store in first
tsk_bitset_subtract(&arr, 0, &arr, 1);
// verify our assumptions about subtraction
CU_ASSERT_EQUAL_FATAL(arr.data[0], 1048575);
CU_ASSERT_EQUAL_FATAL(arr.data[1], 261888);
tsk_bitset_t int_result;
tsk_bitset_init(&int_result, 64, 1);
CU_ASSERT_EQUAL_FATAL(int_result.len, 1);
CU_ASSERT_EQUAL_FATAL(int_result.row_len, 2);
// their intersection should be zero
tsk_bitset_intersect(&arr, 0, &arr, 1, &int_result);
CU_ASSERT_EQUAL_FATAL(int_result.data[0], 0);
CU_ASSERT_EQUAL_FATAL(int_result.data[1], 0);
// now, add them back together, storing back in a
tsk_bitset_union(&arr, 0, &arr, 1);
// now, their intersection should be the subtracted chunk (20-40)
tsk_bitset_intersect(&arr, 0, &arr, 1, &int_result);
CU_ASSERT_EQUAL_FATAL(int_result.data[0], 4293918720);
CU_ASSERT_EQUAL_FATAL(int_result.data[1], 255);
tsk_bitset_free(&int_result);
tsk_bitset_free(&arr);
}
static void
test_meson_version(void)
{
char version[100];
sprintf(
version, "%d.%d.%d", TSK_VERSION_MAJOR, TSK_VERSION_MINOR, TSK_VERSION_PATCH);
/* the MESON_PROJECT_VERSION define is passed in by meson when compiling */
CU_ASSERT_STRING_EQUAL(version, MESON_PROJECT_VERSION);
}
int
main(int argc, char **argv)
{
CU_TestInfo tests[] = {
{ "test_strerror", test_strerror },
{ "test_strerror_kastore", test_strerror_kastore },
{ "test_generate_uuid", test_generate_uuid },
{ "test_double_round", test_double_round },
{ "test_blkalloc", test_blkalloc },
{ "test_unknown_time", test_unknown_time },
{ "test_malloc_zero", test_malloc_zero },
{ "test_malloc_overflow", test_malloc_overflow },
{ "test_debug_stream", test_debug_stream },
{ "test_avl_empty", test_avl_empty },
{ "test_avl_sequential", test_avl_sequential },
{ "test_avl_interleaved", test_avl_interleaved },
{ "test_avl_random", test_avl_random },
{ "test_bit_arrays", test_bit_arrays },
{ "test_meson_version", test_meson_version },
{ NULL, NULL },
};
return test_main(tests, argc, argv);
}
================================================
FILE: c/tests/test_file_format.c
================================================
/*
* MIT License
*
* Copyright (c) 2019-2022 Tskit Developers
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, mergetest, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "testlib.h"
#include <tskit/tables.h>
typedef struct {
const char *name;
void *array;
tsk_size_t len;
int type;
} write_table_col_t;
static void
write_table_cols(kastore_t *store, write_table_col_t *write_cols, size_t num_cols)
{
size_t j;
int ret;
for (j = 0; j < num_cols; j++) {
ret = kastore_puts(store, write_cols[j].name, write_cols[j].array,
(size_t) write_cols[j].len, write_cols[j].type, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
}
}
static void
copy_store_drop_columns(
tsk_treeseq_t *ts, size_t num_drop_cols, const char **drop_cols, const char *outfile)
{
int ret = 0;
char tmpfile[] = "/tmp/tsk_c_test_copy_XXXXXX";
int fd;
kastore_t read_store, write_store;
kaitem_t *item;
size_t j, k;
bool keep;
fd = mkstemp(tmpfile);
CU_ASSERT_FATAL(fd != -1);
close(fd);
ret = tsk_treeseq_dump(ts, tmpfile, 0);
if (ret != 0) {
unlink(tmpfile);
CU_ASSERT_EQUAL_FATAL(ret, 0);
}
ret = kastore_open(&read_store, tmpfile, "r", KAS_READ_ALL);
/* We can now unlink the file as either kastore has read it all, or failed */
unlink(tmpfile);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_open(&write_store, outfile, "w", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
/* Note: this API is not a documented part of kastore, so may be subject to
* change. */
for (j = 0; j < read_store.num_items; j++) {
item = &read_store.items[j];
keep = true;
for (k = 0; k < num_drop_cols; k++) {
if (strlen(drop_cols[k]) == item->key_len
&& strncmp(drop_cols[k], item->key, item->key_len) == 0) {
keep = false;
break;
}
}
if (keep) {
ret = kastore_put(&write_store, item->key, item->key_len, item->array,
item->array_len, item->type, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
}
}
kastore_close(&read_store);
ret = kastore_close(&write_store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
}
static void
test_format_data_load_errors(void)
{
size_t uuid_size = 36;
char uuid[uuid_size];
char format_name[TSK_FILE_FORMAT_NAME_LENGTH];
double L[2];
uint32_t version[2]
= { TSK_FILE_FORMAT_VERSION_MAJOR, TSK_FILE_FORMAT_VERSION_MINOR };
write_table_col_t write_cols[] = {
{ "format/name", (void *) format_name, sizeof(format_name), KAS_INT8 },
{ "format/version", (void *) version, 2, KAS_UINT32 },
{ "sequence_length", (void *) L, 1, KAS_FLOAT64 },
{ "uuid", (void *) uuid, (tsk_size_t) uuid_size, KAS_INT8 },
};
tsk_table_collection_t tables;
kastore_t store;
size_t j;
int ret;
L[0] = 1;
L[1] = 0;
tsk_memcpy(format_name, TSK_FILE_FORMAT_NAME, sizeof(format_name));
/* Note: this will fail if we ever start parsing the form of the UUID */
tsk_memset(uuid, 0, uuid_size);
ret = kastore_open(&store, _tmp_file_name, "w", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
write_table_cols(&store, write_cols, sizeof(write_cols) / sizeof(*write_cols));
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_table_collection_load(&tables, _tmp_file_name, 0);
/* We've only defined the format headers, so we should fail immediately
* after with required columns not found */
CU_ASSERT_FALSE(tsk_is_kas_error(ret));
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_REQUIRED_COL_NOT_FOUND);
ret = tsk_table_collection_free(&tables);
CU_ASSERT_EQUAL_FATAL(ret, 0);
/* Version too old */
version[0] = TSK_FILE_FORMAT_VERSION_MAJOR - 1;
ret = kastore_open(&store, _tmp_file_name, "w", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
write_table_cols(&store, write_cols, sizeof(write_cols) / sizeof(*write_cols));
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_table_collection_load(&tables, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_FILE_VERSION_TOO_OLD);
ret = tsk_table_collection_free(&tables);
CU_ASSERT_EQUAL_FATAL(ret, 0);
/* Version too new */
version[0] = TSK_FILE_FORMAT_VERSION_MAJOR + 1;
ret = kastore_open(&store, _tmp_file_name, "w", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
write_table_cols(&store, write_cols, sizeof(write_cols) / sizeof(*write_cols));
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_table_collection_load(&tables, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_FILE_VERSION_TOO_NEW);
ret = tsk_table_collection_free(&tables);
CU_ASSERT_EQUAL_FATAL(ret, 0);
version[0] = TSK_FILE_FORMAT_VERSION_MAJOR;
/* Bad version length */
write_cols[1].len = 0;
ret = kastore_open(&store, _tmp_file_name, "w", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
write_table_cols(&store, write_cols, sizeof(write_cols) / sizeof(*write_cols));
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_table_collection_load(&tables, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_FILE_FORMAT);
ret = tsk_table_collection_free(&tables);
CU_ASSERT_EQUAL_FATAL(ret, 0);
write_cols[1].len = 2;
/* Bad format name length */
write_cols[0].len = 0;
ret = kastore_open(&store, _tmp_file_name, "w", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
write_table_cols(&store, write_cols, sizeof(write_cols) / sizeof(*write_cols));
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_table_collection_load(&tables, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_FILE_FORMAT);
ret = tsk_table_collection_free(&tables);
CU_ASSERT_EQUAL_FATAL(ret, 0);
write_cols[0].len = TSK_FILE_FORMAT_NAME_LENGTH;
/* Bad format name */
format_name[0] = 'X';
ret = kastore_open(&store, _tmp_file_name, "w", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
write_table_cols(&store, write_cols, sizeof(write_cols) / sizeof(*write_cols));
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_table_collection_load(&tables, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_FILE_FORMAT);
ret = tsk_table_collection_free(&tables);
CU_ASSERT_EQUAL_FATAL(ret, 0);
format_name[0] = 't';
/* Bad type for sequence length. */
write_cols[2].type = KAS_FLOAT32;
ret = kastore_open(&store, _tmp_file_name, "w", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
write_table_cols(&store, write_cols, sizeof(write_cols) / sizeof(*write_cols));
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_table_collection_load(&tables, _tmp_file_name, 0);
CU_ASSERT_TRUE(tsk_is_kas_error(ret));
CU_ASSERT_EQUAL_FATAL(ret ^ (1 << TSK_KAS_ERR_BIT), KAS_ERR_TYPE_MISMATCH);
ret = tsk_table_collection_free(&tables);
CU_ASSERT_EQUAL_FATAL(ret, 0);
write_cols[2].type = KAS_FLOAT64;
/* Bad length for sequence length. */
write_cols[2].len = 2;
ret = kastore_open(&store, _tmp_file_name, "w", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
write_table_cols(&store, write_cols, sizeof(write_cols) / sizeof(*write_cols));
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_table_collection_load(&tables, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_FILE_FORMAT);
ret = tsk_table_collection_free(&tables);
CU_ASSERT_EQUAL_FATAL(ret, 0);
write_cols[2].len = 1;
/* Bad value for sequence length. */
L[0] = -1;
ret = kastore_open(&store, _tmp_file_name, "w", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
write_table_cols(&store, write_cols, sizeof(write_cols) / sizeof(*write_cols));
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_table_collection_load(&tables, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BAD_SEQUENCE_LENGTH);
ret = tsk_table_collection_free(&tables);
CU_ASSERT_EQUAL_FATAL(ret, 0);
L[0] = 1;
/* Wrong length for uuid */
write_cols[3].len = 1;
ret = kastore_open(&store, _tmp_file_name, "w", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
write_table_cols(&store, write_cols, sizeof(write_cols) / sizeof(*write_cols));
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_table_collection_load(&tables, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_FILE_FORMAT);
ret = tsk_table_collection_free(&tables);
CU_ASSERT_EQUAL_FATAL(ret, 0);
write_cols[3].len = (tsk_size_t) uuid_size;
/* Missing keys */
for (j = 0; j < sizeof(write_cols) / sizeof(*write_cols) - 1; j++) {
ret = kastore_open(&store, _tmp_file_name, "w", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
write_table_cols(&store, write_cols, j);
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_table_collection_load(&tables, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_REQUIRED_COL_NOT_FOUND);
ret = tsk_table_collection_free(&tables);
CU_ASSERT_EQUAL_FATAL(ret, 0);
}
}
static void
test_missing_optional_column_pairs(void)
{
int ret;
size_t j;
tsk_treeseq_t *ts = caterpillar_tree(5, 3, 3);
tsk_table_collection_t t1, t2;
const char *required_cols[][2] = { { "edges/metadata", "edges/metadata_offset" },
{ "migrations/metadata", "migrations/metadata_offset" },
{ "individuals/parents", "individuals/parents_offset" } };
const char *drop_cols[2];
ret = tsk_treeseq_copy_tables(ts, &t1, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
for (j = 0; j < sizeof(required_cols) / sizeof(*required_cols); j++) {
drop_cols[0] = required_cols[j][0];
copy_store_drop_columns(ts, 1, drop_cols, _tmp_file_name);
ret = tsk_table_collection_load(&t2, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BOTH_COLUMNS_REQUIRED);
tsk_table_collection_free(&t2);
drop_cols[0] = required_cols[j][1];
copy_store_drop_columns(ts, 1, drop_cols, _tmp_file_name);
ret = tsk_table_collection_load(&t2, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BOTH_COLUMNS_REQUIRED);
tsk_table_collection_free(&t2);
drop_cols[0] = required_cols[j][0];
drop_cols[1] = required_cols[j][1];
copy_store_drop_columns(ts, 2, drop_cols, _tmp_file_name);
ret = tsk_table_collection_load(&t2, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_FALSE(tsk_table_collection_equals(&t1, &t2, 0));
tsk_table_collection_free(&t2);
}
tsk_table_collection_free(&t1);
tsk_treeseq_free(ts);
free(ts);
}
static void
test_missing_required_column_pairs(void)
{
int ret;
size_t j;
tsk_treeseq_t *ts = caterpillar_tree(5, 3, 3);
tsk_table_collection_t t;
const char *required_cols[][2] = {
{ "individuals/location", "individuals/location_offset" },
{ "individuals/metadata", "individuals/metadata_offset" },
{ "mutations/derived_state", "mutations/derived_state_offset" },
{ "mutations/metadata", "mutations/metadata_offset" },
{ "nodes/metadata", "nodes/metadata_offset" },
{ "populations/metadata", "populations/metadata_offset" },
{ "provenances/record", "provenances/record_offset" },
{ "provenances/timestamp", "provenances/timestamp_offset" },
{ "sites/ancestral_state", "sites/ancestral_state_offset" },
{ "sites/metadata", "sites/metadata_offset" },
};
const char *drop_cols[2];
for (j = 0; j < sizeof(required_cols) / sizeof(*required_cols); j++) {
drop_cols[0] = required_cols[j][0];
copy_store_drop_columns(ts, 1, drop_cols, _tmp_file_name);
ret = tsk_table_collection_load(&t, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_REQUIRED_COL_NOT_FOUND);
tsk_table_collection_free(&t);
drop_cols[0] = required_cols[j][1];
copy_store_drop_columns(ts, 1, drop_cols, _tmp_file_name);
ret = tsk_table_collection_load(&t, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BOTH_COLUMNS_REQUIRED);
tsk_table_collection_free(&t);
copy_store_drop_columns(ts, 2, required_cols[j], _tmp_file_name);
ret = tsk_table_collection_load(&t, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_REQUIRED_COL_NOT_FOUND);
tsk_table_collection_free(&t);
}
tsk_treeseq_free(ts);
free(ts);
}
static void
verify_bad_offset_columns(tsk_treeseq_t *ts, const char *offset_col)
{
int ret = 0;
kastore_t store;
tsk_table_collection_t tables;
uint32_t *offset_array, *offset_copy;
size_t offset_len;
int type;
uint32_t data_len;
ret = tsk_treeseq_dump(ts, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_open(&store, _tmp_file_name, "r", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_gets(&store, offset_col, (void **) &offset_array, &offset_len, &type);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_EQUAL_FATAL(type, KAS_UINT32);
offset_copy = malloc(offset_len * sizeof(*offset_array));
CU_ASSERT_FATAL(offset_copy != NULL);
tsk_memcpy(offset_copy, offset_array, offset_len * sizeof(*offset_array));
data_len = offset_array[offset_len - 1];
CU_ASSERT_TRUE(data_len > 0);
kastore_close(&store);
offset_copy[0] = UINT32_MAX;
copy_store_drop_columns(ts, 1, &offset_col, _tmp_file_name);
ret = kastore_open(&store, _tmp_file_name, "a", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_puts(&store, offset_col, offset_copy, offset_len, KAS_UINT32, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_table_collection_load(&tables, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BAD_OFFSET);
tsk_table_collection_free(&tables);
offset_copy[0] = 0;
offset_copy[offset_len - 1] = 0;
copy_store_drop_columns(ts, 1, &offset_col, _tmp_file_name);
ret = kastore_open(&store, _tmp_file_name, "a", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_puts(&store, offset_col, offset_copy, offset_len, KAS_UINT32, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_table_collection_load(&tables, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BAD_OFFSET);
tsk_table_collection_free(&tables);
offset_copy[offset_len - 1] = data_len + 1;
copy_store_drop_columns(ts, 1, &offset_col, _tmp_file_name);
ret = kastore_open(&store, _tmp_file_name, "a", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_puts(&store, offset_col, offset_copy, offset_len, KAS_UINT32, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_table_collection_load(&tables, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BAD_OFFSET);
tsk_table_collection_free(&tables);
copy_store_drop_columns(ts, 1, &offset_col, _tmp_file_name);
ret = kastore_open(&store, _tmp_file_name, "a", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_puts(&store, offset_col, NULL, 0, KAS_UINT32, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_table_collection_load(&tables, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_FILE_FORMAT);
tsk_table_collection_free(&tables);
copy_store_drop_columns(ts, 1, &offset_col, _tmp_file_name);
ret = kastore_open(&store, _tmp_file_name, "a", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_puts(&store, offset_col, offset_copy, offset_len, KAS_FLOAT32, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_table_collection_load(&tables, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BAD_COLUMN_TYPE);
tsk_table_collection_free(&tables);
free(offset_copy);
}
static void
test_bad_offset_columns(void)
{
size_t j;
tsk_treeseq_t *ts = caterpillar_tree(5, 3, 3);
/* We exclude "provenances/timestamp_offset" here because there are no
* non-ragged columns in the provenances table, so this doesn't quite
* fit into the same pattern as the other tables */
const char *cols[] = {
"edges/metadata_offset",
"migrations/metadata_offset",
"individuals/location_offset",
"individuals/parents_offset",
"individuals/metadata_offset",
"mutations/derived_state_offset",
"mutations/metadata_offset",
"nodes/metadata_offset",
"populations/metadata_offset",
"provenances/record_offset",
"sites/ancestral_state_offset",
"sites/metadata_offset",
};
for (j = 0; j < sizeof(cols) / sizeof(*cols); j++) {
verify_bad_offset_columns(ts, cols[j]);
}
tsk_treeseq_free(ts);
free(ts);
}
static void
test_force_offset_64(void)
{
int ret;
tsk_treeseq_t *ts = caterpillar_tree(5, 3, 3);
tsk_table_collection_t t1;
tsk_table_collection_t t2;
kastore_t store;
kaitem_t *item;
const char *suffix;
const char *offset_str = "_offset";
int num_found = 0;
size_t j;
ret = tsk_treeseq_dump(ts, _tmp_file_name, TSK_DUMP_FORCE_OFFSET_64);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_open(&store, _tmp_file_name, "r", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
for (j = 0; j < store.num_items; j++) {
item = &store.items[j];
/* Does the key end in "_offset"? */
if (item->key_len > strlen(offset_str)) {
suffix = item->key + (item->key_len - strlen(offset_str));
if (strncmp(suffix, offset_str, strlen(offset_str)) == 0) {
CU_ASSERT_EQUAL(item->type, KAS_UINT64);
num_found++;
}
}
}
CU_ASSERT_TRUE(num_found > 0);
kastore_close(&store);
ret = tsk_table_collection_load(&t1, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_treeseq_copy_tables(ts, &t2, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_TRUE(tsk_table_collection_equals(&t1, &t2, 0));
tsk_table_collection_free(&t1);
tsk_table_collection_free(&t2);
tsk_treeseq_free(ts);
free(ts);
}
static void
test_missing_indexes(void)
{
int ret;
tsk_treeseq_t *ts = caterpillar_tree(5, 3, 3);
tsk_table_collection_t t1, t2;
const char *cols[]
= { "indexes/edge_insertion_order", "indexes/edge_removal_order" };
const char *drop_cols[2];
ret = tsk_treeseq_copy_tables(ts, &t1, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
drop_cols[0] = cols[0];
copy_store_drop_columns(ts, 1, drop_cols, _tmp_file_name);
ret = tsk_table_collection_load(&t2, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BOTH_COLUMNS_REQUIRED);
tsk_table_collection_free(&t2);
drop_cols[0] = cols[1];
copy_store_drop_columns(ts, 1, drop_cols, _tmp_file_name);
ret = tsk_table_collection_load(&t2, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BOTH_COLUMNS_REQUIRED);
tsk_table_collection_free(&t2);
copy_store_drop_columns(ts, 2, cols, _tmp_file_name);
ret = tsk_table_collection_load(&t2, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_TRUE(tsk_table_collection_equals(&t1, &t2, 0));
CU_ASSERT_FALSE(tsk_table_collection_has_index(&t2, 0));
tsk_table_collection_free(&t2);
tsk_table_collection_free(&t1);
tsk_treeseq_free(ts);
free(ts);
}
static void
test_malformed_indexes(void)
{
int ret;
tsk_treeseq_t *ts = caterpillar_tree(5, 3, 3);
tsk_table_collection_t tables;
tsk_treeseq_t ts2;
tsk_size_t num_edges = tsk_treeseq_get_num_edges(ts);
tsk_id_t *bad_index = tsk_calloc(num_edges, sizeof(tsk_id_t));
tsk_id_t *good_index = tsk_calloc(num_edges, sizeof(tsk_id_t));
kastore_t store;
const char *cols[]
= { "indexes/edge_insertion_order", "indexes/edge_removal_order" };
CU_ASSERT_FATAL(bad_index != NULL);
CU_ASSERT_FATAL(good_index != NULL);
/* If both columns are not the same length as the number of edges we
* should raise an error */
copy_store_drop_columns(ts, 2, cols, _tmp_file_name);
ret = kastore_open(&store, _tmp_file_name, "a", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_puts(&store, cols[0], NULL, 0, TSK_ID_STORAGE_TYPE, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_puts(&store, cols[1], NULL, 0, TSK_ID_STORAGE_TYPE, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_table_collection_load(&tables, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_FILE_FORMAT);
tsk_table_collection_free(&tables);
bad_index[0] = -1;
copy_store_drop_columns(ts, 2, cols, _tmp_file_name);
ret = kastore_open(&store, _tmp_file_name, "a", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_puts(
&store, cols[0], good_index, (size_t) num_edges, TSK_ID_STORAGE_TYPE, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_puts(
&store, cols[1], bad_index, (size_t) num_edges, TSK_ID_STORAGE_TYPE, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_treeseq_load(&ts2, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_EDGE_OUT_OF_BOUNDS);
tsk_treeseq_free(&ts2);
copy_store_drop_columns(ts, 2, cols, _tmp_file_name);
ret = kastore_open(&store, _tmp_file_name, "a", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_puts(
&store, cols[0], bad_index, (size_t) num_edges, TSK_ID_STORAGE_TYPE, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_puts(
&store, cols[1], good_index, (size_t) num_edges, TSK_ID_STORAGE_TYPE, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_treeseq_load(&ts2, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_EDGE_OUT_OF_BOUNDS);
tsk_treeseq_free(&ts2);
copy_store_drop_columns(ts, 1, cols, _tmp_file_name);
ret = kastore_open(&store, _tmp_file_name, "a", 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_puts(&store, cols[0], bad_index, (size_t) num_edges, KAS_FLOAT32, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = kastore_close(&store);
CU_ASSERT_EQUAL_FATAL(ret, 0);
ret = tsk_treeseq_load(&ts2, _tmp_file_name, 0);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_BAD_COLUMN_TYPE);
tsk_treeseq_free(&ts2);
free(good_index);
free(bad_index);
tsk_treeseq_free(ts);
free(ts);
}
static void
test_missing_reference_sequence(void)
{
int ret;
tsk_treeseq_t *ts = caterpillar_tree(5, 3, 3);
tsk_table_collection_t t1, t2;
const char *cols[] = { "reference_sequence/data", "reference_sequence/url",
"reference_sequence/metadata_schema", "reference_sequence/metadata" };
CU_ASSERT_TRUE(tsk_treeseq_has_reference_sequence(ts));
ret = tsk_treeseq_copy_tables(ts, &t1, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);
copy_store_drop_columns(ts, 1, cols, _tmp_file_name);
ret = tsk_table_collection_load(&t2, _tmp_file_name, 0);
CU_ASSERT_TRUE(tsk_table_collection_has_reference_sequence(&t2));
tsk_table_collection_free(&t2);
copy_store_drop_columns(ts, 2, cols, _tmp_file_name);
ret = tsk_table_collection_load(&t2, _tmp_file_name, 0);
CU_ASSERT_TRUE(tsk_table_collection_has_reference_sequence(&t2));
tsk_table_collection_free(&t2);
copy_store_drop_columns(ts, 3, cols, _tmp_file_name);
ret = tsk_table_collection_load(&t2, _tmp_file_name, 0);
CU_ASSERT_TRUE(tsk_table_collection_has_reference_sequence(&t2));
tsk_table_collection_free(&t2);
/* Dropping all the columns gives us a NULL reference_sequence, though */
copy_store_drop_columns(ts, 4, cols, _tmp_file_name);
ret = tsk_table_collection_load(&t
gitextract_7z1tql5y/
├── .clang-format
├── .github/
│ ├── PULL_REQUEST_TEMPLATE.md
│ └── workflows/
│ ├── docs.yml
│ ├── lint.yml
│ ├── release-c.yml
│ ├── tests.yml
│ └── wheels.yml
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── c/
│ ├── .gitignore
│ ├── CHANGELOG.rst
│ ├── VERSION.txt
│ ├── examples/
│ │ ├── Makefile
│ │ ├── api_structure.c
│ │ ├── cpp_sorting_example.cpp
│ │ ├── error_handling.c
│ │ ├── haploid_wright_fisher.c
│ │ ├── json_struct_metadata.c
│ │ ├── multichrom_wright_fisher.c
│ │ ├── multichrom_wright_fisher_singlethreaded.c
│ │ ├── streaming.c
│ │ ├── take_ownership.c
│ │ ├── tree_iteration.c
│ │ └── tree_traversal.c
│ ├── meson.build
│ ├── meson_options.txt
│ ├── subprojects/
│ │ └── kastore/
│ │ ├── README.md
│ │ ├── VERSION.txt
│ │ ├── kastore.c
│ │ ├── kastore.h
│ │ └── meson.build
│ ├── tests/
│ │ ├── meson-subproject/
│ │ │ ├── example.c
│ │ │ └── meson.build
│ │ ├── test_convert.c
│ │ ├── test_core.c
│ │ ├── test_file_format.c
│ │ ├── test_genotypes.c
│ │ ├── test_haplotype_matching.c
│ │ ├── test_minimal_cpp.cpp
│ │ ├── test_stats.c
│ │ ├── test_tables.c
│ │ ├── test_trees.c
│ │ ├── testlib.c
│ │ └── testlib.h
│ ├── tskit/
│ │ ├── convert.c
│ │ ├── convert.h
│ │ ├── core.c
│ │ ├── core.h
│ │ ├── genotypes.c
│ │ ├── genotypes.h
│ │ ├── haplotype_matching.c
│ │ ├── haplotype_matching.h
│ │ ├── stats.c
│ │ ├── stats.h
│ │ ├── tables.c
│ │ ├── tables.h
│ │ ├── trees.c
│ │ └── trees.h
│ └── tskit.h
├── codecov.yml
├── docs/
│ ├── .gitignore
│ ├── Makefile
│ ├── _config.yml
│ ├── _static/
│ │ ├── README
│ │ └── bespoke.css
│ ├── _toc.yml
│ ├── build.sh
│ ├── c-api.rst
│ ├── changelogs.rst
│ ├── citation.md
│ ├── cli.md
│ ├── data/
│ │ └── basic_tree_seq.trees
│ ├── data-model.md
│ ├── development.md
│ ├── doxygen/
│ │ └── Doxyfile
│ ├── export.md
│ ├── file-formats.md
│ ├── glossary.md
│ ├── ibd.md
│ ├── installation.md
│ ├── introduction.md
│ ├── metadata.md
│ ├── numba.md
│ ├── provenance.md
│ ├── python-api.md
│ ├── quickstart.md
│ ├── stats.md
│ ├── substitutions/
│ │ ├── linear_traversal_warning.rst
│ │ ├── table_edit_warning.rst
│ │ ├── table_keep_rows_main.rst
│ │ ├── tree_array_warning.rst
│ │ └── virtual_root_array_note.rst
│ └── topological-analysis.md
├── prek.toml
└── python/
├── .gitignore
├── CHANGELOG.rst
├── MANIFEST.in
├── Makefile
├── README.rst
├── _tskitmodule.c
├── benchmark/
│ ├── config.yaml
│ ├── run-for-all-releases.py
│ └── run.py
├── lwt_interface/
│ ├── CHANGELOG.rst
│ ├── Makefile
│ ├── README.md
│ ├── cython_example/
│ │ ├── Makefile
│ │ ├── _lwtc.c
│ │ ├── example.pyx
│ │ ├── pyproject.toml
│ │ └── setup.py
│ ├── dict_encoding_testlib.py
│ ├── example_c_module.c
│ ├── setup.py
│ ├── test_example_c_module.py
│ └── tskit_lwt_interface.h
├── pyproject.toml
├── setup.py
├── stress_lowlevel.py
├── tests/
│ ├── __init__.py
│ ├── conftest.py
│ ├── data/
│ │ ├── SLiM/
│ │ │ ├── README
│ │ │ ├── minimal-example.trees
│ │ │ ├── minimal-example.txt
│ │ │ ├── single-locus-example.trees
│ │ │ └── single-locus-example.txt
│ │ ├── dict-encodings/
│ │ │ ├── generate_msprime.py
│ │ │ └── msprime-0.7.4.pkl
│ │ ├── hdf5-formats/
│ │ │ ├── msprime-0.3.0_v2.0.hdf5
│ │ │ ├── msprime-0.4.0_v3.1.hdf5
│ │ │ └── msprime-0.5.0_v10.0.hdf5
│ │ ├── old-formats/
│ │ │ └── tskit-0.3.3.trees
│ │ └── simplify-bugs/
│ │ ├── 01-edges.txt
│ │ ├── 01-mutations.txt
│ │ ├── 01-nodes.txt
│ │ ├── 01-sites.txt
│ │ ├── 02-edges.txt
│ │ ├── 02-mutations.txt
│ │ ├── 02-nodes.txt
│ │ ├── 02-sites.txt
│ │ ├── 03-edges.txt
│ │ ├── 03-mutations.txt
│ │ ├── 03-nodes.txt
│ │ ├── 03-sites.txt
│ │ ├── 04-edges.txt
│ │ ├── 04-mutations.txt
│ │ ├── 04-nodes.txt
│ │ ├── 04-sites.txt
│ │ ├── 05-edges.txt
│ │ ├── 05-mutations.txt
│ │ ├── 05-nodes.txt
│ │ └── 05-sites.txt
│ ├── ibd.py
│ ├── simplify.py
│ ├── test_avl_tree.py
│ ├── test_balance_metrics.py
│ ├── test_cli.py
│ ├── test_coalrate.py
│ ├── test_combinatorics.py
│ ├── test_dict_encoding.py
│ ├── test_distance_metrics.py
│ ├── test_divmat.py
│ ├── test_drawing.py
│ ├── test_extend_haplotypes.py
│ ├── test_file_format.py
│ ├── test_fileobj.py
│ ├── test_genotype_matching.py
│ ├── test_genotypes.py
│ ├── test_haplotype_matching.py
│ ├── test_highlevel.py
│ ├── test_ibd.py
│ ├── test_immutable_table_collection.py
│ ├── test_intervals.py
│ ├── test_jit.py
│ ├── test_ld_matrix.py
│ ├── test_metadata.py
│ ├── test_ms.py
│ ├── test_parsimony.py
│ ├── test_phylo_formats.py
│ ├── test_provenance.py
│ ├── test_python_c.py
│ ├── test_reference_sequence.py
│ ├── test_relatedness_vector.py
│ ├── test_stats.py
│ ├── test_table_transforms.py
│ ├── test_tables.py
│ ├── test_text_formats.py
│ ├── test_threads.py
│ ├── test_topology.py
│ ├── test_tree_positioning.py
│ ├── test_tree_stats.py
│ ├── test_util.py
│ ├── test_utilities.py
│ ├── test_vcf.py
│ ├── test_version.py
│ ├── test_wright_fisher.py
│ └── tsutil.py
└── tskit/
├── __init__.py
├── __main__.py
├── _version.py
├── cli.py
├── combinatorics.py
├── drawing.py
├── exceptions.py
├── genotypes.py
├── intervals.py
├── jit/
│ ├── __init__.py
│ └── numba.py
├── metadata.py
├── metadata_schema.schema.json
├── provenance.py
├── provenance.schema.json
├── stats.py
├── tables.py
├── text_formats.py
├── trees.py
├── util.py
└── vcf.py
Showing preview only (621K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (8100 symbols across 109 files)
FILE: c/examples/api_structure.c
function main (line 11) | int
FILE: c/examples/cpp_sorting_example.cpp
function handle_tskit_return_code (line 10) | static void
type edge_plus_time (line 20) | struct edge_plus_time {
function sort_edges (line 26) | int
function main (line 72) | int
FILE: c/examples/error_handling.c
function main (line 5) | int
FILE: c/examples/haploid_wright_fisher.c
function simulate (line 13) | void
function main (line 78) | int
FILE: c/examples/json_struct_metadata.c
function load_u64_le (line 14) | static uint64_t
function set_u64_le (line 29) | static void
function json_struct_codec_get_components (line 45) | void
function json_struct_codec_create_buffer (line 96) | void
function main (line 128) | int
FILE: c/examples/multichrom_wright_fisher.c
function init_tables (line 15) | static void
function free_tables (line 29) | static void
function join_tables (line 43) | static void
type chunk_work (line 65) | struct chunk_work {
type chunk_work (line 76) | struct chunk_work
type chunk_work (line 76) | struct chunk_work
function sort_and_simplify_all (line 91) | void
function simplify_tables (line 122) | void
function simulate (line 178) | void
function main (line 247) | int
FILE: c/examples/multichrom_wright_fisher_singlethreaded.c
function simulate (line 14) | void
function main (line 93) | int
FILE: c/examples/streaming.c
function main (line 11) | int
FILE: c/examples/take_ownership.c
function main (line 11) | int
FILE: c/examples/tree_iteration.c
function main (line 12) | int
FILE: c/examples/tree_traversal.c
function traverse_standard (line 12) | static void
function _traverse (line 37) | static void
function traverse_recursive (line 52) | static void
function traverse_stack (line 58) | static void
function traverse_upwards (line 83) | static void
function main (line 100) | int
FILE: c/subprojects/kastore/kastore.c
function kas_version_t (line 80) | kas_version_t
function type_size (line 91) | static size_t
function compare_items (line 100) | static int
function kastore_get_read_io_error (line 117) | static int KAS_WARN_UNUSED
function kastore_write_header (line 128) | static int KAS_WARN_UNUSED
function kastore_read_header (line 153) | static int KAS_WARN_UNUSED
function kastore_pack_items (line 199) | static void
function kastore_write_descriptors (line 222) | static int KAS_WARN_UNUSED
function kastore_read_descriptors (line 254) | static int KAS_WARN_UNUSED
function kastore_write_data (line 339) | static int KAS_WARN_UNUSED
function kastore_read_file (line 381) | static int KAS_WARN_UNUSED
function kastore_read_item (line 434) | static int KAS_WARN_UNUSED
function kastore_write_file (line 463) | static int KAS_WARN_UNUSED
function kastore_read (line 486) | static int KAS_WARN_UNUSED
function kastore_insert_all (line 527) | static int KAS_WARN_UNUSED
function kastore_open (line 546) | int KAS_WARN_UNUSED
function kastore_openf (line 609) | int KAS_WARN_UNUSED
function kastore_close (line 642) | int KAS_WARN_UNUSED
function kastore_find_item (line 686) | static int
function kastore_contains (line 714) | int KAS_WARN_UNUSED
function kastore_containss (line 727) | int KAS_WARN_UNUSED
function kastore_get (line 733) | int KAS_WARN_UNUSED
function kastore_gets (line 759) | int KAS_WARN_UNUSED
function kastore_gets_type (line 766) | static int KAS_WARN_UNUSED
function kastore_gets_int8 (line 785) | int KAS_WARN_UNUSED
function kastore_gets_uint8 (line 791) | int KAS_WARN_UNUSED
function kastore_gets_int16 (line 797) | int KAS_WARN_UNUSED
function kastore_gets_uint16 (line 803) | int KAS_WARN_UNUSED
function kastore_gets_int32 (line 810) | int KAS_WARN_UNUSED
function kastore_gets_uint32 (line 816) | int KAS_WARN_UNUSED
function kastore_gets_int64 (line 823) | int KAS_WARN_UNUSED
function kastore_gets_uint64 (line 829) | int KAS_WARN_UNUSED
function kastore_gets_float32 (line 836) | int KAS_WARN_UNUSED
function kastore_gets_float64 (line 842) | int KAS_WARN_UNUSED
function kastore_put_item (line 848) | static int KAS_WARN_UNUSED
function kastore_bput (line 910) | static int KAS_WARN_UNUSED
function kastore_put (line 932) | int KAS_WARN_UNUSED
function kastore_oput (line 970) | int KAS_WARN_UNUSED
function kastore_puts (line 992) | int KAS_WARN_UNUSED
function kastore_puts_int8 (line 999) | int KAS_WARN_UNUSED
function kastore_puts_uint8 (line 1006) | int KAS_WARN_UNUSED
function kastore_puts_int16 (line 1013) | int KAS_WARN_UNUSED
function kastore_puts_uint16 (line 1020) | int KAS_WARN_UNUSED
function kastore_puts_int32 (line 1027) | int KAS_WARN_UNUSED
function kastore_puts_uint32 (line 1034) | int KAS_WARN_UNUSED
function kastore_puts_int64 (line 1041) | int KAS_WARN_UNUSED
function kastore_puts_uint64 (line 1048) | int KAS_WARN_UNUSED
function kastore_puts_float32 (line 1055) | int KAS_WARN_UNUSED
function kastore_puts_float64 (line 1062) | int KAS_WARN_UNUSED
function kastore_oputs (line 1069) | int KAS_WARN_UNUSED
function kastore_oputs_int8 (line 1076) | int KAS_WARN_UNUSED
function kastore_oputs_uint8 (line 1083) | int KAS_WARN_UNUSED
function kastore_oputs_int16 (line 1090) | int KAS_WARN_UNUSED
function kastore_oputs_uint16 (line 1097) | int KAS_WARN_UNUSED
function kastore_oputs_int32 (line 1104) | int KAS_WARN_UNUSED
function kastore_oputs_uint32 (line 1111) | int KAS_WARN_UNUSED
function kastore_oputs_int64 (line 1118) | int KAS_WARN_UNUSED
function kastore_oputs_uint64 (line 1125) | int KAS_WARN_UNUSED
function kastore_oputs_float32 (line 1132) | int KAS_WARN_UNUSED
function kastore_oputs_float64 (line 1139) | int KAS_WARN_UNUSED
function kastore_print_state (line 1146) | void
FILE: c/subprojects/kastore/kastore.h
type kaitem_t (line 191) | typedef struct {
type kastore_t (line 206) | typedef struct {
type kas_version_t (line 221) | typedef struct {
FILE: c/tests/meson-subproject/example.c
function test_kas_strerror (line 33) | void
function test_strerror (line 41) | void
function test_load_error (line 49) | void
function test_table_basics (line 59) | void
function main (line 76) | int
FILE: c/tests/test_convert.c
function test_single_tree_newick (line 31) | static void
function test_single_tree_newick_errors (line 77) | static void
function main (line 118) | int
FILE: c/tests/test_core.c
function test_strerror (line 32) | static void
function test_strerror_kastore (line 48) | static void
function test_generate_uuid (line 64) | static void
function test_double_round (line 86) | static void
function test_blkalloc (line 287) | static void
function test_unknown_time (line 340) | static void
function test_malloc_zero (line 351) | static void
function test_malloc_overflow (line 364) | static void
function test_debug_stream (line 377) | static void
function validate_avl_node (line 392) | static int
function test_avl_empty (line 420) | static void
function validate_avl (line 440) | static void
function test_avl_sequential (line 488) | static void
function test_avl_interleaved (line 498) | static void
function test_avl_random (line 516) | static void
function test_bit_arrays (line 530) | static void
function test_meson_version (line 638) | static void
function main (line 649) | int
FILE: c/tests/test_file_format.c
type write_table_col_t (line 28) | typedef struct {
function write_table_cols (line 35) | static void
function copy_store_drop_columns (line 48) | static void
function test_format_data_load_errors (line 101) | static void
function test_missing_optional_column_pairs (line 271) | static void
function test_missing_required_column_pairs (line 312) | static void
function verify_bad_offset_columns (line 356) | static void
function test_bad_offset_columns (line 444) | static void
function test_force_offset_64 (line 474) | static void
function test_missing_indexes (line 521) | static void
function test_malformed_indexes (line 558) | static void
function test_missing_reference_sequence (line 639) | static void
function test_bad_column_types (line 680) | static void
function test_missing_required_columns (line 760) | static void
function test_metadata_schemas_optional (line 806) | static void
function test_load_bad_file_formats (line 848) | static void
function test_load_errors (line 884) | static void
function test_load_eof (line 936) | static void
function test_dump_errors (line 995) | static void
function test_load_node_table_errors (line 1039) | static void
function test_example_round_trip (line 1127) | static void
function test_multiple_round_trip (line 1186) | static void
function test_copy_store_drop_columns (line 1251) | static void
function test_skip_tables (line 1272) | static void
function test_skip_reference_sequence (line 1342) | static void
function main (line 1403) | int
FILE: c/tests/test_genotypes.c
function test_simplest_missing_data (line 32) | static void
function test_simplest_missing_data_user_alleles (line 74) | static void
function test_simplest_missing_data_mutations (line 129) | static void
function test_simplest_missing_data_mutations_all_samples (line 187) | static void
function test_single_tree_user_alleles (line 247) | static void
function test_single_tree_char_alphabet (line 354) | static void
function test_single_tree_binary_alphabet (line 446) | static void
function test_single_tree_non_samples (line 504) | static void
function test_isolated_internal_node (line 598) | static void
function test_single_tree_errors (line 652) | static void
function test_single_tree_user_alleles_errors (line 684) | static void
function test_single_tree_subsample (line 732) | static void
function test_single_tree_many_alleles (line 821) | static void
function test_single_tree_silent_mutations (line 877) | static void
function test_multiple_variant_decode (line 966) | static void
function test_variant_decode_errors (line 1025) | static void
function assert_variants_equal (line 1053) | static void
function test_variant_copy (line 1082) | static void
function test_variant_copy_long_alleles (line 1120) | static void
function test_variant_copy_memory_management (line 1163) | static void
function build_balanced_three_example_align (line 1202) | static void
function test_alignments_basic_default (line 1219) | static void
function test_alignments_reference_sequence (line 1247) | static void
function test_alignments_partial_isolation (line 1274) | static void
function test_alignments_return_code_truncated_interval (line 1300) | static void
function test_alignments_invalid_allele_length (line 1329) | static void
function test_alignments_bad_reference_length (line 1347) | static void
function test_alignments_non_integer_bounds (line 1364) | static void
function test_alignments_discrete_genome_required (line 1381) | static void
function test_alignments_null_reference (line 1399) | static void
function test_alignments_null_nodes_or_buf (line 1417) | static void
function test_alignments_node_out_of_bounds (line 1440) | static void
function test_alignments_isolated_as_not_missing (line 1457) | static void
function test_alignments_internal_node_non_sample (line 1484) | static void
function test_alignments_missing_char_collision (line 1500) | static void
function test_alignments_zero_nodes_ok (line 1519) | static void
function test_alignments_bad_bounds_cases (line 1531) | static void
function test_alignments_order_preserved (line 1549) | static void
function test_alignments_missing_char_custom (line 1571) | static void
function test_alignments_embedded_null_reference (line 1592) | static void
function test_alignments_growing_allele_buffer (line 1620) | static void
function main (line 1662) | int
FILE: c/tests/test_haplotype_matching.c
function test_single_tree_missing_alleles (line 31) | static void
function test_single_tree_exact_match (line 60) | static void
function test_single_tree_missing_haplotype_data (line 119) | static void
function test_single_tree_match_impossible (line 162) | static void
function test_single_tree_errors (line 206) | static void
function test_single_tree_compressed_matrix (line 270) | static void
function test_single_tree_viterbi_matrix (line 340) | static void
function test_multi_tree_exact_match (line 412) | static void
function test_multi_tree_errors (line 479) | static void
function test_caterpillar_tree_many_values (line 506) | static void
function main (line 558) | int
FILE: c/tests/test_minimal_cpp.cpp
function test_kas_strerror (line 38) | void
function test_strerror (line 47) | void
function test_load_error (line 56) | void
function test_table_basics (line 66) | void
function cpp_sort_edges (line 87) | int
function test_edge_sorting (line 146) | void
function sort_edges_raises_exception (line 193) | int
function sort_edges_raises_non_exception (line 200) | int
function safe_sort_edges (line 207) | int
function test_edge_sorting_errors (line 227) | void
function main (line 265) | int
FILE: c/tests/test_stats.c
function multi_mutations_exist (line 33) | static bool
function verify_ld (line 50) | static void
function verify_genealogical_nearest_neighbours (line 191) | static void
function verify_mean_descendants (line 230) | static void
function verify_divergence_matrix (line 269) | static void
function verify_pair_coalescence_counts (line 309) | static void
function verify_pair_coalescence_quantiles (line 413) | static void
function verify_pair_coalescence_rates (line 518) | static void
type general_stat_error_params_t (line 635) | typedef struct {
function general_stat_error (line 641) | static int
function verify_window_errors (line 656) | static void
function verify_summary_func_errors (line 708) | static void
function verify_branch_general_stat_errors (line 755) | static void
function verify_site_general_stat_errors (line 762) | static void
function verify_node_general_stat_errors (line 769) | static void
function verify_one_way_weighted_func_errors (line 776) | static void
function verify_one_way_weighted_covariate_func_errors (line 799) | static void
function verify_one_way_stat_func_errors (line 824) | static void
function verify_one_way_stat_func_errors_tw (line 880) | static void
function verify_two_way_stat_func_errors (line 950) | static void
function verify_two_way_weighted_stat_func_errors (line 979) | static void
function verify_three_way_stat_func_errors (line 1005) | static void
function verify_four_way_stat_func_errors (line 1033) | static void
function general_stat_identity (line 1061) | static int
function verify_branch_general_stat_identity (line 1075) | static void
function general_stat_sum (line 1126) | static int
function verify_general_stat_dims (line 1144) | static void
function verify_general_stat_windows (line 1169) | static void
function verify_default_general_stat (line 1204) | static void
function verify_general_stat (line 1232) | static void
function verify_afs (line 1256) | static void
function test_general_stat_input_errors (line 1298) | static void
function test_empty_ts_ld (line 1332) | static void
function test_empty_ts_mean_descendants (line 1344) | static void
function test_empty_ts_genealogical_nearest_neighbours (line 1355) | static void
function test_empty_ts_general_stat (line 1366) | static void
function test_empty_ts_afs (line 1381) | static void
function test_single_tree_ld (line 1392) | static void
function test_single_tree_mean_descendants (line 1403) | static void
function test_single_tree_genealogical_nearest_neighbours (line 1414) | static void
function test_single_tree_general_stat (line 1425) | static void
function test_single_tree_general_stat_errors (line 1440) | static void
function test_single_tree_divergence_matrix (line 1453) | static void
function test_single_tree_divergence_matrix_internal_samples (line 1504) | static void
function test_single_tree_divergence_matrix_multi_root (line 1576) | static void
function test_paper_ex_ld (line 1625) | static void
function test_paper_ex_mean_descendants (line 1656) | static void
function test_paper_ex_genealogical_nearest_neighbours (line 1667) | static void
function test_paper_ex_general_stat (line 1678) | static void
function test_paper_ex_general_stat_errors (line 1693) | static void
function test_paper_ex_diversity_errors (line 1706) | static void
function test_paper_ex_diversity (line 1717) | static void
function test_paper_ex_trait_covariance_errors (line 1744) | static void
function test_paper_ex_trait_covariance (line 1755) | static void
function test_paper_ex_trait_correlation_errors (line 1786) | static void
function test_paper_ex_trait_correlation (line 1797) | static void
function test_paper_ex_trait_linear_model_errors (line 1820) | static void
function test_paper_ex_trait_linear_model (line 1831) | static void
function test_paper_ex_segregating_sites_errors (line 1861) | static void
function test_paper_ex_segregating_sites (line 1872) | static void
function test_paper_ex_Y1_errors (line 1899) | static void
function test_paper_ex_Y1 (line 1910) | static void
function test_paper_ex_divergence_errors (line 1934) | static void
function test_paper_ex_divergence (line 1945) | static void
function test_paper_ex_genetic_relatedness (line 1973) | static void
function test_paper_ex_genetic_relatedness_errors (line 1997) | static void
function test_paper_ex_genetic_relatedness_weighted (line 2012) | static void
function test_paper_ex_genetic_relatedness_weighted_errors (line 2049) | static void
function test_empty_genetic_relatedness_vector (line 2065) | static void
function verify_genetic_relatedness_vector (line 2116) | static void
function test_paper_ex_genetic_relatedness_vector (line 2170) | static void
function test_paper_ex_genetic_relatedness_vector_errors (line 2190) | static void
function test_paper_ex_genetic_relatedness_vector_node_errors (line 2259) | static void
function test_paper_ex_Y2_errors (line 2304) | static void
function test_paper_ex_Y2 (line 2315) | static void
function test_paper_ex_f2_errors (line 2342) | static void
function test_paper_ex_f2 (line 2353) | static void
function test_paper_ex_Y3_errors (line 2388) | static void
function test_paper_ex_Y3 (line 2399) | static void
function test_paper_ex_f3_errors (line 2419) | static void
function test_paper_ex_f3 (line 2430) | static void
function test_paper_ex_f4_errors (line 2457) | static void
function test_paper_ex_f4 (line 2468) | static void
function test_paper_ex_afs_errors (line 2487) | static void
function test_paper_ex_afs (line 2517) | static void
function test_paper_ex_divergence_matrix (line 2550) | static void
function test_unary_ex_afs (line 2566) | static void
function test_nonbinary_ex_ld (line 2599) | static void
function test_nonbinary_ex_mean_descendants (line 2610) | static void
function test_nonbinary_ex_genealogical_nearest_neighbours (line 2621) | static void
function test_nonbinary_ex_general_stat (line 2632) | static void
function test_nonbinary_ex_general_stat_errors (line 2647) | static void
function test_caterpillar_tree_ld (line 2660) | static void
function test_ld_multi_mutations (line 2688) | static void
function test_ld_silent_mutations (line 2705) | static void
function test_paper_ex_two_site (line 2733) | static void
function test_paper_ex_two_branch (line 2848) | static void
function test_two_site_correlated_multiallelic (line 3005) | static void
function test_two_site_uncorrelated_multiallelic (line 3192) | static void
function test_two_site_backmutation (line 3385) | static void
function test_two_locus_branch_all_stats (line 3454) | static void
function test_paper_ex_two_site_subset (line 3593) | static void
function test_two_locus_stat_input_errors (line 3648) | static void
function test_simplest_divergence_matrix (line 3819) | static void
function test_simplest_divergence_matrix_windows (line 3907) | static void
function test_simplest_divergence_matrix_internal_sample (line 3966) | static void
function test_multiroot_divergence_matrix (line 3995) | static void
function test_pair_coalescence_counts (line 4011) | static void
function test_pair_coalescence_counts_missing (line 4025) | static void
function test_pair_coalescence_quantiles (line 4036) | static void
function test_pair_coalescence_rates (line 4046) | static void
function main (line 4056) | int
FILE: c/tests/test_tables.c
function reverse_migrations (line 33) | static void
function reverse_edges (line 62) | static void
function reverse_mutations (line 90) | static void
function insert_edge_metadata (line 119) | static void
function test_table_collection_equals_options (line 144) | static void
function test_table_collection_simplify_errors (line 341) | static void
function test_reference_sequence_state_machine (line 406) | static void
function test_reference_sequence_take (line 470) | static void
function test_reference_sequence (line 526) | static void
function test_table_collection_reference_sequence (line 632) | static void
function test_table_collection_has_reference_sequence (line 752) | static void
function test_table_collection_metadata (line 775) | static void
function test_table_collection_time_units (line 878) | static void
function test_node_table (line 945) | static void
function test_node_table_takeset (line 1299) | static void
function test_node_table_update_row (line 1412) | static void
function test_node_table_keep_rows (line 1494) | static void
function test_edge_table_with_options (line 1594) | static void
function test_edge_table (line 2002) | static void
function test_edge_table_update_row (line 2009) | static void
function test_edge_table_update_row_no_metadata (line 2091) | static void
function test_edge_table_keep_rows (line 2137) | static void
function test_edge_table_keep_rows_no_metadata (line 2237) | static void
function test_edge_table_takeset_with_options (line 2334) | static void
function test_edge_table_takeset (line 2452) | static void
function test_edge_table_copy_semantics (line 2459) | static void
function test_edge_table_squash (line 2510) | static void
function test_edge_table_squash_multiple_parents (line 2548) | static void
function test_edge_table_squash_empty (line 2592) | static void
function test_edge_table_squash_single_edge (line 2619) | static void
function test_edge_table_squash_bad_intervals (line 2644) | static void
function test_edge_table_squash_metadata (line 2671) | static void
function test_site_table (line 2701) | static void
function test_site_table_takeset (line 3034) | static void
function test_site_table_update_row (line 3155) | static void
function test_site_table_keep_rows (line 3258) | static void
function test_mutation_table (line 3359) | static void
function test_mutation_table_takeset (line 3764) | static void
function test_mutation_table_update_row (line 3914) | static void
function test_mutation_table_keep_rows (line 4044) | static void
function test_mutation_table_keep_rows_parent_references (line 4151) | static void
function test_migration_table (line 4237) | static void
function test_migration_table_takeset (line 4606) | static void
function test_migration_table_update_row (line 4745) | static void
function test_migration_table_keep_rows (line 4838) | static void
function test_individual_table (line 4940) | static void
function test_individual_table_takeset (line 5402) | static void
function test_individual_table_update_row (line 5539) | static void
function test_individual_table_keep_rows (line 5665) | static void
function test_individual_table_keep_rows_parent_references (line 5773) | static void
function test_population_table (line 5860) | static void
function test_population_table_takeset (line 6105) | static void
function test_population_table_update_row (line 6176) | static void
function test_population_table_keep_rows (line 6237) | static void
function test_provenance_table (line 6333) | static void
function test_provenance_table_takeset (line 6590) | static void
function test_provenance_table_update_row (line 6687) | static void
function test_provenance_table_keep_rows (line 6772) | static void
function test_table_size_increments (line 6872) | static void
function test_table_expansion (line 6982) | static void
function test_ragged_expansion (line 7499) | static void
function test_link_ancestors_input_errors (line 7573) | static void
function test_link_ancestors_single_tree (line 7649) | static void
function test_link_ancestors_no_edges (line 7689) | static void
function test_link_ancestors_samples_and_ancestors_overlap (line 7715) | static void
function test_link_ancestors_paper (line 7757) | static void
function test_link_ancestors_multiple_to_single_tree (line 7798) | static void
function verify_ibd_segment_list (line 7836) | static void
function verify_ibd_result (line 7859) | static void
function test_ibd_segments_debug (line 7918) | static void
function test_ibd_segments_caterpillar_tree (line 7956) | static void
function test_ibd_segments_single_tree (line 7972) | static void
function test_ibd_segments_single_tree_options (line 8090) | static void
function test_ibd_segments_single_tree_between (line 8192) | static void
function test_ibd_segments_multiple_trees (line 8258) | static void
function test_ibd_segments_empty_result (line 8311) | static void
function test_ibd_segments_min_span_max_time (line 8340) | static void
function test_ibd_segments_errors (line 8378) | static void
function test_ibd_segments_samples_are_descendants (line 8462) | static void
function test_ibd_segments_multiple_ibd_paths (line 8501) | static void
function test_ibd_segments_odd_topologies (line 8543) | static void
function test_simplify_tables_drops_indexes (line 8576) | static void
function test_simplify_empty_tables (line 8598) | static void
function test_simplify_metadata (line 8616) | static void
function test_edge_update_invalidates_index (line 8632) | static void
function test_copy_table_collection (line 8670) | static void
function test_sort_tables_offsets (line 8705) | static void
function test_sort_tables_drops_indexes_with_options (line 8811) | static void
function test_sort_tables_drops_indexes (line 8832) | static void
function test_sort_tables_edge_metadata (line 8839) | static void
function test_sort_tables_no_edge_metadata (line 8865) | static void
function test_sort_tables_errors (line 8904) | static void
function test_sort_tables_mutation_times (line 9002) | static void
function test_sort_tables_mutations (line 9062) | static void
function test_sort_tables_canonical_errors (line 9176) | static void
function test_sort_tables_canonical (line 9269) | static void
function test_sort_tables_migrations (line 9398) | static void
function test_sort_tables_individuals (line 9443) | static void
function test_sorter_interface (line 9509) | static void
function test_dump_unindexed_with_options (line 9577) | static void
function test_dump_unindexed (line 9606) | static void
function test_dump_load_empty_with_options (line 9613) | static void
function test_dump_load_empty (line 9632) | static void
function test_dump_load_unsorted_with_options (line 9639) | static void
function test_dump_load_unsorted (line 9692) | static void
function test_dump_load_metadata_schema (line 9699) | static void
function test_dump_fail_no_file (line 9734) | static void
function test_load_reindex (line 9783) | static void
function test_table_overflow (line 9821) | static void
function test_column_overflow (line 9877) | static void
function test_table_collection_check_integrity_with_options (line 10036) | static void
function test_table_collection_check_integrity_no_populations (line 10519) | static void
function test_table_collection_check_integrity (line 10570) | static void
function test_table_collection_check_integrity_bad_indexes_example (line 10577) | static void
function test_table_collection_check_integrity_bad_indexes (line 10628) | static void
function test_check_integrity_bad_mutation_parent_topology (line 10720) | static void
function test_table_collection_compute_mutation_parents_tolerates_invalid_input (line 10778) | static void
function test_table_collection_compute_mutation_parents_restores_on_error (line 10814) | static void
function test_table_collection_subset_with_options (line 10857) | static void
function test_table_collection_subset (line 11027) | static void
function test_table_collection_subset_unsorted (line 11034) | static void
function test_table_collection_subset_errors (line 11099) | static void
function test_table_collection_union (line 11177) | static void
function test_table_collection_disjoint_union (line 11322) | static void
function test_table_collection_union_middle_merge (line 11425) | static void
function test_table_collection_union_errors (line 11583) | static void
function test_table_collection_clear_with_options (line 11669) | static void
function test_table_collection_clear (line 11771) | static void
function test_table_collection_takeset_indexes (line 11789) | static void
function test_table_collection_delete_older (line 11836) | static void
function main (line 11889) | int
FILE: c/tests/test_trees.c
function check_trees_equal (line 38) | static void
function check_trees_identical (line 55) | static void
function verify_compute_mutation_parents (line 106) | static void
function verify_compute_mutation_times (line 132) | static void
function verify_individual_nodes (line 158) | static void
function verify_tree_pos (line 178) | static void
function verify_trees (line 326) | static void
function tsk_tree_t (line 405) | static tsk_tree_t *
function verify_tree_next_prev (line 432) | static void
function verify_edge_array_single_tree (line 554) | static void
function verify_edge_array_trees (line 582) | static void
function verify_simplify_genotypes (line 615) | static void
function verify_simplify_properties (line 670) | static void
function verify_simplify (line 782) | static void
type sample_count_test_t (line 824) | typedef struct {
function verify_sample_counts (line 830) | static void
function verify_sample_sets_for_tree (line 949) | static void
function verify_sample_sets (line 1014) | static void
function verify_empty_tree_sequence (line 1050) | static void
function test_simplest_discrete_genome (line 1066) | static void
function test_simplest_discrete_time (line 1164) | static void
function test_simplest_min_time (line 1239) | static void
function test_simplest_max_time (line 1290) | static void
function test_simplest_records (line 1341) | static void
function test_simplest_nonbinary_records (line 1385) | static void
function test_simplest_unary_records (line 1433) | static void
function test_simplest_unary_with_individuals (line 1495) | static void
function test_simplest_non_sample_leaf_records (line 1563) | static void
function test_simplest_degenerate_multiple_root_records (line 1639) | static void
function test_simplest_multiple_root_records (line 1691) | static void
function test_simplest_zero_root_tree (line 1734) | static void
function test_simplest_multi_root_tree (line 1773) | static void
function test_simplest_tree_mrca (line 1833) | static void
function test_simplest_root_mutations (line 1866) | static void
function test_simplest_back_mutations (line 1901) | static void
function test_simplest_general_samples (line 1945) | static void
function test_simplest_holey_tree_sequence (line 1987) | static void
function test_simplest_holey_tsk_treeseq_mutation_parents (line 2030) | static void
function test_simplest_initial_gap_tree_sequence (line 2072) | static void
function test_simplest_initial_gap_zero_roots (line 2123) | static void
function test_simplest_holey_tsk_treeseq_zero_roots (line 2171) | static void
function test_simplest_initial_gap_tsk_treeseq_mutation_parents (line 2235) | static void
function test_simplest_final_gap_tree_sequence (line 2274) | static void
function test_simplest_final_gap_tsk_treeseq_mutation_parents (line 2311) | static void
function test_simplest_individuals (line 2350) | static void
function test_simplest_bad_individuals (line 2448) | static void
function test_simplest_bad_edges (line 2542) | static void
function test_simplest_bad_indexes (line 2731) | static void
function test_simplest_bad_migrations (line 2792) | static void
function test_simplest_migration_simplify (line 2907) | static void
function test_simplest_overlapping_parents (line 2941) | static void
function test_simplest_contradictory_children (line 2989) | static void
function test_simplest_overlapping_edges_simplify (line 3018) | static void
function test_simplest_overlapping_unary_edges_simplify (line 3068) | static void
function test_simplest_overlapping_unary_edges_internal_samples_simplify (line 3111) | static void
function test_simplest_reduce_site_topology (line 3153) | static void
function test_simplest_simplify_defragment (line 3200) | static void
function test_simplest_population_filter (line 3263) | static void
function test_simplest_individual_filter (line 3301) | static void
function test_simplest_no_node_filter (line 3339) | static void
function test_simplest_no_update_flags (line 3405) | static void
function test_simplest_map_mutations (line 3435) | static void
function test_simplest_nonbinary_map_mutations (line 3515) | static void
function test_simplest_unary_map_mutations (line 3559) | static void
function test_simplest_non_sample_leaf_map_mutations (line 3605) | static void
function test_simplest_internal_sample_map_mutations (line 3649) | static void
function test_simplest_multiple_root_map_mutations (line 3702) | static void
function test_simplest_chained_map_mutations (line 3759) | static void
function test_simplest_mutation_edges (line 3808) | static void
function test_single_tree_good_records (line 3869) | static void
function test_single_nonbinary_tree_good_records (line 3885) | static void
function test_single_tree_bad_records (line 3913) | static void
function test_single_tree_good_mutations (line 3963) | static void
function test_single_tree_bad_mutations (line 4030) | static void
function test_single_tree_iter (line 4210) | static void
function test_single_nonbinary_tree_iter (line 4272) | static void
function test_single_tree_general_samples_iter (line 4367) | static void
function test_single_tree_iter_times (line 4433) | static void
function test_single_tree_iter_depths (line 4479) | static void
function test_single_tree_simplify (line 4525) | static void
function test_single_tree_simplify_debug (line 4582) | static void
function test_single_tree_simplify_keep_input_roots (line 4605) | static void
function test_single_tree_simplify_no_sample_nodes (line 4631) | static void
function test_single_tree_simplify_null_samples (line 4660) | static void
function test_single_tree_compute_mutation_parents (line 4683) | static void
function test_single_tree_compute_mutation_times (line 4792) | static void
function test_single_tree_mutation_edges (line 4910) | static void
function test_single_tree_is_descendant (line 4948) | static void
function test_single_tree_total_branch_length (line 4988) | static void
function test_single_tree_num_lineages (line 5026) | static void
function test_single_tree_map_mutations (line 5065) | static void
function test_single_tree_map_mutations_internal_samples (line 5193) | static void
function test_single_tree_tracked_samples (line 5239) | static void
function test_single_tree_tree_pos (line 5322) | static void
function test_simple_multi_tree (line 5424) | static void
function test_multi_tree_direction_switching_tree_pos (line 5444) | static void
function test_unary_multi_tree (line 5548) | static void
function test_internal_sample_multi_tree (line 5568) | static void
function test_internal_sample_simplified_multi_tree (line 5588) | static void
function test_nonbinary_multi_tree (line 5620) | static void
function test_simplify_keep_input_roots_multi_tree (line 5641) | static void
function test_left_to_right_multi_tree (line 5696) | static void
function test_gappy_multi_tree (line 5740) | static void
function test_tsk_treeseq_bad_records (line 5786) | static void
function test_convenience_arrays_multi_tree (line 5832) | static void
function test_multiroot_mrca (line 5857) | static void
function test_simple_sample_sets (line 5890) | static void
function test_nonbinary_sample_sets (line 5910) | static void
function test_internal_sample_sample_sets (line 5930) | static void
function test_non_sample_leaf_sample_lists (line 5951) | static void
function test_virtual_root_properties (line 5989) | static void
function test_no_sample_count_semantics (line 6049) | static void
function verify_node_lists (line 6088) | static void
function test_single_tree_traversal (line 6099) | static void
function test_multiroot_tree_traversal (line 6214) | static void
function verify_seek_multi_tree (line 6318) | static void
function test_seek_multi_tree (line 6391) | static void
function test_seek_errors (line 6398) | static void
function test_isolated_node_kc (line 6429) | static void
function test_single_tree_kc (line 6469) | static void
function test_two_trees_kc (line 6510) | static void
function test_empty_tree_kc (line 6563) | static void
function test_nonbinary_tree_kc (line 6617) | static void
function test_nonzero_samples_kc (line 6646) | static void
function test_internal_samples_kc (line 6676) | static void
function test_non_sample_leaf_kc (line 6705) | static void
function test_unequal_sample_size_kc (line 6735) | static void
function test_unequal_samples_kc (line 6779) | static void
function test_unary_nodes_kc (line 6828) | static void
function test_no_sample_lists_kc (line 6854) | static void
function test_unequal_sequence_lengths_kc (line 6876) | static void
function test_different_number_trees_kc (line 6902) | static void
function test_offset_trees_with_errors_kc (line 6953) | static void
function test_genealogical_nearest_neighbours_errors (line 6990) | static void
function test_single_tree_balance (line 7082) | static void
function test_multiroot_balance (line 7117) | static void
function test_nonbinary_balance (line 7156) | static void
function test_empty_tree_balance (line 7191) | static void
function test_b2_bad_base (line 7225) | static void
function test_tree_errors (line 7258) | static void
function test_treeseq_row_access_errors (line 7340) | static void
function test_treeseq_get_individuals_population_errors (line 7374) | static void
function test_treeseq_get_individuals_population (line 7409) | static void
function test_treeseq_get_individuals_time_errors (line 7457) | static void
function test_treeseq_get_individuals_time (line 7492) | static void
function test_tree_copy_flags (line 7540) | static void
function test_deduplicate_sites (line 7603) | static void
function test_deduplicate_sites_errors (line 7687) | static void
function test_deduplicate_sites_zero_rows (line 7761) | static void
function test_deduplicate_sites_multichar (line 7779) | static void
function test_empty_tree_sequence (line 7817) | static void
function test_zero_edges (line 7864) | static void
function test_tree_sequence_metadata (line 7939) | static void
function dummy_stat (line 7991) | static int
function test_time_uncalibrated (line 8004) | static void
function test_reference_sequence (line 8084) | static void
function test_split_edges_no_populations (line 8110) | static void
function test_split_edges_populations (line 8175) | static void
function test_split_edges_errors (line 8221) | static void
function test_extend_haplotypes_simple (line 8275) | static void
function test_extend_haplotypes_errors (line 8299) | static void
function assert_equal_except_edges_and_mutation_nodes (line 8339) | static void
function test_extend_haplotypes (line 8364) | static void
function test_extend_haplotypes_conflicting_times (line 8448) | static void
function test_extend_haplotypes_new_edge (line 8487) | static void
function test_init_take_ownership_no_edge_metadata (line 8556) | static void
function test_init_compute_mutation_parents (line 8577) | static void
function test_init_compute_mutation_parents_errors (line 8638) | static void
function main (line 8683) | int
FILE: c/tests/testlib.c
function parse_nodes (line 410) | void
function parse_edges (line 464) | void
function parse_migrations (line 527) | void
function parse_sites (line 584) | void
function parse_mutations (line 622) | void
function parse_individuals (line 675) | void
function tsk_treeseq_from_text (line 766) | void
function tsk_treeseq_t (line 844) | tsk_treeseq_t *
function unsort_edges (line 967) | void
function tskit_suite_init (line 992) | static int
function tskit_suite_cleanup (line 1018) | static int
function handle_cunit_error (line 1031) | static void
function test_main (line 1038) | int
FILE: c/tskit/convert.c
type tsk_newick_converter_t (line 44) | typedef struct {
function tsk_newick_converter_run (line 52) | static int
function tsk_newick_converter_init (line 154) | static int
function tsk_newick_converter_free (line 174) | static int
function tsk_convert_newick (line 181) | int
FILE: c/tskit/core.c
function get_random_bytes (line 42) | static int TSK_WARN_UNUSED
function get_random_bytes (line 74) | static int TSK_WARN_UNUSED
function tsk_generate_uuid (line 102) | int
function tsk_set_kas_error (line 712) | int
function tsk_is_kas_error (line 725) | bool
function tsk_get_kas_error (line 731) | int
function __tsk_safe_free (line 747) | void
function tsk_blkalloc_print_state (line 762) | void
function tsk_blkalloc_reset (line 773) | int TSK_WARN_UNUSED
function tsk_blkalloc_init (line 784) | int TSK_WARN_UNUSED
function tsk_blkalloc_free (line 850) | void
function tsk_size_t (line 867) | tsk_size_t
function tsk_round (line 898) | double
function tsk_is_unknown_time (line 918) | bool
function tsk_isnan (line 941) | bool
function tsk_isfinite (line 951) | bool
function tsk_memcmp (line 1022) | int
function tsk_set_debug_stream (line 1035) | void
function FILE (line 1041) | FILE *
function tsk_avl_tree_int_print_node (line 1055) | static void
function tsk_avl_tree_int_print_state (line 1070) | void
function tsk_avl_tree_int_init (line 1077) | int
function tsk_avl_tree_int_free (line 1084) | int
function tsk_avl_node_int_t (line 1090) | tsk_avl_node_int_t *
function tsk_avl_node_int_t (line 1096) | tsk_avl_node_int_t *
function tsk_avl_tree_int_insert_empty (line 1113) | static int
function tsk_avl_tree_int_insert_non_empty (line 1135) | static int
function tsk_avl_tree_int_insert (line 1233) | int
function ordered_nodes_traverse (line 1253) | static int
function tsk_avl_tree_int_ordered_nodes (line 1264) | int
function tsk_bitset_init (line 1274) | int
function tsk_bitset_intersect (line 1292) | void
function tsk_bitset_subtract (line 1304) | void
function tsk_bitset_union (line 1315) | void
function tsk_bitset_set_bit (line 1326) | void
function tsk_bitset_contains (line 1334) | bool
function popcount (line 1342) | static inline uint32_t
function tsk_size_t (line 1364) | tsk_size_t
function tsk_bitset_get_items (line 1377) | void
function tsk_bitset_free (line 1407) | void
FILE: c/tskit/core.h
type tsk_id_t (line 95) | typedef int64_t tsk_id_t;
type tsk_id_t (line 99) | typedef int32_t tsk_id_t;
type tsk_size_t (line 111) | typedef uint64_t tsk_size_t;
type tsk_flags_t (line 123) | typedef uint32_t tsk_flags_t;
type tsk_bool_t (line 133) | typedef uint8_t tsk_bool_t;
function __tsk_nan_f (line 165) | static inline double
function _tsk_trace_error (line 982) | static inline int
type tsk_blkalloc_t (line 1044) | typedef struct {
type tsk_avl_node_int_t (line 1060) | typedef struct _tsk_avl_node_int_t {
type tsk_avl_tree_int_t (line 1071) | typedef struct {
type tsk_bitset_val_t (line 1134) | typedef uint32_t tsk_bitset_val_t;
type tsk_bitset_t (line 1136) | typedef struct {
FILE: c/tskit/genotypes.c
function tsk_variant_print_state (line 38) | void
function tsk_vargen_print_state (line 53) | void
function tsk_variant_copy_alleles (line 61) | static int
function variant_init_samples_and_index_map (line 91) | static int
function tsk_variant_init (line 128) | int
function tsk_vargen_init (line 237) | int
function tsk_variant_free (line 258) | int
function tsk_vargen_free (line 275) | int
function tsk_variant_expand_alleles (line 282) | static int
function tsk_variant_update_genotypes_sample_list (line 317) | static int TSK_WARN_UNUSED
function tsk_variant_traverse (line 355) | static int TSK_WARN_UNUSED
function tsk_variant_visit (line 391) | static int
function tsk_variant_update_genotypes_traversal (line 406) | static int TSK_WARN_UNUSED
function tsk_size_t (line 413) | static tsk_size_t
function tsk_size_t (line 438) | static tsk_size_t
function tsk_id_t (line 457) | static tsk_id_t
function tsk_variant_decode (line 473) | int
function tsk_variant_restricted_copy (line 596) | int
function tsk_vargen_next (line 649) | int
function tsk_treeseq_decode_alignments_overlay_missing (line 667) | static int
function tsk_treeseq_decode_alignments_overlay_sites (line 720) | static int
function tsk_treeseq_decode_alignments (line 804) | int
FILE: c/tskit/genotypes.h
type tsk_variant_t (line 45) | typedef struct {
type tsk_vargen_t (line 83) | typedef struct {
FILE: c/tskit/haplotype_matching.c
function cmp_double (line 39) | static int
function cmp_argsort (line 47) | static int
function tsk_ls_hmm_check_state (line 60) | static void
function tsk_ls_hmm_print_state (line 84) | void
function tsk_ls_hmm_init (line 121) | int TSK_WARN_UNUSED
function tsk_ls_hmm_set_precision (line 201) | int
function tsk_ls_hmm_free (line 208) | int
function tsk_ls_hmm_reset (line 231) | static int
function tsk_ls_hmm_remove_dead_roots (line 262) | static int
function tsk_ls_hmm_update_tree (line 294) | static int
function tsk_ls_hmm_get_allele_index (line 363) | static int
function tsk_ls_hmm_update_probabilities (line 387) | static int
function tsk_ls_hmm_discretise_values (line 467) | static int
function tsk_id_t (line 512) | static inline tsk_id_t
function set_bit (line 530) | static inline uint64_t
function bit_is_set (line 536) | static inline bool
function tsk_id_t (line 542) | static inline tsk_id_t
function all_zero (line 559) | static inline bool
function element_in (line 571) | static inline bool
function set_optimal_value (line 579) | static inline void
function compute_optimal_value_1 (line 595) | static void
function compute_optimal_value_general (line 631) | static void
function compute_optimal_value (line 689) | static void
function tsk_ls_hmm_setup_optimal_value_sets (line 702) | static int
function tsk_ls_hmm_build_optimal_value_sets (line 733) | static int
function tsk_ls_hmm_redistribute_transitions (line 791) | static int
function tsk_ls_hmm_compress (line 889) | static int
function tsk_ls_hmm_process_site_forward (line 914) | static int
function tsk_ls_hmm_run_forward (line 954) | static int
function tsk_ls_hmm_compute_normalisation_factor_forward (line 1001) | static double
function tsk_ls_hmm_next_probability_forward (line 1031) | static int
function tsk_ls_hmm_forward (line 1050) | int
function tsk_ls_hmm_next_probability_backward (line 1085) | static int
function tsk_ls_hmm_process_site_backward (line 1101) | static int
function tsk_ls_hmm_run_backward (line 1152) | static int
function tsk_ls_hmm_backward (line 1208) | int
function tsk_ls_hmm_compute_normalisation_factor_viterbi (line 1243) | static double
function tsk_ls_hmm_next_probability_viterbi (line 1263) | static int
function tsk_ls_hmm_viterbi (line 1291) | int
function tsk_compressed_matrix_init (line 1326) | int
function tsk_compressed_matrix_free (line 1358) | int
function tsk_compressed_matrix_clear (line 1369) | int
function tsk_compressed_matrix_print_state (line 1380) | void
function tsk_compressed_matrix_store_site (line 1405) | int
function tsk_compressed_matrix_decode_site (line 1439) | static int
function tsk_compressed_matrix_decode (line 1478) | int
function tsk_viterbi_matrix_expand_recomb_records (line 1527) | static int
function tsk_viterbi_matrix_init (line 1543) | int
function tsk_viterbi_matrix_free (line 1572) | int
function tsk_viterbi_matrix_clear (line 1580) | int
function tsk_viterbi_matrix_print_state (line 1588) | void
function TSK_WARN_UNUSED (line 1611) | TSK_WARN_UNUSED int
function tsk_id_t (line 1634) | static tsk_id_t
function tsk_viterbi_matrix_traceback (line 1684) | int
FILE: c/tskit/haplotype_matching.h
type tsk_value_transition_t (line 38) | typedef struct {
type tsk_argsort_t (line 44) | typedef struct {
type tsk_transition_stack_t (line 49) | typedef struct {
type tsk_site_probability_t (line 56) | typedef struct {
type tsk_compressed_matrix_t (line 63) | typedef struct {
type tsk_recomb_required_record (line 75) | typedef struct {
type tsk_viterbi_matrix_t (line 81) | typedef struct {
type tsk_ls_hmm_t (line 88) | typedef struct _tsk_ls_hmm_t {
FILE: c/tskit/stats.c
function tsk_ld_calc_print_state (line 33) | void
function tsk_ld_calc_init (line 41) | int TSK_WARN_UNUSED
function tsk_ld_calc_free (line 63) | int
function tsk_ld_calc_check_site (line 71) | static int
function tsk_ld_calc_set_focal_samples (line 93) | static int
function tsk_ld_calc_initialise (line 108) | static int
function tsk_ld_calc_compute_r2 (line 133) | static int
function tsk_ld_calc_compute_and_append (line 155) | static int
function tsk_ld_calc_run_forward (line 178) | static int
function tsk_ld_calc_run_reverse (line 215) | static int
function tsk_ld_calc_get_r2 (line 252) | int
function tsk_ld_calc_get_r2_array (line 278) | int
FILE: c/tskit/stats.h
type tsk_ld_calc_t (line 35) | typedef struct {
FILE: c/tskit/tables.c
type read_table_col_t (line 41) | typedef struct {
type read_table_ragged_col_t (line 48) | typedef struct {
type read_table_property_t (line 57) | typedef struct {
type write_table_col_t (line 65) | typedef struct {
type write_table_ragged_col_t (line 72) | typedef struct {
function check_table_overflow (line 85) | static bool
function check_offset_overflow (line 95) | static bool
function read_table_cols (line 106) | static int
function cast_offset_array (line 148) | static int
function read_table_ragged_cols (line 168) | static int
function read_table_properties (line 268) | static int
function read_table (line 302) | static int
function free_read_table_mem (line 336) | static void
function write_offset_col (line 362) | static int
function write_table_ragged_cols (line 407) | static int
function write_table_cols (line 430) | static int
function write_table (line 449) | static int
function check_offsets (line 467) | static int
function calculate_max_rows (line 493) | static int
function calculate_max_length (line 535) | static int
function expand_column (line 582) | static int
function expand_ragged_column (line 598) | static int
function replace_string (line 624) | static int
function takeset_string (line 644) | static int
function alloc_empty_ragged_column (line 653) | static int
function check_ragged_column (line 668) | static int
function takeset_ragged_column (line 686) | static int
function takeset_optional_id_column (line 705) | static int
function write_metadata_schema_header (line 728) | static int
function tsk_size_t (line 740) | static tsk_size_t
function keep_mask_to_id_map (line 754) | static void
function tsk_size_t (line 770) | static tsk_size_t
function tsk_size_t (line 796) | static tsk_size_t
function tsk_size_t (line 812) | static tsk_size_t
function tsk_size_t (line 828) | static tsk_size_t
function tsk_size_t (line 844) | static tsk_size_t
function tsk_size_t (line 868) | static tsk_size_t
function tsk_size_t (line 892) | static tsk_size_t
function tsk_reference_sequence_init (line 924) | int
function tsk_reference_sequence_free (line 932) | int
function tsk_reference_sequence_is_null (line 942) | bool
function tsk_reference_sequence_equals (line 949) | bool
function tsk_reference_sequence_copy (line 972) | int
function tsk_reference_sequence_set_data (line 1012) | int
function tsk_reference_sequence_set_url (line 1019) | int
function tsk_reference_sequence_set_metadata (line 1026) | int
function tsk_reference_sequence_set_metadata_schema (line 1034) | int
function tsk_reference_sequence_takeset_data (line 1042) | int
function tsk_reference_sequence_takeset_metadata (line 1049) | int
function tsk_individual_table_free_columns (line 1061) | static void
function tsk_individual_table_free (line 1073) | int
function tsk_individual_table_expand_main_columns (line 1081) | static int
function tsk_individual_table_expand_location (line 1119) | static int
function tsk_individual_table_expand_parents (line 1128) | static int
function tsk_individual_table_expand_metadata (line 1137) | static int
function tsk_individual_table_set_max_rows_increment (line 1146) | int
function tsk_individual_table_set_max_metadata_length_increment (line 1154) | int
function tsk_individual_table_set_max_location_length_increment (line 1162) | int
function tsk_individual_table_set_max_parents_length_increment (line 1170) | int
function tsk_individual_table_init (line 1178) | int
function tsk_individual_table_copy (line 1218) | int TSK_WARN_UNUSED
function tsk_individual_table_set_columns (line 1242) | int TSK_WARN_UNUSED
function tsk_individual_table_takeset_columns (line 1260) | int TSK_WARN_UNUSED
function tsk_individual_table_append_columns (line 1316) | int
function tsk_id_t (line 1423) | static tsk_id_t
function tsk_id_t (line 1449) | tsk_id_t
function tsk_individual_table_update_row_rewrite (line 1478) | static int
function tsk_individual_table_update_row (line 1523) | int
function tsk_individual_table_clear (line 1559) | int
function tsk_individual_table_truncate (line 1565) | int
function tsk_individual_table_extend (line 1582) | int
function tsk_individual_table_print_state (line 1621) | void
function tsk_individual_table_get_row_unsafe (line 1668) | static inline void
function tsk_individual_table_get_row (line 1688) | int
function tsk_individual_table_set_metadata_schema (line 1703) | int
function tsk_individual_table_dump_text (line 1711) | int
function tsk_individual_table_equals (line 1773) | bool
function tsk_individual_table_keep_rows (line 1810) | int
function tsk_individual_table_dump (line 1875) | static int
function tsk_individual_table_load (line 1899) | static int
function tsk_node_table_free_columns (line 1966) | static void
function tsk_node_table_free (line 1977) | int
function tsk_node_table_expand_main_columns (line 1985) | static int
function tsk_node_table_expand_metadata (line 2025) | static int
function tsk_node_table_set_max_rows_increment (line 2033) | int
function tsk_node_table_set_max_metadata_length_increment (line 2041) | int
function tsk_node_table_init (line 2049) | int
function tsk_node_table_copy (line 2075) | int TSK_WARN_UNUSED
function tsk_node_table_set_columns (line 2098) | int TSK_WARN_UNUSED
function tsk_node_table_takeset_columns (line 2115) | int TSK_WARN_UNUSED
function tsk_node_table_append_columns (line 2156) | int
function tsk_id_t (line 2220) | static tsk_id_t
function tsk_id_t (line 2238) | tsk_id_t
function tsk_node_table_update_row_rewrite (line 2259) | static int
function tsk_node_table_update_row (line 2303) | int
function tsk_node_table_clear (line 2335) | int TSK_WARN_UNUSED
function tsk_node_table_truncate (line 2341) | int
function tsk_node_table_extend (line 2356) | int
function tsk_node_table_print_state (line 2393) | void
function tsk_node_table_set_metadata_schema (line 2425) | int
function tsk_node_table_dump_text (line 2433) | int
function tsk_node_table_equals (line 2465) | bool
function tsk_node_table_get_row_unsafe (line 2496) | static inline void
function tsk_node_table_get_row (line 2510) | int
function tsk_node_table_keep_rows (line 2524) | int
function tsk_node_table_dump (line 2547) | static int
function tsk_node_table_load (line 2570) | static int
function tsk_edge_table_free_columns (line 2631) | static void
function tsk_edge_table_free (line 2642) | int
function tsk_edge_table_has_metadata (line 2650) | static int
function tsk_edge_table_expand_main_columns (line 2656) | static int
function tsk_edge_table_expand_metadata (line 2697) | static int
function tsk_edge_table_set_max_rows_increment (line 2705) | int
function tsk_edge_table_set_max_metadata_length_increment (line 2713) | int
function tsk_edge_table_init (line 2721) | int
function tsk_id_t (line 2751) | tsk_id_t
function tsk_edge_table_update_row_rewrite (line 2791) | static int
function tsk_edge_table_update_row (line 2835) | int
function tsk_edge_table_copy (line 2869) | int TSK_WARN_UNUSED
function tsk_edge_table_set_columns (line 2906) | int
function tsk_edge_table_takeset_columns (line 2923) | int TSK_WARN_UNUSED
function tsk_edge_table_append_columns (line 2961) | int
function tsk_edge_table_clear (line 3022) | int
function tsk_edge_table_truncate (line 3028) | int
function tsk_edge_table_extend (line 3045) | int
function tsk_edge_table_get_row_unsafe (line 3082) | static inline void
function tsk_edge_table_get_row (line 3101) | int
function tsk_edge_table_print_state (line 3115) | void
function tsk_edge_table_set_metadata_schema (line 3134) | int
function tsk_edge_table_dump_text (line 3142) | int
function tsk_edge_table_equals (line 3173) | bool
function tsk_edge_table_keep_rows (line 3216) | int
function tsk_edge_table_dump (line 3239) | static int
function tsk_edge_table_load (line 3275) | static int
function tsk_edge_table_squash (line 3333) | int
function tsk_site_table_free_columns (line 3382) | static void
function tsk_site_table_free (line 3392) | int
function tsk_site_table_expand_main_columns (line 3400) | static int
function tsk_site_table_expand_ancestral_state (line 3432) | static int
function tsk_site_table_expand_metadata (line 3441) | static int
function tsk_site_table_set_max_rows_increment (line 3449) | int
function tsk_site_table_set_max_metadata_length_increment (line 3457) | int
function tsk_site_table_set_max_ancestral_state_length_increment (line 3465) | int
function tsk_site_table_init (line 3473) | int
function tsk_id_t (line 3507) | tsk_id_t
function tsk_site_table_update_row_rewrite (line 3549) | static int
function tsk_site_table_update_row (line 3593) | int
function tsk_site_table_append_columns (line 3625) | int
function tsk_site_table_copy (line 3699) | int TSK_WARN_UNUSED
function tsk_site_table_set_columns (line 3723) | int
function tsk_site_table_takeset_columns (line 3741) | int
function tsk_site_table_equals (line 3782) | bool
function tsk_site_table_clear (line 3813) | int
function tsk_site_table_truncate (line 3819) | int
function tsk_site_table_extend (line 3835) | int
function tsk_site_table_print_state (line 3872) | void
function tsk_site_table_get_row_unsafe (line 3900) | static inline void
function tsk_site_table_get_row (line 3918) | int
function tsk_site_table_set_metadata_schema (line 3932) | int
function tsk_site_table_dump_text (line 3940) | int
function tsk_site_table_keep_rows (line 3974) | int
function tsk_site_table_dump (line 3996) | static int
function tsk_site_table_load (line 4017) | static int
function tsk_mutation_table_free_columns (line 4077) | static void
function tsk_mutation_table_free (line 4090) | int
function tsk_mutation_table_expand_main_columns (line 4098) | static int
function tsk_mutation_table_expand_derived_state (line 4143) | static int
function tsk_mutation_table_expand_metadata (line 4152) | static int
function tsk_mutation_table_set_max_rows_increment (line 4161) | int
function tsk_mutation_table_set_max_metadata_length_increment (line 4169) | int
function tsk_mutation_table_set_max_derived_state_length_increment (line 4177) | int
function tsk_mutation_table_init (line 4185) | int
function tsk_id_t (line 4219) | tsk_id_t
function tsk_mutation_table_update_row_rewrite (line 4263) | static int
function tsk_mutation_table_update_row (line 4308) | int
function tsk_mutation_table_append_columns (line 4343) | int
function tsk_mutation_table_takeset_columns (line 4434) | int TSK_WARN_UNUSED
function tsk_mutation_table_copy (line 4497) | int TSK_WARN_UNUSED
function tsk_mutation_table_set_columns (line 4521) | int
function tsk_mutation_table_equals (line 4540) | bool
function tsk_mutation_table_clear (line 4577) | int
function tsk_mutation_table_truncate (line 4583) | int
function tsk_mutation_table_extend (line 4599) | int
function tsk_mutation_table_print_state (line 4637) | void
function tsk_mutation_table_get_row_unsafe (line 4664) | static inline void
function tsk_mutation_table_get_row (line 4682) | int
function tsk_mutation_table_set_metadata_schema (line 4697) | int
function tsk_mutation_table_dump_text (line 4705) | int
function tsk_mutation_table_keep_rows (line 4739) | int
function tsk_mutation_table_dump (line 4798) | static int
function tsk_mutation_table_load (line 4824) | static int
function tsk_migration_table_free_columns (line 4893) | static void
function tsk_migration_table_free (line 4906) | int
function tsk_migration_table_expand_main_columns (line 4914) | static int
function tsk_migration_table_expand_metadata (line 4963) | static int
function tsk_migration_table_set_max_rows_increment (line 4972) | int
function tsk_migration_table_set_max_metadata_length_increment (line 4980) | int
function tsk_migration_table_init (line 4988) | int
function tsk_migration_table_append_columns (line 5015) | int
function tsk_migration_table_takeset_columns (line 5073) | int TSK_WARN_UNUSED
function tsk_migration_table_copy (line 5111) | int TSK_WARN_UNUSED
function tsk_migration_table_set_columns (line 5135) | int
function tsk_id_t (line 5153) | tsk_id_t
function tsk_migration_table_update_row_rewrite (line 5187) | static int
function tsk_migration_table_update_row (line 5231) | int
function tsk_migration_table_clear (line 5265) | int
function tsk_migration_table_truncate (line 5271) | int
function tsk_migration_table_extend (line 5286) | int
function tsk_migration_table_print_state (line 5325) | void
function tsk_migration_table_get_row_unsafe (line 5343) | static inline void
function tsk_migration_table_get_row (line 5359) | int
function tsk_migration_table_set_metadata_schema (line 5374) | int
function tsk_migration_table_dump_text (line 5382) | int
function tsk_migration_table_equals (line 5414) | bool
function tsk_migration_table_keep_rows (line 5443) | int
function tsk_migration_table_dump (line 5468) | static int
function tsk_migration_table_load (line 5493) | static int
function tsk_population_table_free_columns (line 5562) | static void
function tsk_population_table_free (line 5569) | int
function tsk_population_table_expand_main_columns (line 5577) | static int
function tsk_population_table_expand_metadata (line 5601) | static int
function tsk_population_table_set_max_rows_increment (line 5610) | int
function tsk_population_table_set_max_metadata_length_increment (line 5618) | int
function tsk_population_table_init (line 5626) | int
function tsk_population_table_copy (line 5652) | int TSK_WARN_UNUSED
function tsk_population_table_set_columns (line 5675) | int
function tsk_population_table_append_columns (line 5690) | int
function tsk_population_table_takeset_columns (line 5729) | int
function tsk_id_t (line 5758) | static tsk_id_t
function tsk_id_t (line 5774) | tsk_id_t
function tsk_population_table_update_row_rewrite (line 5793) | static int
function tsk_population_table_update_row (line 5835) | int
function tsk_population_table_clear (line 5862) | int
function tsk_population_table_truncate (line 5868) | int
function tsk_population_table_extend (line 5883) | int
function tsk_population_table_print_state (line 5921) | void
function tsk_population_table_get_row_unsafe (line 5950) | static inline void
function tsk_population_table_get_row (line 5960) | int
function tsk_population_table_set_metadata_schema (line 5975) | int
function tsk_population_table_dump_text (line 5983) | int
function tsk_population_table_equals (line 6013) | bool
function tsk_population_table_keep_rows (line 6037) | int
function tsk_population_table_dump (line 6055) | static int
function tsk_population_table_load (line 6073) | static int
function tsk_provenance_table_free_columns (line 6121) | static void
function tsk_provenance_table_free (line 6130) | int
function tsk_provenance_table_expand_main_columns (line 6137) | static int
function tsk_provenance_table_expand_timestamp (line 6166) | static int
function tsk_provenance_table_expand_record (line 6175) | static int
function tsk_provenance_table_set_max_rows_increment (line 6184) | int
function tsk_provenance_table_set_max_timestamp_length_increment (line 6192) | int
function tsk_provenance_table_set_max_record_length_increment (line 6200) | int
function tsk_provenance_table_init (line 6208) | int
function tsk_provenance_table_copy (line 6240) | int TSK_WARN_UNUSED
function tsk_provenance_table_set_columns (line 6258) | int
function tsk_provenance_table_append_columns (line 6275) | int
function tsk_provenance_table_takeset_columns (line 6332) | int
function tsk_id_t (line 6372) | static tsk_id_t
function tsk_id_t (line 6395) | tsk_id_t
function tsk_provenance_table_update_row_rewrite (line 6419) | static int
function tsk_provenance_table_update_row (line 6463) | int
function tsk_provenance_table_clear (line 6494) | int
function tsk_provenance_table_truncate (line 6500) | int
function tsk_provenance_table_extend (line 6516) | int
function tsk_provenance_table_print_state (line 6554) | void
function tsk_provenance_table_get_row_unsafe (line 6590) | static inline void
function tsk_provenance_table_get_row (line 6602) | int
function tsk_provenance_table_dump_text (line 6617) | int
function tsk_provenance_table_equals (line 6643) | bool
function tsk_provenance_table_keep_rows (line 6667) | int
function tsk_provenance_table_dump (line 6685) | static int
function tsk_provenance_table_load (line 6700) | static int
type edge_sort_t (line 6741) | typedef struct {
type mutation_sort_t (line 6756) | typedef struct {
type individual_canonical_sort_t (line 6762) | typedef struct {
type migration_sort_t (line 6768) | typedef struct {
function cmp_site (line 6779) | static int
function cmp_mutation (line 6798) | static int
function cmp_individual_canonical (line 6831) | static int
function cmp_edge (line 6847) | static int
function cmp_migration (line 6869) | static int
function tsk_table_sorter_sort_edges (line 6895) | static int
function tsk_table_sorter_sort_migrations (line 6950) | static int
function tsk_table_sorter_sort_sites (line 7002) | static int
function tsk_table_sorter_sort_mutations (line 7049) | static int
function tsk_individual_table_topological_sort (line 7131) | static int
function tsk_table_collection_individual_topological_sort (line 7209) | int
function tsk_table_sorter_sort_individuals_canonical (line 7284) | static int
function tsk_table_sorter_run (line 7383) | int
function tsk_table_sorter_init (line 7454) | int
function tsk_table_sorter_free (line 7486) | int
type interval_list_t (line 7497) | typedef struct _interval_list_t {
type mutation_id_list_t (line 7503) | typedef struct _mutation_id_list_t {
type tsk_segment_t (line 7508) | typedef struct _tsk_segment_t {
type segment_overlapper_t (line 7516) | typedef struct {
type simplifier_t (line 7530) | typedef struct {
function cmp_segment (line 7567) | static int
function segment_overlapper_alloc (line 7580) | static int TSK_WARN_UNUSED
function segment_overlapper_free (line 7596) | static int
function segment_overlapper_start (line 7606) | static int TSK_WARN_UNUSED
function segment_overlapper_next (line 7642) | static int TSK_WARN_UNUSED
function cmp_node_id (line 7703) | static int
type ancestor_mapper_t (line 7720) | typedef struct {
function tsk_segment_t (line 7745) | static tsk_segment_t *TSK_WARN_UNUSED
function interval_list_t (line 7763) | static interval_list_t *TSK_WARN_UNUSED
function ancestor_mapper_flush_edges (line 7779) | static int
function ancestor_mapper_record_edge (line 7813) | static int
function ancestor_mapper_add_ancestry (line 7849) | static int TSK_WARN_UNUSED
function ancestor_mapper_find_oldest_node (line 7883) | static void
function ancestor_mapper_init_samples (line 7900) | static int
function ancestor_mapper_init_ancestors (line 7927) | static int
function ancestor_mapper_init (line 7949) | static int
function ancestor_mapper_free (line 8023) | static int
function ancestor_mapper_enqueue_segment (line 8040) | static int TSK_WARN_UNUSED
function ancestor_mapper_merge_ancestors (line 8070) | static int TSK_WARN_UNUSED
function ancestor_mapper_process_parent_edges (line 8147) | static int TSK_WARN_UNUSED
function ancestor_mapper_run (line 8186) | static int TSK_WARN_UNUSED
function pair_to_integer (line 8243) | static inline int64_t
function integer_to_pair (line 8255) | static inline void
function tsk_identity_segments_get_key (line 8262) | static int64_t
function tsk_identity_segment_t (line 8282) | static tsk_identity_segment_t *TSK_WARN_UNUSED
function tsk_avl_node_int_t (line 8301) | static tsk_avl_node_int_t *
function tsk_identity_segments_init (line 8318) | static int
function tsk_identity_segments_print_state (line 8350) | void
function tsk_size_t (line 8390) | tsk_size_t
function tsk_identity_segments_get_total_span (line 8396) | double
function tsk_size_t (line 8402) | tsk_size_t
function get_keys_traverse (line 8412) | static int
function tsk_identity_segments_get_keys (line 8427) | int
function get_items_traverse (line 8438) | static int
function tsk_identity_segments_get_items (line 8455) | int
function tsk_identity_segments_free (line 8467) | int
function tsk_identity_segments_update_pair (line 8475) | static int TSK_WARN_UNUSED
function tsk_identity_segments_add_segment (line 8516) | static int TSK_WARN_UNUSED
function tsk_identity_segments_get (line 8534) | int TSK_WARN_UNUSED
type tsk_ibd_finder_t (line 8563) | typedef struct {
function tsk_segment_t (line 8581) | static tsk_segment_t *TSK_WARN_UNUSED
function tsk_ibd_finder_add_ancestry (line 8599) | static int TSK_WARN_UNUSED
function tsk_ibd_finder_init_samples_from_set (line 8624) | static int
function tsk_ibd_finder_init_samples_from_nodes (line 8649) | static void
function tsk_ibd_finder_add_sample_ancestry (line 8663) | static int
function tsk_ibd_finder_init (line 8684) | static int TSK_WARN_UNUSED
function tsk_ibd_finder_enqueue_segment (line 8730) | static int TSK_WARN_UNUSED
function tsk_ibd_finder_passes_filters (line 8761) | static bool
function tsk_ibd_finder_record_ibd (line 8778) | static int TSK_WARN_UNUSED
function tsk_ibd_finder_add_queued_ancestry (line 8805) | static int TSK_WARN_UNUSED
function tsk_ibd_finder_print_state (line 8824) | static void
function tsk_ibd_finder_init_within (line 8857) | static int TSK_WARN_UNUSED
function tsk_ibd_finder_init_between (line 8877) | static int TSK_WARN_UNUSED
function tsk_ibd_finder_run (line 8907) | static int TSK_WARN_UNUSED
function tsk_ibd_finder_free (line 8949) | static int
function simplifier_check_state (line 8964) | static void
function print_segment_chain (line 9044) | static void
function simplifier_print_state (line 9054) | static void
function tsk_segment_t (line 9141) | static tsk_segment_t *TSK_WARN_UNUSED
function interval_list_t (line 9158) | static interval_list_t *TSK_WARN_UNUSED
function tsk_id_t (line 9176) | static tsk_id_t TSK_WARN_UNUSED
function simplifier_rewind_node (line 9196) | static int
function simplifier_flush_edges (line 9203) | static int
function simplifier_init_position_lookup (line 9239) | static int
function simplifier_map_reduced_coordinates (line 9263) | static bool
function simplifier_record_edge (line 9287) | static int
function simplifier_init_sites (line 9332) | static int
function simplifier_map_mutations (line 9373) | static void
function simplifier_add_ancestry (line 9392) | static int TSK_WARN_UNUSED
function simplifier_init_tables (line 9429) | static int
function simplifier_init_nodes (line 9474) | static int
function simplifier_init (line 9525) | static int
function simplifier_free (line 9624) | static int
function simplifier_enqueue_segment (line 9647) | static int TSK_WARN_UNUSED
function simplifier_merge_ancestors (line 9676) | static int TSK_WARN_UNUSED
function simplifier_extract_ancestry (line 9790) | static int TSK_WARN_UNUSED
function simplifier_process_parent_edges (line 9853) | static int TSK_WARN_UNUSED
function simplifier_finalise_site_references (line 9884) | static int TSK_WARN_UNUSED
function simplifier_finalise_population_references (line 9920) | static int TSK_WARN_UNUSED
function simplifier_finalise_individual_references (line 9977) | static int TSK_WARN_UNUSED
function simplifier_output_sites (line 10049) | static int TSK_WARN_UNUSED
function simplifier_flush_output (line 10109) | static int TSK_WARN_UNUSED
function simplifier_set_edge_sort_offset (line 10150) | static void
function simplifier_sort_edges (line 10165) | static int TSK_WARN_UNUSED
function simplifier_insert_input_roots (line 10179) | static int TSK_WARN_UNUSED
function simplifier_run (line 10226) | static int TSK_WARN_UNUSED
type index_sort_t (line 10284) | typedef struct {
function cmp_index_sort (line 10293) | static int
function tsk_table_collection_check_offsets (line 10311) | static int
function tsk_table_collection_check_node_integrity (line 10361) | static int
function tsk_table_collection_check_edge_integrity (line 10396) | static int
function tsk_table_collection_check_site_integrity (line 10509) | static int TSK_WARN_UNUSED
function tsk_table_collection_check_mutation_integrity (line 10547) | static int TSK_WARN_UNUSED
function tsk_table_collection_check_migration_integrity (line 10662) | static int TSK_WARN_UNUSED
function tsk_table_collection_check_individual_integrity (line 10727) | static int TSK_WARN_UNUSED
function tsk_id_t (line 10764) | static tsk_id_t TSK_WARN_UNUSED
function tsk_table_collection_check_index_integrity (line 10893) | static int TSK_WARN_UNUSED
function tsk_table_collection_compute_mutation_parents_to_array (line 10920) | static int TSK_WARN_UNUSED
function tsk_table_collection_check_mutation_parents (line 11027) | static int TSK_WARN_UNUSED
function tsk_id_t (line 11062) | tsk_id_t TSK_WARN_UNUSED
function tsk_table_collection_print_state (line 11138) | void
function tsk_table_collection_init (line 11162) | int TSK_WARN_UNUSED
function tsk_table_collection_free (line 11220) | int
function tsk_table_collection_equals (line 11241) | bool
function tsk_table_collection_set_time_units (line 11293) | int
function tsk_table_collection_set_metadata (line 11301) | int
function tsk_table_collection_takeset_metadata (line 11309) | int
function tsk_table_collection_set_metadata_schema (line 11317) | int
function tsk_table_collection_set_indexes (line 11325) | int
function tsk_table_collection_takeset_indexes (line 11347) | int
function tsk_table_collection_has_index (line 11365) | bool
function tsk_table_collection_has_reference_sequence (line 11374) | bool
function tsk_table_collection_drop_index (line 11380) | int
function tsk_table_collection_build_index (line 11392) | int TSK_WARN_UNUSED
function tsk_table_collection_set_file_uuid (line 11460) | static int TSK_WARN_UNUSED
function tsk_table_collection_copy (line 11482) | int TSK_WARN_UNUSED
function tsk_table_collection_read_format_data (line 11571) | static int TSK_WARN_UNUSED
function tsk_table_collection_dump_indexes (line 11721) | static int TSK_WARN_UNUSED
function tsk_table_collection_load_indexes (line 11742) | static int TSK_WARN_UNUSED
function tsk_table_collection_load_reference_sequence (line 11787) | static int
function tsk_table_collection_loadf_inited (line 11850) | static int TSK_WARN_UNUSED
function tsk_table_collection_loadf (line 11942) | int TSK_WARN_UNUSED
function tsk_table_collection_load (line 11961) | int TSK_WARN_UNUSED
function tsk_table_collection_dump_reference_sequence (line 11997) | static int TSK_WARN_UNUSED
function tsk_table_collection_dump (line 12018) | int TSK_WARN_UNUSED
function tsk_table_collection_dumpf (line 12049) | int TSK_WARN_UNUSED
function tsk_table_collection_simplify (line 12147) | int TSK_WARN_UNUSED
function tsk_table_collection_link_ancestors (line 12207) | int TSK_WARN_UNUSED
function tsk_table_collection_ibd_within (line 12236) | int TSK_WARN_UNUSED
function tsk_table_collection_ibd_between (line 12268) | int TSK_WARN_UNUSED
function tsk_table_collection_sort (line 12302) | int TSK_WARN_UNUSED
function tsk_table_collection_canonicalise (line 12322) | int TSK_WARN_UNUSED
function tsk_table_collection_deduplicate_sites (line 12364) | int TSK_WARN_UNUSED
function tsk_table_collection_compute_mutation_parents (line 12434) | int TSK_WARN_UNUSED
function tsk_table_collection_compute_mutation_times (line 12482) | int TSK_WARN_UNUSED
function tsk_table_collection_delete_older (line 12612) | int TSK_WARN_UNUSED
function tsk_table_collection_record_num_rows (line 12722) | int
function tsk_table_collection_truncate (line 12737) | int TSK_WARN_UNUSED
function tsk_table_collection_clear (line 12782) | int TSK_WARN_UNUSED
function tsk_table_collection_add_and_remap_node (line 12843) | static int
function tsk_table_collection_subset (line 12911) | int TSK_WARN_UNUSED
function tsk_check_subset_equality (line 13142) | static int
function tsk_table_collection_union (line 13211) | int TSK_WARN_UNUSED
function cmp_edge_cl (line 13420) | static int
function tsk_squash_edges (line 13439) | int TSK_WARN_UNUSED
FILE: c/tskit/tables.h
type tsk_individual_t (line 57) | typedef struct {
type tsk_node_t (line 89) | typedef struct {
type tsk_edge_t (line 114) | typedef struct {
type tsk_mutation_t (line 139) | typedef struct {
type tsk_site_t (line 175) | typedef struct {
type tsk_migration_t (line 202) | typedef struct {
type tsk_population_t (line 232) | typedef struct {
type tsk_provenance_t (line 250) | typedef struct {
type tsk_individual_table_t (line 275) | typedef struct {
type tsk_node_table_t (line 319) | typedef struct {
type tsk_edge_table_t (line 353) | typedef struct {
type tsk_migration_table_t (line 389) | typedef struct {
type tsk_site_table_t (line 427) | typedef struct {
type tsk_mutation_table_t (line 462) | typedef struct {
type tsk_population_table_t (line 503) | typedef struct {
type tsk_provenance_table_t (line 529) | typedef struct {
type tsk_reference_sequence_t (line 552) | typedef struct {
type tsk_table_collection_t (line 566) | typedef struct {
type tsk_bookmark_t (line 606) | typedef struct {
type tsk_table_sorter_t (line 628) | typedef struct _tsk_table_sorter_t {
type tsk_identity_segment_t (line 653) | typedef struct _tsk_identity_segment_t {
type tsk_identity_segment_list_t (line 660) | typedef struct {
type tsk_identity_segments_t (line 667) | typedef struct {
type tsk_edge_list_node_t (line 678) | typedef struct _tsk_edge_list_node_t {
type tsk_edge_list_t (line 684) | typedef struct {
type _tsk_table_sorter_t (line 4722) | struct _tsk_table_sorter_t
type _tsk_table_sorter_t (line 4756) | struct _tsk_table_sorter_t
type _tsk_table_sorter_t (line 4764) | struct _tsk_table_sorter_t
FILE: c/tskit/trees.c
function is_discrete (line 36) | static inline bool
function tsk_treeseq_check_state (line 46) | static void
function tsk_treeseq_print_state (line 66) | void
function tsk_treeseq_free (line 106) | int
function tsk_treeseq_init_sites (line 128) | static int
function tsk_treeseq_init_individuals (line 181) | static int
function tsk_treeseq_init_trees (line 243) | static int
function tsk_treeseq_init_migrations (line 361) | static void
function tsk_treeseq_init_mutations (line 382) | static void
function tsk_treeseq_init_nodes (line 404) | static int
function tsk_treeseq_init (line 455) | int TSK_WARN_UNUSED
function tsk_treeseq_copy_tables (line 547) | int TSK_WARN_UNUSED
function tsk_treeseq_load (line 554) | int TSK_WARN_UNUSED
function tsk_treeseq_loadf (line 584) | int TSK_WARN_UNUSED
function tsk_treeseq_dump (line 614) | int TSK_WARN_UNUSED
function tsk_treeseq_dumpf (line 620) | int TSK_WARN_UNUSED
function tsk_size_t (line 634) | tsk_size_t
function tsk_size_t (line 646) | tsk_size_t
function tsk_size_t (line 658) | tsk_size_t
function tsk_treeseq_get_sequence_length (line 664) | double
function tsk_size_t (line 676) | tsk_size_t
function tsk_size_t (line 682) | tsk_size_t
function tsk_size_t (line 688) | tsk_size_t
function tsk_size_t (line 694) | tsk_size_t
function tsk_size_t (line 700) | tsk_size_t
function tsk_size_t (line 706) | tsk_size_t
function tsk_size_t (line 712) | tsk_size_t
function tsk_size_t (line 718) | tsk_size_t
function tsk_size_t (line 724) | tsk_size_t
function tsk_size_t (line 730) | tsk_size_t
function tsk_id_t (line 742) | const tsk_id_t *
function tsk_id_t (line 748) | const tsk_id_t *
function tsk_treeseq_is_sample (line 754) | bool
function tsk_treeseq_get_discrete_genome (line 765) | bool
function tsk_treeseq_get_discrete_time (line 771) | bool
function tsk_treeseq_get_min_time (line 777) | double
function tsk_treeseq_get_max_time (line 783) | double
function tsk_treeseq_has_reference_sequence (line 789) | bool
function tsk_treeseq_get_individuals_population (line 795) | int
function tsk_treeseq_get_individuals_time (line 827) | int
function increment_nd_array_value (line 872) | static inline void
function tsk_treeseq_genealogical_nearest_neighbours (line 890) | int TSK_WARN_UNUSED
function tsk_treeseq_mean_descendants (line 1075) | int TSK_WARN_UNUSED
function tsk_treeseq_check_windows (line 1244) | static int
function tsk_treeseq_check_time_windows (line 1288) | static int
function update_state (line 1317) | static inline void
function update_node_summary (line 1329) | static inline int
function update_running_sum (line 1339) | static inline void
function tsk_treeseq_branch_general_stat (line 1352) | static int
function get_allele_weights (line 1525) | static int
function compute_general_stat_site_result (line 1614) | static int
function tsk_treeseq_site_general_stat (line 1654) | static int
function increment_row (line 1778) | static inline void
function tsk_treeseq_node_general_stat (line 1788) | static int
function span_normalise (line 1920) | static void
type unpolarised_summary_func_args (line 1936) | typedef struct {
function unpolarised_summary_func (line 1944) | static int
function tsk_polarisable_func_general_stat (line 1979) | static int
function tsk_treeseq_general_stat (line 2035) | int
function check_set_indexes (line 2097) | static int
function tsk_treeseq_check_sample_sets (line 2114) | static int
type weight_stat_params_t (line 2151) | typedef struct {
type covariates_stat_params_t (line 2155) | typedef struct {
type sample_count_stat_params_t (line 2161) | typedef struct {
type indexed_weight_stat_params_t (line 2168) | typedef struct {
function tsk_treeseq_sample_count_stat (line 2174) | static int
function get_allele_samples (line 2226) | static int
function norm_hap_weighted (line 2300) | static int
function norm_hap_weighted_ij (line 2317) | static int
function norm_total_weighted (line 2343) | static int
function get_all_samples_bits (line 2356) | static void
type two_locus_work_t (line 2371) | typedef struct {
function two_locus_work_init (line 2378) | static int
function two_locus_work_free (line 2401) | static void
function compute_general_normed_two_site_stat_result (line 2410) | static int
function compute_general_two_site_stat_result (line 2463) | static int
function get_site_row_col_indices (line 2494) | static void
function get_mutation_samples (line 2539) | static int
function get_mutation_sample_sets (line 2628) | static void
function tsk_treeseq_two_site_count_stat (line 2652) | static int
function sample_sets_to_bitset (line 2764) | static int
function check_sites (line 2796) | static int
function check_positions (line 2829) | static int
function positions_to_tree_indexes (line 2863) | static int
function get_index_counts (line 2891) | static int
type iter_state (line 2922) | typedef struct {
function iter_state_init (line 2933) | static int
function get_node_samples (line 2965) | static int
function iter_state_clear (line 2994) | static void
function iter_state_free (line 3009) | static void
function advance_collect_edges (line 3021) | static int
function compute_two_tree_branch_state_update (line 3089) | static int
function compute_two_tree_branch_stat (line 3142) | static int
function tsk_treeseq_two_branch_count_stat (line 3242) | static int
function check_sample_set_dups (line 3353) | static int
function tsk_treeseq_two_locus_count_stat (line 3387) | int
function fold (line 3469) | static inline void
function tsk_treeseq_update_site_afs (line 3498) | static int
function tsk_treeseq_site_allele_frequency_spectrum (line 3547) | static int
function tsk_treeseq_update_branch_afs (line 3650) | static void
function tsk_treeseq_branch_allele_frequency_spectrum (line 3696) | static int
function tsk_treeseq_allele_frequency_spectrum (line 3815) | int
function diversity_summary_func (line 3934) | static int
function tsk_treeseq_diversity (line 3950) | int
function trait_covariance_summary_func (line 3960) | static int
function tsk_treeseq_trait_covariance (line 3975) | int
function trait_correlation_summary_func (line 4025) | static int
function tsk_treeseq_trait_correlation (line 4046) | int
function trait_linear_model_summary_func (line 4107) | static int
function tsk_treeseq_trait_linear_model (line 4153) | int
function segregating_sites_summary_func (line 4221) | static int
function tsk_treeseq_segregating_sites (line 4238) | int
function Y1_summary_func (line 4248) | static int
function tsk_treeseq_Y1 (line 4266) | int
function D_summary_func (line 4276) | static int
function tsk_treeseq_D (line 4300) | int
function D2_summary_func (line 4314) | static int
function tsk_treeseq_D2 (line 4339) | int
function r2_summary_func (line 4352) | static int
function tsk_treeseq_r2 (line 4379) | int
function D_prime_summary_func (line 4391) | static int
function tsk_treeseq_D_prime (line 4421) | int
function r_summary_func (line 4435) | static int
function tsk_treeseq_r (line 4462) | int
function Dz_summary_func (line 4476) | static int
function tsk_treeseq_Dz (line 4502) | int
function pi2_summary_func (line 4515) | static int
function tsk_treeseq_pi2 (line 4538) | int
function D2_unbiased_summary_func (line 4551) | static int
function tsk_treeseq_D2_unbiased (line 4575) | int
function Dz_unbiased_summary_func (line 4588) | static int
function tsk_treeseq_Dz_unbiased (line 4613) | int
function pi2_unbiased_summary_func (line 4626) | static int
function tsk_treeseq_pi2_unbiased (line 4650) | int
function check_sample_stat_inputs (line 4667) | static int
function divergence_summary_func (line 4690) | static int
function tsk_treeseq_divergence (line 4711) | int
function genetic_relatedness_summary_func (line 4729) | static int
function genetic_relatedness_noncentred_summary_func (line 4755) | static int
function tsk_treeseq_genetic_relatedness (line 4775) | int
function genetic_relatedness_weighted_summary_func (line 4800) | static int
function genetic_relatedness_weighted_noncentred_summary_func (line 4821) | static int
function tsk_treeseq_genetic_relatedness_weighted (line 4838) | int
function Y2_summary_func (line 4899) | static int
function tsk_treeseq_Y2 (line 4920) | int
function f2_summary_func (line 4938) | static int
function tsk_treeseq_f2 (line 4961) | int
function D2_ij_summary_func (line 4979) | static int
function tsk_treeseq_D2_ij (line 5018) | int
function D2_ij_unbiased_summary_func (line 5039) | static int
function tsk_treeseq_D2_ij_unbiased (line 5092) | int
function r2_ij_summary_func (line 5113) | static int
function tsk_treeseq_r2_ij (line 5152) | int
function Y3_summary_func (line 5177) | static int
function tsk_treeseq_Y3 (line 5201) | int
function f3_summary_func (line 5219) | static int
function tsk_treeseq_f3 (line 5244) | int
function f4_summary_func (line 5266) | static int
function tsk_treeseq_f4 (line 5293) | int
function tsk_treeseq_get_node (line 5313) | int TSK_WARN_UNUSED
function tsk_treeseq_get_edge (line 5319) | int TSK_WARN_UNUSED
function tsk_treeseq_get_migration (line 5325) | int TSK_WARN_UNUSED
function tsk_treeseq_get_mutation (line 5332) | int TSK_WARN_UNUSED
function tsk_treeseq_get_site (line 5350) | int TSK_WARN_UNUSED
function tsk_treeseq_get_individual (line 5365) | int TSK_WARN_UNUSED
function tsk_treeseq_get_population (line 5381) | int TSK_WARN_UNUSED
function tsk_treeseq_get_provenance (line 5388) | int TSK_WARN_UNUSED
function tsk_treeseq_simplify (line 5395) | int TSK_WARN_UNUSED
function tsk_treeseq_split_edges (line 5427) | int TSK_WARN_UNUSED
function tsk_tree_position_set_null (line 5546) | static void
function tsk_tree_position_init (line 5554) | int
function tsk_tree_position_free (line 5564) | int
function tsk_tree_position_print_state (line 5570) | int
function tsk_tree_position_next (line 5583) | bool
function tsk_tree_position_prev (line 5641) | bool
function tsk_tree_position_seek_forward (line 5701) | int TSK_WARN_UNUSED
function tsk_tree_position_seek_backward (line 5765) | int TSK_WARN_UNUSED
function tsk_id_t (line 5838) | static tsk_id_t
function tsk_tree_init (line 5849) | int TSK_WARN_UNUSED
function tsk_tree_set_root_threshold (line 5912) | int
function tsk_size_t (line 5934) | tsk_size_t
function tsk_tree_free (line 5940) | int
function tsk_tree_has_sample_lists (line 5959) | bool
function tsk_tree_has_sample_counts (line 5965) | bool
function tsk_tree_reset_tracked_samples (line 5971) | static int TSK_WARN_UNUSED
function tsk_tree_set_tracked_samples (line 5986) | int TSK_WARN_UNUSED
function tsk_tree_track_descendant_samples (line 6028) | int TSK_WARN_UNUSED
function tsk_tree_copy (line 6073) | int TSK_WARN_UNUSED
function tsk_tree_equals (line 6132) | bool TSK_WARN_UNUSED
function tsk_tree_check_node (line 6143) | static int
function tsk_tree_is_descendant (line 6153) | bool
function tsk_tree_get_mrca (line 6169) | int TSK_WARN_UNUSED
function tsk_tree_get_num_samples_by_traversal (line 6215) | static int
function tsk_tree_get_num_samples (line 6246) | int TSK_WARN_UNUSED
function tsk_tree_get_num_tracked_samples (line 6265) | int TSK_WARN_UNUSED
function tsk_tree_is_sample (line 6284) | bool
function tsk_id_t (line 6290) | tsk_id_t
function tsk_id_t (line 6296) | tsk_id_t
function tsk_size_t (line 6302) | tsk_size_t
function tsk_tree_get_parent (line 6308) | int TSK_WARN_UNUSED
function tsk_tree_get_time (line 6322) | int TSK_WARN_UNUSED
function tsk_tree_get_branch_length_unsafe (line 6341) | static inline double
function tsk_tree_get_branch_length (line 6350) | int TSK_WARN_UNUSED
function tsk_tree_get_total_branch_length (line 6364) | int
function tsk_tree_get_sites (line 6398) | int TSK_WARN_UNUSED
function tsk_tree_get_depth_unsafe (line 6408) | static int
function tsk_tree_get_depth (line 6424) | int TSK_WARN_UNUSED
function tsk_id_t (line 6439) | static tsk_id_t
function tsk_tree_check_state (line 6450) | static void
function tsk_tree_print_state (line 6529) | void
function tsk_tree_update_sample_lists (line 6577) | static inline void
function tsk_tree_remove_branch (line 6612) | static inline void
function tsk_tree_insert_branch (line 6640) | static inline void
function tsk_tree_insert_root (line 6666) | static inline void
function tsk_tree_remove_root (line 6673) | static inline void
function tsk_tree_remove_edge (line 6679) | static void
function tsk_tree_insert_edge (line 6721) | static void
function tsk_tree_first (line 6762) | int TSK_WARN_UNUSED
function tsk_tree_last (line 6776) | int TSK_WARN_UNUSED
function tsk_tree_update_index_and_interval (line 6790) | static void
function tsk_tree_next (line 6805) | int TSK_WARN_UNUSED
function tsk_tree_prev (line 6837) | int TSK_WARN_UNUSED
function tsk_tree_position_in_interval (line 6869) | static inline bool
function tsk_tree_seek_from_null (line 6875) | static int
function tsk_tree_seek_forward (line 6929) | static int TSK_WARN_UNUSED
function tsk_tree_seek_backward (line 6971) | static int TSK_WARN_UNUSED
function tsk_tree_seek_index (line 7013) | int TSK_WARN_UNUSED
function tsk_tree_seek_linear (line 7029) | static int TSK_WARN_UNUSED
function tsk_tree_seek_skip (line 7069) | static int TSK_WARN_UNUSED
function tsk_tree_seek (line 7092) | int TSK_WARN_UNUSED
function tsk_tree_clear (line 7117) | int TSK_WARN_UNUSED
function tsk_size_t (line 7186) | tsk_size_t
function tsk_id_t (line 7213) | static tsk_id_t *
function tsk_tree_preorder (line 7219) | int
function tsk_tree_preorder_from (line 7225) | int
function tsk_tree_preorder_samples_from (line 7282) | int
function tsk_tree_postorder (line 7341) | int
function tsk_tree_postorder_from (line 7346) | int
function tsk_tree_sackin_index (line 7413) | int
function tsk_tree_colless_index (line 7468) | int
function tsk_tree_b1_index (line 7519) | int
function general_log (line 7559) | static double
function tsk_tree_b2_index (line 7565) | int
function tsk_tree_num_lineages (line 7621) | int
function set_bit (line 7672) | static inline uint64_t
function bit_is_set (line 7678) | static inline bool
function get_smallest_set_bit (line 7684) | static inline int8_t
function tsk_tree_map_mutations (line 7714) | int TSK_WARN_UNUSED
type kc_vectors (line 7870) | typedef struct {
function kc_vectors_alloc (line 7877) | static int
function kc_vectors_free (line 7895) | static void
function update_kc_vectors_single_sample (line 7902) | static inline void
function update_kc_vectors_all_pairs (line 7913) | static inline void
type kc_stack_elmt (line 7954) | struct kc_stack_elmt {
function fill_kc_vectors (line 7959) | static int
function norm_kc_vectors (line 8014) | static double
function check_kc_distance_tree_inputs (line 8030) | static int
function check_kc_distance_samples_inputs (line 8057) | static int
function tsk_tree_kc_distance (line 8082) | int
function check_kc_distance_tree_sequence_inputs (line 8126) | static int
function update_kc_pair_with_sample (line 8146) | static void
function update_kc_subtree_state (line 8168) | static int
function update_kc_incremental (line 8206) | static int
function tsk_treeseq_kc_distance (line 8256) | int
type sv_tables_t (line 8363) | typedef struct {
function sv_tables_init (line 8378) | static int
function sv_tables_free (line 8401) | static int
function sv_tables_reset (line 8414) | static void
function sv_tables_convert_tree (line 8428) | static void
function sv_tables_build_index (line 8450) | static void
function sv_tables_build (line 8526) | static void
function tsk_id_t (line 8534) | static tsk_id_t
function tsk_id_t (line 8572) | static tsk_id_t
function tsk_treeseq_divergence_matrix_branch (line 8579) | static int
function update_site_divergence (line 8684) | static void
function group_alleles (line 8717) | static void
function remap_to_sample_sets (line 8739) | static void
function tsk_treeseq_divergence_matrix_site (line 8753) | static int
function get_sample_set_index_map (line 8832) | static int
function fill_lower_triangle_count_normalise (line 8876) | static void
function tsk_treeseq_divergence_matrix (line 8901) | int
type edge_list_t (line 9007) | typedef struct _edge_list_t {
function edge_list_print (line 9015) | static void
function edge_list_append_entry (line 9036) | static void
function remove_unextended (line 9052) | static void
function edge_list_set_extended (line 9078) | static void
function tsk_treeseq_slide_mutation_nodes_up (line 9094) | static int
type haplotype_extender_t (line 9142) | typedef struct {
function haplotype_extender_init (line 9156) | static int
function haplotype_extender_print_state (line 9220) | static void
function haplotype_extender_free (line 9264) | static int
function haplotype_extender_next_tree (line 9278) | static int
function haplotype_extender_add_or_extend_edge (line 9360) | static int
function haplotype_extender_mergeable (line 9430) | static float
function haplotype_extender_merge_paths (line 9482) | static int
function haplotype_extender_extend_paths (line 9531) | static int
function extend_haplotypes_iter (line 9617) | static int
function tsk_treeseq_extend_haplotypes (line 9643) | int TSK_WARN_UNUSED
function check_node_bin_map (line 9749) | static int
function TRANSPOSE_2D (line 9776) | static inline void
function pair_coalescence_count (line 9787) | static inline void
function tsk_treeseq_pair_coalescence_stat (line 9807) | int
function pair_coalescence_weights (line 10132) | static int
function tsk_treeseq_pair_coalescence_counts (line 10142) | int
function pair_coalescence_quantiles (line 10154) | static int
function check_quantiles (line 10184) | static int
function check_sorted_node_bin_map (line 10201) | static int
function tsk_treeseq_pair_coalescence_quantiles (line 10250) | int
function pair_coalescence_rates (line 10280) | static int
function check_coalescence_rate_time_windows (line 10313) | static int
function tsk_treeseq_pair_coalescence_rates (line 10372) | int
type tsk_matvec_calculator_t (line 10402) | typedef struct {
function tsk_matvec_calculator_print_state (line 10421) | static void
function tsk_matvec_calculator_init (line 10445) | static int
function tsk_matvec_calculator_free (line 10539) | static int
function tsk_matvec_calculator_add_z (line 10553) | static inline void
function tsk_matvec_calculator_adjust_path_up (line 10575) | static void
function tsk_matvec_calculator_remove_edge (line 10609) | static void
function tsk_matvec_calculator_insert_edge (line 10626) | static void
function tsk_matvec_calculator_write_output (line 10636) | static int
function tsk_matvec_calculator_run (line 10702) | static int
function tsk_treeseq_genetic_relatedness_vector (line 10782) | int
FILE: c/tskit/trees.h
type tsk_treeseq_t (line 86) | typedef struct {
type tsk_tree_position_t (line 121) | typedef struct {
type tsk_tree_t (line 169) | typedef struct {
type tsk_state_transition_t (line 1971) | typedef struct {
FILE: python/_tskitmodule.c
type TableCollection (line 80) | typedef struct _TableCollection {
type IndividualTable (line 90) | typedef struct {
type NodeTable (line 97) | typedef struct {
type EdgeTable (line 104) | typedef struct {
type SiteTable (line 111) | typedef struct {
type MutationTable (line 118) | typedef struct {
type MigrationTable (line 125) | typedef struct {
type PopulationTable (line 132) | typedef struct {
type ProvenanceTable (line 139) | typedef struct {
type TreeSequence (line 146) | typedef struct {
type Tree (line 151) | typedef struct {
type Variant (line 157) | typedef struct {
type LdCalculator (line 163) | typedef struct {
type LsHmm (line 169) | typedef struct {
type CompressedMatrix (line 175) | typedef struct {
type ViterbiMatrix (line 181) | typedef struct {
type ReferenceSequence (line 187) | typedef struct {
type IdentitySegments (line 194) | typedef struct {
type IdentitySegmentList (line 199) | typedef struct {
function handle_library_error (line 230) | static void
function PyObject (line 306) | static PyObject *
function PyObject (line 331) | static PyObject *
function PyObject (line 338) | static PyObject *
function PyObject (line 356) | static PyObject *
function PyObject (line 375) | static PyObject *
function PyObject (line 400) | static PyObject *
function PyObject (line 415) | static PyObject *
function PyObject (line 426) | static PyObject *
function PyObject (line 455) | static PyObject *
function PyObject (line 487) | static PyObject *
function PyObject (line 502) | static PyObject *
function PyObject (line 523) | static PyObject *
function PyObject (line 540) | static PyObject *
function PyObject (line 557) | static PyObject *
function PyObject (line 582) | static PyObject *
function PyObject (line 615) | static PyObject *
function PyObject (line 635) | static PyObject *
function PyObject (line 660) | static PyObject *
function PyObject (line 687) | static PyObject *
function PyObject (line 721) | static PyObject *
function parse_sample_sets (line 798) | static int
function PyObject (line 850) | static PyObject *
function PyObject (line 868) | static PyObject *
function FILE (line 886) | static FILE *
function uint32_converter (line 913) | static int
function tsk_id_converter (line 938) | static int
function array_converter (line 963) | static int
function int32_array_converter (line 981) | static int
function bool_array_converter (line 987) | static int
function PyObject (line 1001) | static PyObject *
function DEFINE_TABLE_METADATA_SCHEMA_SETTER (line 1415) | DEFINE_TABLE_METADATA_SCHEMA_GETTER(Individual)
function PyObject (line 1493) | static PyObject *
function DEFINE_TABLE_METADATA_SCHEMA_SETTER (line 1669) | DEFINE_TABLE_METADATA_SCHEMA_GETTER(Node)
function PyObject (line 1717) | static PyObject *
function DEFINE_TABLE_METADATA_SCHEMA_SETTER (line 1857) | DEFINE_TABLE_METADATA_SCHEMA_GETTER(Edge)
function PyObject (line 1901) | static PyObject *
function PyObject (line 1939) | static PyObject *
function DEFINE_TABLE_METADATA_SCHEMA_SETTER (line 2058) | DEFINE_TABLE_METADATA_SCHEMA_GETTER(Migration)
function PyObject (line 2106) | static PyObject *
function DEFINE_TABLE_METADATA_SCHEMA_SETTER (line 2245) | DEFINE_TABLE_METADATA_SCHEMA_GETTER(Site)
function PyObject (line 2289) | static PyObject *
function DEFINE_TABLE_METADATA_SCHEMA_SETTER (line 2428) | DEFINE_TABLE_METADATA_SCHEMA_GETTER(Mutation)
function PyObject (line 2480) | static PyObject *
function DEFINE_TABLE_METADATA_SCHEMA_SETTER (line 2625) | DEFINE_TABLE_METADATA_SCHEMA_GETTER(Population)
function PyObject (line 2663) | static PyObject *
function PyObject (line 2794) | static PyObject *
function PyObject (line 2822) | static PyObject *
function PyObject (line 2851) | static PyObject *
function IdentitySegmentList_check_state (line 2972) | static int
function IdentitySegmentList_check_segments_stored (line 2985) | static int
function IdentitySegmentList_dealloc (line 2999) | static void
function IdentitySegmentList_init (line 3008) | static int
function PyObject (line 3019) | static PyObject *
function PyObject (line 3033) | static PyObject *
function PyObject (line 3047) | static PyObject *
function PyObject (line 3080) | static PyObject *
function PyObject (line 3113) | static PyObject *
function IdentitySegments_check_state (line 3189) | static int
function IdentitySegments_dealloc (line 3202) | static void
function IdentitySegments_init (line 3213) | static int
function PyObject (line 3229) | static PyObject *
function PyObject (line 3272) | static PyObject *
function PyObject (line 3302) | static PyObject *
function PyObject (line 3328) | static PyObject *
function PyObject (line 3342) | static PyObject *
function PyObject (line 3356) | static PyObject *
function ReferenceSequence_check_read (line 3423) | static int
function ReferenceSequence_check_write (line 3436) | static int
function ReferenceSequence_dealloc (line 3456) | static void
function ReferenceSequence_init (line 3464) | static int
function PyObject (line 3473) | static PyObject *
function ReferenceSequence_set_string_attr (line 3492) | static int
function ReferenceSequence_set_data (line 3527) | static int
function PyObject (line 3534) | static PyObject *
function ReferenceSequence_set_url (line 3548) | static int
function PyObject (line 3555) | static PyObject *
function ReferenceSequence_set_metadata_schema (line 3569) | static int
function PyObject (line 3577) | static PyObject *
function ReferenceSequence_set_metadata (line 3592) | static int
function PyObject (line 3623) | static PyObject *
function PyObject (line 3680) | static PyObject *
function TableCollection_check_state (line 3711) | static int
function TableCollection_alloc (line 3722) | static int
function TableCollection_dealloc (line 3742) | static void
function TableCollection_init (line 3753) | static int
function PyObject (line 3790) | static PyObject *
function PyObject (line 3810) | static PyObject *
function PyObject (line 3830) | static PyObject *
function PyObject (line 3850) | static PyObject *
function PyObject (line 3870) | static PyObject *
function PyObject (line 3890) | static PyObject *
function PyObject (line 3910) | static PyObject *
function PyObject (line 3930) | static PyObject *
function PyObject (line 3950) | static PyObject *
function TableCollection_set_sequence_length (line 3963) | static int
function PyObject (line 3986) | static PyObject *
function PyObject (line 3999) | static PyObject *
function TableCollection_set_time_units (line 4013) | static int
function PyObject (line 4039) | static PyObject *
function TableCollection_set_metadata (line 4053) | static int
function PyObject (line 4083) | static PyObject *
function TableCollection_set_metadata_schema (line 4097) | static int
function PyObject (line 4123) | static PyObject *
function PyObject (line 4137) | static PyObject *
function PyObject (line 4226) | static PyObject *
function PyObject (line 4288) | static PyObject *
function PyObject (line 4339) | static PyObject *
function PyObject (line 4400) | static PyObject *
function PyObject (line 4464) | static PyObject *
function PyObject (line 4525) | static PyObject *
function PyObject (line 4557) | static PyObject *
function PyObject (line 4577) | static PyObject *
function PyObject (line 4606) | static PyObject *
function PyObject (line 4629) | static PyObject *
function PyObject (line 4648) | static PyObject *
function PyObject (line 4667) | static PyObject *
function PyObject (line 4686) | static PyObject *
function PyObject (line 4705) | static PyObject *
function PyObject (line 4724) | static PyObject *
function TableCollection_set_indexes (line 4770) | static int
function PyObject (line 4789) | static PyObject *
function PyObject (line 4803) | static PyObject *
function PyObject (line 4817) | static PyObject *
function PyObject (line 4869) | static PyObject *
function PyObject (line 4908) | static PyObject *
function PyObject (line 4942) | static PyObject *
function PyObject (line 4994) | static PyObject *
function PyObject (line 5013) | static PyObject *
function TreeSequence_check_state (line 5208) | static int
function TreeSequence_dealloc (line 5219) | static void
function TreeSequence_alloc (line 5230) | static int
function TreeSequence_init (line 5250) | static int
function PyObject (line 5257) | static PyObject *
function PyObject (line 5291) | static PyObject *
function PyObject (line 5322) | static PyObject *
function PyObject (line 5347) | static PyObject *
function PyObject (line 5410) | static PyObject *
function PyObject (line 5462) | static PyObject *
function PyObject (line 5491) | static PyObject *
function PyObject (line 5520) | static PyObject *
function PyObject (line 5550) | static PyObject *
function PyObject (line 5579) | static PyObject *
function PyObject (line 5593) | static PyObject *
function PyObject (line 5608) | static PyObject *
function PyObject (line 5622) | static PyObject *
function PyObject (line 5670) | static PyObject *
function PyObject (line 5700) | static PyObject *
function PyObject (line 5730) | static PyObject *
function PyObject (line 5760) | static PyObject *
function PyObject (line 5790) | static PyObject *
function PyObject (line 5805) | static PyObject *
function PyObject (line 5820) | static PyObject *
function PyObject (line 5835) | static PyObject *
function PyObject (line 5850) | static PyObject *
function PyObject (line 5865) | static PyObject *
function PyObject (line 5878) | static PyObject *
function PyObject (line 5891) | static PyObject *
function PyObject (line 5904) | static PyObject *
function PyObject (line 5917) | static PyObject *
function PyObject (line 5930) | static PyObject *
function PyObject (line 5955) | static PyObject *
function PyObject (line 5968) | static PyObject *
function PyObject (line 5983) | static PyObject *
function PyObject (line 5998) | static PyObject *
function PyObject (line 6027) | static PyObject *
function PyObject (line 6059) | static PyObject *
function PyObject (line 6090) | static PyObject *
function PyObject (line 6145) | static PyObject *
function PyObject (line 6237) | static PyObject *
function PyObject (line 6265) | static PyObject *
function PyObject (line 6369) | static PyObject *
function PyObject (line 6397) | static PyObject *
function PyObject (line 6485) | static PyObject *
function general_stat_func (line 6532) | static int
function parse_stats_mode (line 6588) | static int
function parse_windows (line 6609) | static int
function PyArrayObject (line 6638) | static PyArrayObject *
function PyObject (line 6665) | static PyObject *
function PyObject (line 6747) | static PyObject *
function PyObject (line 6820) | static PyObject *
function PyObject (line 6909) | static PyObject *
function PyObject (line 6977) | static PyObject *
function PyObject (line 7064) | static PyObject *
function PyObject (line 7070) | static PyObject *
function PyObject (line 7077) | static PyObject *
function PyObject (line 7084) | static PyObject *
function PyObject (line 7091) | static PyObject *
function PyObject (line 7098) | static PyObject *
function PyObject (line 7104) | static PyObject *
function PyObject (line 7196) | static PyObject *
function PyObject (line 7284) | static PyObject *
function PyObject (line 7376) | static PyObject *
function PyObject (line 7382) | static PyObject *
function PyObject (line 7389) | static PyObject *
function PyObject (line 7397) | static PyObject *
function PyObject (line 7405) | static PyObject *
function PyObject (line 7411) | static PyObject *
function PyObject (line 7417) | static PyObject *
function PyObject (line 7423) | static PyObject *
function PyObject (line 7429) | static PyObject *
function PyObject (line 7435) | static PyObject *
function parse_node_bin_map (line 7511) | static int
function parse_set_indexes (line 7554) | static int
function PyObject (line 7582) | static PyObject *
function parse_quantiles (line 7670) | static int
function PyObject (line 7697) | static PyObject *
function parse_time_windows (line 7786) | static int
function PyObject (line 7813) | static PyObject *
function PyArrayObject (line 7901) | static PyArrayObject *
function PyArrayObject (line 7926) | static PyArrayObject *
function PyObject (line 7949) | static PyObject *
function PyObject (line 8052) | static PyObject *
function PyObject (line 8058) | static PyObject *
function PyObject (line 8064) | static PyObject *
function PyObject (line 8070) | static PyObject *
function PyObject (line 8076) | static PyObject *
function PyObject (line 8082) | static PyObject *
function PyObject (line 8088) | static PyObject *
function PyObject (line 8094) | static PyObject *
function PyObject (line 8100) | static PyObject *
function PyObject (line 8106) | static PyObject *
function PyObject (line 8112) | static PyObject *
function PyObject (line 8233) | static PyObject *
function PyObject (line 8239) | static PyObject *
function PyObject (line 8245) | static PyObject *
function PyObject (line 8251) | static PyObject *
function PyObject (line 8266) | static PyObject *
function PyObject (line 8281) | static PyObject *
function PyObject (line 8296) | static PyObject *
function PyObject (line 8344) | static PyObject *
function PyObject (line 8358) | static PyObject *
function PyObject (line 8373) | static PyObject *
function PyObject (line 8399) | static PyObject *
function PyObject (line 8406) | PyObject *
function PyObject (line 8483) | static PyObject *
function PyObject (line 8625) | static PyObject *
function PyObject (line 8641) | static PyObject *
function Tree_check_state (line 9173) | static int
function Tree_check_bounds (line 9184) | static int
function Tree_dealloc (line 9195) | static void
function Tree_init (line 9207) | static int
function PyObject (line 9283) | static PyObject *
function PyObject (line 9302) | static PyObject *
function PyObject (line 9321) | static PyObject *
function PyObject (line 9340) | static PyObject *
function PyObject (line 9359) | static PyObject *
function PyObject (line 9387) | static PyObject *
function PyObject (line 9415) | static PyObject *
function PyObject (line 9434) | static PyObject *
function PyObject (line 9447) | static PyObject *
function PyObject (line 9460) | static PyObject *
function PyObject (line 9473) | static PyObject *
function PyObject (line 9486) | static PyObject *
function PyObject (line 9506) | static PyObject *
function PyObject (line 9519) | static PyObject *
function PyObject (line 9532) | static PyObject *
function PyObject (line 9545) | static PyObject *
function Tree_get_node_argument (line 9558) | static int
function PyObject (line 9576) | static PyObject *
function PyObject (line 9590) | static PyObject *
function PyObject (line 9614) | static PyObject *
function PyObject (line 9630) | static PyObject *
function PyObject (line 9650) | static PyObject *
function PyObject (line 9670) | static PyObject *
function PyObject (line 9686) | static PyObject *
function PyObject (line 9702) | static PyObject *
function PyObject (line 9718) | static PyObject *
function PyObject (line 9734) | static PyObject *
function PyObject (line 9750) | static PyObject *
function PyObject (line 9784) | static PyObject *
function Tree_check_sample_list (line 9804) | static bool
function PyObject (line 9815) | static PyObject *
function PyObject (line 9834) | static PyObject *
function PyObject (line 9853) | static PyObject *
function PyObject (line 9880) | static PyObject *
function PyObject (line 9910) | static PyObject *
function PyObject (line 9926) | static PyObject *
function PyObject (line 9946) | static PyObject *
function PyObject (line 9967) | static PyObject *
function PyObject (line 9980) | static PyObject *
function PyObject (line 9993) | static PyObject *
function PyObject (line 10045) | static PyObject *
function PyObject (line 10114) | static PyObject *
function PyObject (line 10134) | static PyObject *
function PyObject (line 10166) | static PyObject *
function PyObject (line 10193) | static PyObject *
function PyObject (line 10214) | static PyObject *
function PyObject (line 10235) | static PyObject *
function PyObject (line 10256) | static PyObject *
function PyObject (line 10280) | static PyObject *
function PyObject (line 10304) | static PyObject *
function PyObject (line 10317) | static PyObject *
function PyObject (line 10344) | static PyObject *
function PyObject (line 10393) | static PyObject *
function PyObject (line 10399) | static PyObject *
function PyObject (line 10411) | static PyObject *
function PyObject (line 10417) | static PyObject *
function PyObject (line 10430) | static PyObject *
function PyObject (line 10443) | static PyObject *
function PyObject (line 10456) | static PyObject *
function PyObject (line 10469) | static PyObject *
function PyObject (line 10482) | static PyObject *
function PyObject (line 10495) | static PyObject *
function Variant_check_state (line 10765) | static int
function Variant_dealloc (line 10776) | static void
function Variant_init (line 10788) | static int
function PyObject (line 10857) | static PyObject *
function PyObject (line 10881) | static PyObject *
function PyObject (line 10915) | static PyObject *
function PyObject (line 10927) | static PyObject *
function PyObject (line 10940) | static PyObject *
function PyObject (line 10953) | static PyObject *
function PyObject (line 10968) | static PyObject *
function LdCalculator_check_state (line 11050) | static int
function LdCalculator_dealloc (line 11061) | static void
function LdCalculator_init (line 11073) | static int
function PyObject (line 11108) | static PyObject *
function PyObject (line 11132) | static PyObject *
function CompressedMatrix_check_state (line 11236) | static int
function CompressedMatrix_dealloc (line 11249) | static void
function CompressedMatrix_init (line 11261) | static int
function PyObject (line 11299) | static PyObject *
function PyObject (line 11312) | static PyObject *
function PyObject (line 11336) | static PyObject *
function PyObject (line 11360) | static PyObject *
function PyObject (line 11377) | static PyObject *
function ViterbiMatrix_check_state (line 11434) | static int
function ViterbiMatrix_dealloc (line 11447) | static void
function ViterbiMatrix_init (line 11459) | static int
function PyObject (line 11497) | static PyObject *
function PyObject (line 11526) | static PyObject *
function PyObject (line 11547) | static PyObject *
function PyObject (line 11571) | static PyObject *
function PyObject (line 11596) | static PyObject *
function PyObject (line 11613) | static PyObject *
function LsHmm_check_state (line 11674) | static int
function LsHmm_dealloc (line 11687) | static void
function LsHmm_init (line 11699) | static int
function PyObject (line 11777) | static PyObject *
function PyObject (line 11818) | static PyObject *
function PyObject (line 11876) | static PyObject *
function PyObject (line 11952) | static PyObject *
function PyObject (line 11958) | static PyObject *
type PyModuleDef (line 11976) | struct PyModuleDef
function PyObject (line 11984) | PyObject *
FILE: python/benchmark/run-for-all-releases.py
function versions (line 9) | def versions(package_name):
function sh (line 15) | def sh(command):
FILE: python/benchmark/run.py
function system_info (line 25) | def system_info():
function make_file (line 44) | def make_file():
function autotime (line 77) | def autotime(setup, code):
function run_benchmarks (line 88) | def run_benchmarks(keyword_filter):
function generate_report (line 135) | def generate_report(all_versions_results):
function print_result (line 196) | def print_result(results):
function run_benchmark_and_save (line 212) | def run_benchmark_and_save(keyword_filter, print_results):
FILE: python/lwt_interface/cython_example/_lwtc.c
type PyModuleDef (line 45) | struct PyModuleDef
function PyMODINIT_FUNC (line 52) | PyMODINIT_FUNC
FILE: python/lwt_interface/dict_encoding_testlib.py
function full_ts (line 46) | def full_ts():
function tables (line 103) | def tables(full_ts):
function test_check_ts_full (line 107) | def test_check_ts_full(tmp_path, full_ts):
class TestEncodingVersion (line 117) | class TestEncodingVersion:
method test_version (line 118) | def test_version(self):
class TestRoundTrip (line 123) | class TestRoundTrip:
method verify (line 128) | def verify(self, tables):
method test_simple (line 134) | def test_simple(self):
method test_empty (line 138) | def test_empty(self):
method test_individuals (line 142) | def test_individuals(self):
method test_sequence_length (line 152) | def test_sequence_length(self):
method test_migration (line 158) | def test_migration(self):
method test_example (line 170) | def test_example(self, tables):
class TestMissingData (line 194) | class TestMissingData:
method test_missing_sequence_length (line 199) | def test_missing_sequence_length(self, tables):
method test_missing_time_units (line 206) | def test_missing_time_units(self, tables):
method test_missing_metadata (line 215) | def test_missing_metadata(self, tables):
method test_missing_metadata_schema (line 225) | def test_missing_metadata_schema(self, tables):
method test_missing_tables (line 234) | def test_missing_tables(self, tables):
class TestBadTypes (line 253) | class TestBadTypes:
method verify_columns (line 258) | def verify_columns(self, value, tables):
method test_2d_array (line 280) | def test_2d_array(self, tables):
method test_str (line 283) | def test_str(self, tables):
method test_bad_top_level_types (line 286) | def test_bad_top_level_types(self, tables):
class TestBadLengths (line 297) | class TestBadLengths:
method verify (line 302) | def verify(self, num_rows, tables):
method test_two_rows (line 324) | def test_two_rows(self, tables):
method test_zero_rows (line 327) | def test_zero_rows(self, tables):
method test_bad_index_length (line 330) | def test_bad_index_length(self, tables):
class TestParsingUtilities (line 354) | class TestParsingUtilities:
method test_missing_required (line 355) | def test_missing_required(self, tables):
method test_string_bad_type (line 362) | def test_string_bad_type(self, tables):
method test_bytes_bad_type (line 369) | def test_bytes_bad_type(self, tables):
method test_dict_bad_type (line 376) | def test_dict_bad_type(self, tables):
method test_bad_strings (line 383) | def test_bad_strings(self, tables):
class TestRequiredAndOptionalColumns (line 412) | class TestRequiredAndOptionalColumns:
method verify_required_columns (line 418) | def verify_required_columns(self, tables, table_name, required_cols):
method verify_optional_column (line 450) | def verify_optional_column(self, tables, table_len, table_name, col_na...
method verify_offset_pair (line 461) | def verify_offset_pair(
method verify_metadata_schema (line 531) | def verify_metadata_schema(self, tables, table_name):
method test_individuals (line 541) | def test_individuals(self, tables):
method test_nodes (line 562) | def test_nodes(self, tables):
method test_edges (line 569) | def test_edges(self, tables):
method test_migrations (line 576) | def test_migrations(self, tables):
method test_sites (line 584) | def test_sites(self, tables):
method test_mutations (line 591) | def test_mutations(self, tables):
method test_populations (line 607) | def test_populations(self, tables):
method test_provenances (line 614) | def test_provenances(self, tables):
method test_index (line 621) | def test_index(self, tables):
method test_index_bad_type (line 655) | def test_index_bad_type(self, tables):
method test_reference_sequence (line 662) | def test_reference_sequence(self, tables):
method test_top_level_time_units (line 684) | def test_top_level_time_units(self, tables):
method test_top_level_metadata (line 700) | def test_top_level_metadata(self, tables):
method test_top_level_metadata_schema (line 712) | def test_top_level_metadata_schema(self, tables):
class TestLifecycle (line 725) | class TestLifecycle:
method test_unassigned_empty (line 726) | def test_unassigned_empty(self):
method test_del_empty (line 730) | def test_del_empty(self):
method test_del_full (line 736) | def test_del_full(self, tables):
method test_del_lwt_and_tables (line 743) | def test_del_lwt_and_tables(self, tables):
class TestForceOffset64 (line 753) | class TestForceOffset64:
method get_offset_columns (line 754) | def get_offset_columns(self, dict_encoding):
method test_bad_args (line 761) | def test_bad_args(self, tables):
method test_off_by_default (line 768) | def test_off_by_default(self, tables):
method test_types_64 (line 775) | def test_types_64(self, tables):
method test_types_32 (line 782) | def test_types_32(self, tables):
method test_values_equal (line 789) | def test_values_equal(self, tables):
function test_fromdict_bad_type (line 803) | def test_fromdict_bad_type(bad_type):
FILE: python/lwt_interface/example_c_module.c
function PyObject (line 41) | static PyObject *
function PyObject (line 90) | static PyObject * example_modifying(PyObject *self, PyObject *args) {
type PyModuleDef (line 134) | struct PyModuleDef
function PyMODINIT_FUNC (line 141) | PyMODINIT_FUNC
FILE: python/lwt_interface/setup.py
class local_build_ext (line 12) | class local_build_ext(build_ext): # noqa N801
method finalize_options (line 13) | def finalize_options(self):
FILE: python/lwt_interface/test_example_c_module.py
function test_example_receiving (line 27) | def test_example_receiving():
function test_example_modifying (line 48) | def test_example_modifying():
FILE: python/lwt_interface/tskit_lwt_interface.h
type LightweightTableCollection (line 33) | typedef struct {
function handle_tskit_error (line 40) | static void
function PyObject (line 46) | static PyObject *
function PyObject (line 68) | static PyObject *
function PyObject (line 86) | static PyObject *
function PyObject (line 104) | static PyObject *
function PyObject (line 122) | static PyObject *
function PyArrayObject (line 140) | static PyArrayObject *
function PyArrayObject (line 168) | static PyArrayObject *
function parse_individual_table_dict (line 226) | static int
function parse_node_table_dict (line 394) | static int
function parse_edge_table_dict (line 533) | static int
function parse_migration_table_dict (line 663) | static int
function parse_site_table_dict (line 817) | static int
function parse_mutation_table_dict (line 942) | static int
function parse_population_table_dict (line 1113) | static int
function parse_provenance_table_dict (line 1187) | static int
function parse_indexes_dict (line 1265) | static int
function parse_reference_sequence_dict (line 1328) | static int
function parse_table_collection_dict (line 1411) | static int
type tsklwt_table_col_t (line 1582) | typedef struct _tsklwt_table_col_t {
type tsklwt_ragged_col_t (line 1589) | typedef struct _tsklwt_ragged_col_t {
type tsklwt_table_desc_t (line 1598) | typedef struct _tsklwt_table_desc_t {
function write_table_col (line 1606) | static int
function write_ragged_col (line 1626) | static int
function write_string_to_dict (line 1675) | static int
function write_bytes_to_dict (line 1693) | static int
function PyObject (line 1712) | static PyObject *
function write_table_arrays (line 1753) | static int
function write_top_level_data (line 1942) | static int
function PyObject (line 1996) | static PyObject *
function PyObject (line 2035) | static PyObject *
function LightweightTableCollection_check_state (line 2081) | static int
function LightweightTableCollection_dealloc (line 2092) | static void
function LightweightTableCollection_init (line 2103) | static int
function PyObject (line 2132) | static PyObject *
function PyObject (line 2151) | static PyObject *
function register_lwt_class (line 2199) | static int
FILE: python/stress_lowlevel.py
function main (line 18) | def main(stdscr):
FILE: python/tests/__init__.py
class PythonTree (line 32) | class PythonTree:
method __init__ (line 39) | def __init__(self, num_nodes):
method from_tree (line 56) | def from_tree(cls, tree):
method roots (line 75) | def roots(self):
method children (line 83) | def children(self, u):
method get_interval (line 91) | def get_interval(self):
method get_parent (line 94) | def get_parent(self, node):
method get_children (line 97) | def get_children(self, node):
method get_index (line 100) | def get_index(self):
method get_parent_dict (line 103) | def get_parent_dict(self):
method sites (line 111) | def sites(self):
method __eq__ (line 114) | def __eq__(self, other):
method __ne__ (line 123) | def __ne__(self, other):
class PythonTreeSequence (line 127) | class PythonTreeSequence:
method __init__ (line 136) | def __init__(self, tree_sequence, breakpoints=None):
method trees (line 186) | def trees(self):
class MRCACalculator (line 209) | class MRCACalculator:
method __init__ (line 225) | def __init__(self, oriented_forest):
method __preprocess (line 231) | def __preprocess(self, oriented_forest):
method get_mrca (line 302) | def get_mrca(self, x, y):
method _sv_mrca (line 314) | def _sv_mrca(self, x, y):
function base64_encode (line 339) | def base64_encode(metadata):
function cached_example (line 347) | def cached_example(ts_func):
FILE: python/tests/conftest.py
function pytest_addoption (line 48) | def pytest_addoption(parser):
function pytest_configure (line 75) | def pytest_configure(config):
function pytest_collection_modifyitems (line 83) | def pytest_collection_modifyitems(config, items):
function overwrite_viz (line 97) | def overwrite_viz(request):
function draw_plotbox (line 102) | def draw_plotbox(request):
function simple_degree1_ts_fixture (line 107) | def simple_degree1_ts_fixture():
function simple_degree2_ts_fixture (line 112) | def simple_degree2_ts_fixture():
function ts_fixture (line 119) | def ts_fixture():
function ts_fixture_for_simplify (line 127) | def ts_fixture_for_simplify():
function replicate_ts_fixture (line 135) | def replicate_ts_fixture():
FILE: python/tests/ibd.py
class Segment (line 34) | class Segment:
method __init__ (line 43) | def __init__(self, left=None, right=None, node=None, next_seg=None):
method __str__ (line 49) | def __str__(self):
method __repr__ (line 55) | def __repr__(self):
method __eq__ (line 58) | def __eq__(self, other):
method __lt__ (line 66) | def __lt__(self, other):
class SegmentList (line 74) | class SegmentList:
method __init__ (line 82) | def __init__(self, head=None, tail=None):
method __str__ (line 86) | def __str__(self):
method __repr__ (line 89) | def __repr__(self):
method extend (line 97) | def extend(self, seglist):
method append (line 110) | def append(self, segment):
class IbdResult (line 123) | class IbdResult:
method __init__ (line 129) | def __init__(self):
method __repr__ (line 132) | def __repr__(self):
method __str__ (line 135) | def __str__(self):
method add_segment_deprecated (line 138) | def add_segment_deprecated(self, a, b, seg):
method add_segment (line 143) | def add_segment(self, a, b, seg):
class IbdFinder (line 203) | class IbdFinder:
method __init__ (line 208) | def __init__(self, ts, *, within=None, between=None, min_span=0, max_t...
method print_state (line 232) | def print_state(self):
method run (line 241) | def run(self, squash=False):
method record_ibd (line 265) | def record_ibd(self, current_parent, child_segs, squash):
method filter_by_min_span (line 299) | def filter_by_min_span(self):
method passes_filters (line 316) | def passes_filters(self, a, b, left, right):
FILE: python/tests/simplify.py
function overlapping_segments (line 35) | def overlapping_segments(segments):
class Segment (line 70) | class Segment:
method __init__ (line 79) | def __init__(self, left=None, right=None, node=None, next_segment=None):
method __str__ (line 85) | def __str__(self):
method __repr__ (line 91) | def __repr__(self):
method __lt__ (line 94) | def __lt__(self, other):
class Simplifier (line 98) | class Simplifier:
method __init__ (line 104) | def __init__(
method record_node (line 179) | def record_node(self, input_id):
method rewind_node (line 195) | def rewind_node(self, input_id, output_id):
method flush_edges (line 205) | def flush_edges(self):
method record_edge (line 218) | def record_edge(self, left, right, parent, child):
method print_state (line 247) | def print_state(self):
method map_mutations (line 273) | def map_mutations(self, left, right, input_id, output_id):
method add_ancestry (line 285) | def add_ancestry(self, input_id, left, right, node):
method merge_labeled_ancestors (line 301) | def merge_labeled_ancestors(self, S, input_id):
method extract_ancestry (line 353) | def extract_ancestry(self, edge):
method process_parent_edges (line 398) | def process_parent_edges(self, edges):
method finalise_sites (line 410) | def finalise_sites(self):
method finalise_references (line 446) | def finalise_references(self):
method insert_input_roots (line 508) | def insert_input_roots(self):
method simplify (line 540) | def simplify(self):
method check_state (line 559) | def check_state(self):
class AncestorMap (line 594) | class AncestorMap:
method __init__ (line 600) | def __init__(self, ts, sample, ancestors):
method link_ancestors (line 617) | def link_ancestors(self):
method process_parent_edges (line 631) | def process_parent_edges(self, edges):
method merge_labeled_ancestors (line 648) | def merge_labeled_ancestors(self, S, input_id):
method record_edge (line 687) | def record_edge(self, left, right, parent, child):
method add_ancestry (line 700) | def add_ancestry(self, left, right, node, current_node):
method flush_edges (line 714) | def flush_edges(self):
method check_state (line 727) | def check_state(self):
method print_state (line 750) | def print_state(self):
FILE: python/tests/test_avl_tree.py
class Node (line 53) | class Node:
method __str__ (line 59) | def __str__(self):
function get_link (line 71) | def get_link(a, P):
function set_link (line 78) | def set_link(a, P, val):
class AvlTree (line 85) | class AvlTree:
method __init__ (line 86) | def __init__(self):
method root (line 92) | def root(self):
method __str__ (line 95) | def __str__(self):
method ordered_keys (line 106) | def ordered_keys(self):
method search (line 120) | def search(self, key):
method __insert_empty (line 131) | def __insert_empty(self, key):
method __insert (line 138) | def __insert(self, K):
method insert (line 253) | def insert(self, key):
class TestAvlTree (line 259) | class TestAvlTree:
method verify_tree (line 260) | def verify_tree(self, tree):
method verify (line 308) | def verify(self, keys):
method test_sequential (line 346) | def test_sequential(self, n):
method test_sequential_reversed (line 350) | def test_sequential_reversed(self, n):
method test_random_integers (line 354) | def test_random_integers(self, n):
method test_random_floats (line 360) | def test_random_floats(self, n):
FILE: python/tests/test_balance_metrics.py
function sackin_index_definition (line 39) | def sackin_index_definition(tree):
function colless_index_definition (line 43) | def colless_index_definition(tree):
function b1_index_definition (line 62) | def b1_index_definition(tree):
function b2_index_definition (line 70) | def b2_index_definition(tree, base=10):
class TestDefinitions (line 80) | class TestDefinitions:
method test_sackin (line 82) | def test_sackin(self, ts):
method test_colless (line 87) | def test_colless(self, ts):
method test_b1 (line 101) | def test_b1(self, ts):
method test_b2 (line 106) | def test_b2(self, ts):
method test_b2_base (line 118) | def test_b2_base(self, ts, base):
class TestBalancedBinaryOdd (line 131) | class TestBalancedBinaryOdd:
method tree (line 139) | def tree(self):
method test_sackin (line 142) | def test_sackin(self):
method test_colless (line 145) | def test_colless(self):
method test_b1 (line 148) | def test_b1(self):
method test_b2 (line 151) | def test_b2(self):
class TestBalancedBinaryEven (line 155) | class TestBalancedBinaryEven:
method tree (line 163) | def tree(self):
method test_sackin (line 166) | def test_sackin(self):
method test_colless (line 169) | def test_colless(self):
method test_b1 (line 172) | def test_b1(self):
method test_b2 (line 175) | def test_b2(self):
method test_b2_base (line 191) | def test_b2_base(self, base, expected):
method test_b2_bad_base (line 195) | def test_b2_bad_base(self, base):
method test_b2_base1 (line 199) | def test_b2_base1(self):
class TestBalancedTernary (line 204) | class TestBalancedTernary:
method tree (line 212) | def tree(self):
method test_sackin (line 215) | def test_sackin(self):
method test_colless (line 218) | def test_colless(self):
method test_b1 (line 222) | def test_b1(self):
method test_b2 (line 225) | def test_b2(self):
class TestStarN10 (line 229) | class TestStarN10:
method tree (line 235) | def tree(self):
method test_sackin (line 238) | def test_sackin(self):
method test_colless (line 241) | def test_colless(self):
method test_b1 (line 245) | def test_b1(self):
method test_b2 (line 248) | def test_b2(self):
class TestCombN5 (line 252) | class TestCombN5:
method tree (line 264) | def tree(self):
method test_sackin (line 267) | def test_sackin(self):
method test_colless (line 270) | def test_colless(self):
method test_b1 (line 273) | def test_b1(self):
method test_b2 (line 276) | def test_b2(self):
class TestMultiRootBinary (line 280) | class TestMultiRootBinary:
method tree (line 290) | def tree(self):
method test_sackin (line 299) | def test_sackin(self):
method test_colless (line 302) | def test_colless(self):
method test_b1 (line 306) | def test_b1(self):
method test_b2 (line 309) | def test_b2(self):
class TestEmpty (line 314) | class TestEmpty:
method tree (line 316) | def tree(self):
method test_sackin (line 320) | def test_sackin(self):
method test_colless (line 323) | def test_colless(self):
method test_b1 (line 327) | def test_b1(self):
method test_b2 (line 330) | def test_b2(self):
class TestTreeInNullState (line 335) | class TestTreeInNullState:
method tree (line 337) | def tree(self):
method test_sackin (line 342) | def test_sackin(self):
method test_colless (line 345) | def test_colless(self):
method test_b1 (line 349) | def test_b1(self):
method test_b2 (line 352) | def test_b2(self):
class TestAllRootsN5 (line 357) | class TestAllRootsN5:
method tree (line 359) | def tree(self):
method test_sackin (line 365) | def test_sackin(self):
method test_colless (line 368) | def test_colless(self):
method test_b1 (line 372) | def test_b1(self):
method test_b2 (line 375) | def test_b2(self):
FILE: python/tests/test_cli.py
class TestException (line 43) | class TestException(Exception):
function capture_output (line 50) | def capture_output(func, *args, **kwargs):
class TestCli (line 76) | class TestCli(unittest.TestCase):
method setUp (line 81) | def setUp(self):
method tearDown (line 85) | def tearDown(self):
class TestTskitArgumentParser (line 89) | class TestTskitArgumentParser:
method test_individuals_default_values (line 94) | def test_individuals_default_values(self):
method test_individuals_short_args (line 102) | def test_individuals_short_args(self):
method test_individuals_long_args (line 110) | def test_individuals_long_args(self):
method test_nodes_default_values (line 118) | def test_nodes_default_values(self):
method test_nodes_short_args (line 126) | def test_nodes_short_args(self):
method test_nodes_long_args (line 134) | def test_nodes_long_args(self):
method test_edges_default_values (line 142) | def test_edges_default_values(self):
method test_edges_short_args (line 150) | def test_edges_short_args(self):
method test_edges_long_args (line 158) | def test_edges_long_args(self):
method test_sites_default_values (line 166) | def test_sites_default_values(self):
method test_sites_short_args (line 174) | def test_sites_short_args(self):
method test_sites_long_args (line 182) | def test_sites_long_args(self):
method test_mutations_default_values (line 190) | def test_mutations_default_values(self):
method test_mutations_short_args (line 198) | def test_mutations_short_args(self):
method test_mutations_long_args (line 206) | def test_mutations_long_args(self):
method test_provenances_default_values (line 214) | def test_provenances_default_values(self):
method test_provenances_short_args (line 222) | def test_provenances_short_args(self):
method test_provenances_long_args (line 230) | def test_provenances_long_args(self):
method test_fasta_default_values (line 239) | def test_fasta_default_values(self):
method test_fasta_short_args (line 248) | def test_fasta_short_args(self):
method test_fasta_long_args (line 257) | def test_fasta_long_args(self):
method test_vcf_ploidy (line 273) | def test_vcf_ploidy(self, flags, expected):
method test_vcf_contig_id (line 289) | def test_vcf_contig_id(self, flags, expected):
method test_vcf_allow_position_zero (line 305) | def test_vcf_allow_position_zero(self, flags, expected):
method test_info_default_values (line 313) | def test_info_default_values(self):
method test_populations_default_values (line 320) | def test_populations_default_values(self):
method test_migrations_default_values (line 327) | def test_migrations_default_values(self):
method test_migrations_short_args (line 334) | def test_migrations_short_args(self):
method test_migrations_long_args (line 342) | def test_migrations_long_args(self):
method test_trees_default_values (line 350) | def test_trees_default_values(self):
method test_trees_short_args (line 359) | def test_trees_short_args(self):
method test_trees_long_args (line 368) | def test_trees_long_args(self):
class TestTskitConversionOutput (line 378) | class TestTskitConversionOutput(unittest.TestCase):
method setUpClass (line 384) | def setUpClass(cls):
method tearDownClass (line 405) | def tearDownClass(cls):
method verify_individuals (line 408) | def verify_individuals(self, output_individuals, precision):
method test_individuals (line 415) | def test_individuals(self):
method verify_nodes (line 425) | def verify_nodes(self, output_nodes, precision):
method test_nodes (line 432) | def test_nodes(self):
method verify_edges (line 442) | def verify_edges(self, output_edges, precision):
method test_edges (line 449) | def test_edges(self):
method verify_sites (line 459) | def verify_sites(self, output_sites, precision):
method test_sites (line 466) | def test_sites(self):
method verify_mutations (line 476) | def verify_mutations(self, output_mutations, precision):
method test_mutations (line 483) | def test_mutations(self):
method verify_migrations (line 493) | def verify_migrations(self, output_migrations, precision):
method test_migrations (line 500) | def test_migrations(self):
method verify_provenances (line 510) | def verify_provenances(self, output_provenances):
method test_provenances (line 517) | def test_provenances(self):
method test_provenances_human (line 524) | def test_provenances_human(self):
method verify_fasta (line 534) | def verify_fasta(self, output_fasta):
method test_fasta (line 542) | def test_fasta(self):
method verify_vcf (line 548) | def verify_vcf(self, output_vcf):
method test_vcf (line 555) | def test_vcf(self):
method verify_info (line 563) | def verify_info(self, ts, output_info):
method test_info (line 566) | def test_info(self):
method test_trees_no_draw (line 573) | def test_trees_no_draw(self):
method test_trees_draw (line 580) | def test_trees_draw(self):
class TestVCFZeroPosition (line 590) | class TestVCFZeroPosition:
method test_zero_position (line 595) | def test_zero_position(self, tmp_path):
class TestBadFile (line 606) | class TestBadFile:
method verify (line 611) | def verify(self, command):
method test_info (line 619) | def test_info(self):
method test_fasta (line 622) | def test_fasta(self):
method test_vcf (line 625) | def test_vcf(self):
method test_nodes (line 628) | def test_nodes(self):
method test_edges (line 631) | def test_edges(self):
method test_sites (line 634) | def test_sites(self):
method test_mutations (line 637) | def test_mutations(self):
method test_migrations (line 640) | def test_migrations(self):
method test_provenances (line 643) | def test_provenances(self):
FILE: python/tests/test_coalrate.py
function _single_tree_example (line 37) | def _single_tree_example(L, T):
function _nonmissing_window_span (line 63) | def _nonmissing_window_span(ts, windows):
function _pair_coalescence_weights (line 93) | def _pair_coalescence_weights(
function _pair_coalescence_rates (line 100) | def _pair_coalescence_rates(
function _pair_coalescence_quantiles (line 136) | def _pair_coalescence_quantiles(
function _pair_coalescence_stat (line 169) | def _pair_coalescence_stat(
function proto_pair_coalescence_counts (line 382) | def proto_pair_coalescence_counts(
function proto_pair_coalescence_rates (line 457) | def proto_pair_coalescence_rates(
function proto_pair_coalescence_quantiles (line 540) | def proto_pair_coalescence_quantiles(
function naive_pair_coalescence_counts (line 608) | def naive_pair_coalescence_counts(ts, sample_set_0, sample_set_1):
function _numpy_weighted_quantile (line 633) | def _numpy_weighted_quantile(values, weights, quantiles):
function _numpy_hazard_rate (line 648) | def _numpy_hazard_rate(values, weights, breaks):
function convert_to_nonsuccinct (line 677) | def convert_to_nonsuccinct(ts):
class TestCoalescingPairsOneTree (line 717) | class TestCoalescingPairsOneTree:
method example_ts (line 722) | def example_ts(self):
method test_total_pairs (line 757) | def test_total_pairs(self):
method test_population_pairs (line 779) | def test_population_pairs(self):
method test_internal_samples (line 809) | def test_internal_samples(self):
method test_windows (line 838) | def test_windows(self):
method test_time_windows (line 853) | def test_time_windows(self):
method test_pair_normalise (line 880) | def test_pair_normalise(self):
method test_multiple_roots (line 906) | def test_multiple_roots(self):
class TestCoalescingPairsTwoTree (line 918) | class TestCoalescingPairsTwoTree:
method example_ts (line 923) | def example_ts(self, S, L):
method test_total_pairs (line 950) | def test_total_pairs(self):
method test_population_pairs (line 972) | def test_population_pairs(self):
method test_internal_samples (line 1003) | def test_internal_samples(self):
method test_windows (line 1030) | def test_windows(self):
method test_time_windows (line 1056) | def test_time_windows(self):
method test_pair_normalise (line 1092) | def test_pair_normalise(self):
method test_multiple_roots (line 1119) | def test_multiple_roots(self):
class TestCoalescingPairsSimulated (line 1134) | class TestCoalescingPairsSimulated:
method example_ts (line 1140) | def example_ts(self):
method _check_total_pairs (line 1162) | def _check_total_pairs(ts, windows):
method _check_subset_pairs (line 1176) | def _check_subset_pairs(ts, windows):
method test_sequence (line 1201) | def test_sequence(self):
method test_missing_interval (line 1207) | def test_missing_interval(self):
method test_missing_leaves (line 1218) | def test_missing_leaves(self):
method test_multiple_roots (line 1238) | def test_multiple_roots(self):
method test_windows (line 1248) | def test_windows(self):
method test_windows_are_trees (line 1254) | def test_windows_are_trees(self):
method test_windows_inside_trees (line 1263) | def test_windows_inside_trees(self):
method test_nonsuccinct_sequence (line 1273) | def test_nonsuccinct_sequence(self):
method test_span_normalise (line 1282) | def test_span_normalise(self):
method test_span_normalise_with_missing_flanks (line 1296) | def test_span_normalise_with_missing_flanks(self):
method test_span_normalise_with_missing_interior (line 1315) | def test_span_normalise_with_missing_interior(self):
method test_empty_windows (line 1339) | def test_empty_windows(self):
method test_pair_normalise (line 1354) | def test_pair_normalise(self):
method test_internal_nodes_are_samples (line 1371) | def test_internal_nodes_are_samples(self):
method test_time_windows (line 1387) | def test_time_windows(self):
method test_time_windows_truncated (line 1411) | def test_time_windows_truncated(self):
method test_time_windows_unique (line 1440) | def test_time_windows_unique(self):
method test_diversity (line 1464) | def test_diversity(self):
method test_divergence (line 1479) | def test_divergence(self):
class TestCoalescingPairsUsage (line 1499) | class TestCoalescingPairsUsage:
method example_ts (line 1505) | def example_ts(self):
method test_bad_windows (line 1514) | def test_bad_windows(self):
method test_bad_sample_sets (line 1527) | def test_bad_sample_sets(self):
method test_bad_indexes (line 1532) | def test_bad_indexes(self):
method test_no_indexes (line 1539) | def test_no_indexes(self):
method test_oob_samples (line 1545) | def test_oob_samples(self):
method test_uncalibrated_time (line 1551) | def test_uncalibrated_time(self):
method test_bad_time_windows (line 1559) | def test_bad_time_windows(self, time_windows):
method test_unsorted_time_windows (line 1564) | def test_unsorted_time_windows(self):
method test_empty_time_windows (line 1570) | def test_empty_time_windows(self):
method test_output_dim (line 1577) | def test_output_dim(self):
method test_extra_time_windows (line 1596) | def test_extra_time_windows(self):
class TestPairCoalescenceQuantiles (line 1616) | class TestPairCoalescenceQuantiles:
method example_ts (line 1622) | def example_ts(self):
method test_quantiles (line 1641) | def test_quantiles(self):
method test_windows (line 1652) | def test_windows(self):
method test_sample_sets (line 1663) | def test_sample_sets(self):
method test_observations_are_quantiles (line 1680) | def test_observations_are_quantiles(self):
method test_errors (line 1691) | def test_errors(self):
method test_long_sequence (line 1702) | def test_long_sequence(self):
method test_empty_windows (line 1725) | def test_empty_windows(self):
class TestPairCoalescenceRates (line 1739) | class TestPairCoalescenceRates:
method example_ts (line 1745) | def example_ts(self):
method test_simulated (line 1762) | def test_simulated(self):
method test_windowed (line 1772) | def test_windowed(self):
method test_truncated (line 1786) | def test_truncated(self):
method test_empty (line 1795) | def test_empty(self):
method test_single (line 1810) | def test_single(self):
method test_indexes (line 1819) | def test_indexes(self):
method test_errors (line 1830) | def test_errors(self):
method test_long_sequence (line 1843) | def test_long_sequence(self):
method test_extra_time_windows (line 1867) | def test_extra_time_windows(self):
method test_missing_sequence (line 1886) | def test_missing_sequence(self):
method test_empty_windows (line 1902) | def test_empty_windows(self):
FILE: python/tests/test_combinatorics.py
class TestCombination (line 45) | class TestCombination:
method test_combination_with_replacement_rank_unrank (line 46) | def test_combination_with_replacement_rank_unrank(self):
method test_combination_rank_unrank (line 58) | def test_combination_rank_unrank(self):
method test_combination_unrank_errors (line 67) | def test_combination_unrank_errors(self):
method verify_unrank_errors (line 71) | def verify_unrank_errors(self, rank, n, k):
class TestPartition (line 76) | class TestPartition:
method test_rule_asc (line 77) | def test_rule_asc(self):
method verify_rule_asc (line 103) | def verify_rule_asc(self, n, partitions):
method test_partitions (line 106) | def test_partitions(self):
method test_group_partition (line 111) | def test_group_partition(self):
class TestRankTree (line 118) | class TestRankTree:
method test_num_shapes (line 120) | def test_num_shapes(self, n):
method test_num_labellings (line 125) | def test_num_labellings(self, n):
method test_num_labelled_trees (line 132) | def test_num_labelled_trees(self):
method test_all_labelled_trees_3 (line 139) | def test_all_labelled_trees_3(self):
method test_all_labelled_trees_4 (line 144) | def test_all_labelled_trees_4(self):
method test_generate_trees_roundtrip (line 182) | def test_generate_trees_roundtrip(self):
method test_generate_treeseq_roundtrip (line 189) | def test_generate_treeseq_roundtrip(self):
method test_all_shapes_roundtrip (line 199) | def test_all_shapes_roundtrip(self):
method test_all_labellings_roundtrip (line 206) | def test_all_labellings_roundtrip(self):
method test_unrank_labelled (line 216) | def test_unrank_labelled(self, n):
method test_unrank_unlabelled (line 223) | def test_unrank_unlabelled(self, n):
method test_unrank_errors (line 233) | def test_unrank_errors(self):
method verify_unrank_errors (line 253) | def verify_unrank_errors(self, rank, n):
method test_shape_rank (line 260) | def test_shape_rank(self, n):
method test_shape_unrank (line 265) | def test_shape_unrank(self, n):
method test_shape_unrank_tsk_tree (line 271) | def test_shape_unrank_tsk_tree(self, n):
method test_label_rank (line 279) | def test_label_rank(self, n):
method test_label_unrank (line 285) | def test_label_unrank(self, n):
method test_rank_names (line 293) | def test_rank_names(self):
method test_unrank_rank_round_trip (line 303) | def test_unrank_rank_round_trip(self, n):
method test_is_canonical (line 315) | def test_is_canonical(self):
method test_unranking_is_canonical (line 362) | def test_unranking_is_canonical(self, n):
method test_to_from_tsk_tree (line 373) | def test_to_from_tsk_tree(self, n):
method test_to_tsk_tree_internal_nodes (line 382) | def test_to_tsk_tree_internal_nodes(self, n):
method test_from_unary_tree (line 397) | def test_from_unary_tree(self):
method test_to_tsk_tree_errors (line 407) | def test_to_tsk_tree_errors(self):
method test_rank_errors_multiple_roots (line 415) | def test_rank_errors_multiple_roots(self):
method test_span (line 430) | def test_span(self):
method test_big_trees (line 440) | def test_big_trees(self):
method test_symmetrical_trees (line 455) | def test_symmetrical_trees(self):
method test_equal (line 461) | def test_equal(self):
method test_is_symmetrical (line 482) | def test_is_symmetrical(self):
class TestPartialTopologyCounter (line 496) | class TestPartialTopologyCounter:
method test_add_sibling_topologies_simple (line 497) | def test_add_sibling_topologies_simple(self):
method test_add_sibling_topologies_polytomy (line 521) | def test_add_sibling_topologies_polytomy(self):
method test_join_topologies (line 587) | def test_join_topologies(self):
method verify_join_topologies (line 607) | def verify_join_topologies(self, topologies, expected_topology):
class TestCountTopologies (line 612) | class TestCountTopologies:
method verify_topologies (line 613) | def verify_topologies(self, ts, sample_sets=None, expected=None):
method test_no_iterate (line 638) | def test_no_iterate(self):
method subsample_topologies (line 643) | def subsample_topologies(self, ts, sample_sets, sample_set_indexes):
method test_single_population (line 655) | def test_single_population(self):
method test_three_populations (line 662) | def test_three_populations(self):
method test_multiple_roots (line 708) | def test_multiple_roots(self):
method test_no_sample_subtrees (line 724) | def test_no_sample_subtrees(self):
method test_no_full_topology (line 740) | def test_no_full_topology(self):
method test_polytomies (line 759) | def test_polytomies(self):
method test_custom_key (line 777) | def test_custom_key(self):
method test_ignores_non_sample_leaves (line 825) | def test_ignores_non_sample_leaves(self):
method test_internal_samples_errors (line 873) | def test_internal_samples_errors(self):
method test_non_sample_nodes_errors (line 885) | def test_non_sample_nodes_errors(self):
method verify_value_error (line 901) | def verify_value_error(self, ts, sample_sets=None):
method verify_node_out_of_bounds_error (line 907) | def verify_node_out_of_bounds_error(self, ts, sample_sets=None):
method test_standard_msprime_migrations (line 913) | def test_standard_msprime_migrations(self):
method simulate_multiple_populations (line 919) | def simulate_multiple_populations(self, sample_sizes):
method test_msprime_dtwf (line 937) | def test_msprime_dtwf(self):
method test_forward_time_wright_fisher_unsimplified_all_sample_sets (line 971) | def test_forward_time_wright_fisher_unsimplified_all_sample_sets(self):
method test_forward_time_wright_fisher_unsimplified (line 985) | def test_forward_time_wright_fisher_unsimplified(self):
method test_forward_time_wright_fisher_simplified (line 999) | def test_forward_time_wright_fisher_simplified(self):
class TestTreeNode (line 1014) | class TestTreeNode:
method verify_tree (line 1019) | def verify_tree(self, root, labels):
method test_random_binary_tree (line 1039) | def test_random_binary_tree(self, n):
method test_balanced_binary (line 1046) | def test_balanced_binary(self, n):
method test_balanced_arity (line 1051) | def test_balanced_arity(self, arity):
function num_leaf_labelled_binary_trees (line 1057) | def num_leaf_labelled_binary_trees(n):
class TestPolytomySplitting (line 1069) | class TestPolytomySplitting:
method ts_polytomy_44344 (line 1104) | def ts_polytomy_44344(self):
method verify_trees (line 1111) | def verify_trees(self, source_tree, split_tree, epsilon=None):
method test_resolve_star (line 1133) | def test_resolve_star(self, n):
method test_large_epsilon (line 1137) | def test_large_epsilon(self):
method test_small_epsilon (line 1143) | def test_small_epsilon(self):
method test_nextafter_near_zero (line 1149) | def test_nextafter_near_zero(self):
method test_nextafter_large_tree (line 1154) | def test_nextafter_large_tree(self):
method test_epsilon_near_one (line 1166) | def test_epsilon_near_one(self):
method verify_tree_sequence_splits (line 1171) | def verify_tree_sequence_splits(self, ts):
method test_complex_examples (line 1204) | def test_complex_examples(self):
method test_nonbinary_simulation (line 1207) | def test_nonbinary_simulation(self):
method test_seeds (line 1220) | def test_seeds(self):
method test_internal_polytomy (line 1232) | def test_internal_polytomy(self):
method test_binary_tree (line 1248) | def test_binary_tree(self):
method test_bad_method (line 1254) | def test_bad_method(self):
method test_epsilon_too_large (line 1260) | def test_epsilon_too_large(self, epsilon):
method test_epsilon_too_small (line 1274) | def test_epsilon_too_small(self):
method test_unsplittable_branch (line 1289) | def test_unsplittable_branch(self):
method test_epsilon_for_mutations (line 1305) | def test_epsilon_for_mutations(self):
method test_mutation_within_eps_parent (line 1319) | def test_mutation_within_eps_parent(self):
method test_provenance (line 1336) | def test_provenance(self):
method test_kwargs (line 1347) | def test_kwargs(self):
method test_all_topologies (line 1354) | def test_all_topologies(self, n):
class TreeGeneratorTestBase (line 1366) | class TreeGeneratorTestBase:
method method (line 1373) | def method(self, n, **kwargs):
method test_leaves (line 1377) | def test_leaves(self, n):
method test_bad_n (line 1381) | def test_bad_n(self):
method test_bad_span (line 1389) | def test_bad_span(self):
method test_bad_branch_length (line 1393) | def test_bad_branch_length(self):
method test_span (line 1398) | def test_span(self, span):
method test_branch_length (line 1403) | def test_branch_length(self, branch_length):
method test_provenance (line 1409) | def test_provenance(self):
method test_rank_unrank_round_trip (line 1418) | def test_rank_unrank_round_trip(self, n):
method test_kwargs (line 1426) | def test_kwargs(self):
class TestGenerateStar (line 1431) | class TestGenerateStar(TreeGeneratorTestBase):
method test_unrank_equal (line 1435) | def test_unrank_equal(self, n):
method test_branch_length_semantics (line 1441) | def test_branch_length_semantics(self):
class TestGenerateBalanced (line 1450) | class TestGenerateBalanced(TreeGeneratorTestBase):
method test_arity_leaves (line 1454) | def test_arity_leaves(self, arity):
method test_binary_unrank_equal (line 1460) | def test_binary_unrank_equal(self, n):
method test_rank_unrank_round_trip_arity (line 1470) | def test_rank_unrank_round_trip_arity(self, n, arity):
method test_bad_arity (line 1478) | def test_bad_arity(self):
method test_branch_length_semantics (line 1483) | def test_branch_length_semantics(self):
class TestGenerateRandomBinary (line 1492) | class TestGenerateRandomBinary(TreeGeneratorTestBase):
method method (line 1495) | def method(self, n, **kwargs):
method test_all_topologies (line 1500) | def test_all_topologies(self, n):
method test_leaves (line 1511) | def test_leaves(self, n):
method test_rank_unrank_round_trip_seeds (line 1517) | def test_rank_unrank_round_trip_seeds(self, seed):
class TestGenerateComb (line 1527) | class TestGenerateComb(TreeGeneratorTestBase):
method test_unrank_equal (line 1532) | def test_unrank_equal(self, n, rank):
method test_branch_length_semantics (line 1538) | def test_branch_length_semantics(self):
class TestEqualChunks (line 1544) | class TestEqualChunks:
method test_evenly_divisible (line 1546) | def test_evenly_divisible(self, n, k):
method test_one_chunk (line 1555) | def test_one_chunk(self, n):
method test_empty_chunks (line 1561) | def test_empty_chunks(self, n, k):
method test_trailing_chunk (line 1570) | def test_trailing_chunk(self, n, k):
method test_empty_list (line 1576) | def test_empty_list(self):
method test_bad_num_chunks (line 1580) | def test_bad_num_chunks(self):
FILE: python/tests/test_dict_encoding.py
function test_pickled_examples (line 40) | def test_pickled_examples():
FILE: python/tests/test_distance_metrics.py
function c_kc_distance (line 43) | def c_kc_distance(tree1, tree2, lambda_=0):
function naive_kc_distance (line 69) | def naive_kc_distance(tree1, tree2, lambda_=0):
class KCVectors (line 110) | class KCVectors:
method __init__ (line 121) | def __init__(self, n):
function fill_kc_vectors (line 128) | def fill_kc_vectors(tree, kc_vecs):
function update_kc_vectors_single_leaf (line 152) | def update_kc_vectors_single_leaf(kc_vecs, u, time, sample_index_map):
function update_kc_vectors_all_pairs (line 158) | def update_kc_vectors_all_pairs(tree, kc_vecs, c1, c2, depth, time):
function update_kc_vectors_pair (line 172) | def update_kc_vectors_pair(kc_vecs, n1, n2, depth, time):
function norm_kc_vectors (line 181) | def norm_kc_vectors(kc_vecs1, kc_vecs2, lambda_):
class TestKCMetric (line 193) | class TestKCMetric(unittest.TestCase):
method test_same_tree_zero_distance (line 198) | def test_same_tree_zero_distance(self):
method test_sample_2_zero_distance (line 212) | def test_sample_2_zero_distance(self):
method test_different_samples_error (line 223) | def test_different_samples_error(self):
method validate_trees (line 258) | def validate_trees(self, n):
method test_sample_3 (line 273) | def test_sample_3(self):
method test_sample_4 (line 276) | def test_sample_4(self):
method test_sample_10 (line 279) | def test_sample_10(self):
method test_sample_20 (line 282) | def test_sample_20(self):
method validate_nonbinary_trees (line 285) | def validate_nonbinary_trees(self, n):
method test_non_binary_sample_10 (line 315) | def test_non_binary_sample_10(self):
method test_non_binary_sample_20 (line 318) | def test_non_binary_sample_20(self):
method test_non_binary_sample_30 (line 321) | def test_non_binary_sample_30(self):
method verify_result (line 324) | def verify_result(self, tree1, tree2, lambda_, result, places=None):
method test_known_kc_sample_3 (line 339) | def test_known_kc_sample_3(self):
method test_10_samples (line 369) | def test_10_samples(self):
method test_15_samples (line 476) | def test_15_samples(self):
method test_nobinary_trees (line 625) | def test_nobinary_trees(self):
method test_multiple_roots (line 740) | def test_multiple_roots(self):
method do_kc_distance (line 760) | def do_kc_distance(self, t1, t2, lambda_=0):
method test_non_initial_samples (line 773) | def test_non_initial_samples(self):
method test_internal_samples (line 781) | def test_internal_samples(self):
method test_root_sample (line 791) | def test_root_sample(self):
method test_non_sample_leaf (line 798) | def test_non_sample_leaf(self):
method test_ignores_subtrees_with_no_samples (line 822) | def test_ignores_subtrees_with_no_samples(self):
function ts_kc_distance (line 887) | def ts_kc_distance(ts1, ts2, lambda_=0):
function ts_kc_distance_incremental (line 908) | def ts_kc_distance_incremental(ts1, ts2, lambda_=0):
function update_kc_incremental (line 946) | def update_kc_incremental(tree, kc, edge_diffs, sample_index_map, depths):
function update_kc_subtree_state (line 977) | def update_kc_subtree_state(tree, kc, u, sample_index_map, depths):
function update_kc_pairs_with_leaf (line 1000) | def update_kc_pairs_with_leaf(tree, kc, leaf, sample_index_map, depths):
function check_kc_tree_sequence_inputs (line 1017) | def check_kc_tree_sequence_inputs(ts1, ts2):
function check_kc_tree_inputs (line 1032) | def check_kc_tree_inputs(tree1, tree2):
class TestKCSequenceMetric (line 1041) | class TestKCSequenceMetric(unittest.TestCase):
method test_0_distance_from_self (line 1046) | def test_0_distance_from_self(self):
method verify_errors (line 1050) | def verify_errors(self, ts1, ts2):
method test_errors_diff_seq_length (line 1058) | def test_errors_diff_seq_length(self):
method test_errors_diff_num_samples (line 1063) | def test_errors_diff_num_samples(self):
method test_errors_different_sample_lists (line 1068) | def test_errors_different_sample_lists(self):
method test_errors_unary_nodes (line 1104) | def test_errors_unary_nodes(self):
method test_errors_different_samples (line 1123) | def test_errors_different_samples(self):
method verify_result (line 1128) | def verify_result(self, ts1, ts2, lambda_, result, places=None):
method verify_same_kc (line 1143) | def verify_same_kc(self, ts1, ts2, lambda_=0):
method validate_trees (line 1156) | def validate_trees(self, n):
method test_sample_5 (line 1164) | def test_sample_5(self):
method test_sample_10 (line 1167) | def test_sample_10(self):
method test_sample_20 (line 1170) | def test_sample_20(self):
method validate_nonbinary_trees (line 1173) | def validate_nonbinary_trees(self, n):
method test_non_binary_sample_10 (line 1206) | def test_non_binary_sample_10(self):
method test_non_binary_sample_20 (line 1209) | def test_non_binary_sample_20(self):
method test_permit_internal_samples (line 1212) | def test_permit_internal_samples(self):
method test_known_kc_sample_trees_different_shapes (line 1223) | def test_known_kc_sample_trees_different_shapes(self):
method test_known_kc_sample_trees_same_shape_different_times (line 1258) | def test_known_kc_sample_trees_same_shape_different_times(self):
method test_known_kc_same_tree_twice_same_metric (line 1288) | def test_known_kc_same_tree_twice_same_metric(self):
method test_remove_root (line 1317) | def test_remove_root(self):
method test_ignores_subtrees_with_no_samples (line 1357) | def test_ignores_subtrees_with_no_samples(self):
class TestTreeSameSamples (line 1428) | class TestTreeSameSamples:
method tree (line 1448) | def tree(self):
method tree_other (line 1452) | def tree_other(self):
method test_rf_distance (line 1455) | def test_rf_distance(self):
class TestTreeDifferentSamples (line 1459) | class TestTreeDifferentSamples:
method tree (line 1481) | def tree(self):
method tree_other (line 1485) | def tree_other(self):
method test_rf_distance (line 1488) | def test_rf_distance(self):
class TestTreeMultiRoots (line 1492) | class TestTreeMultiRoots:
method tree (line 1516) | def tree(self):
method tree_other (line 1520) | def tree_other(self):
method test_rf_distance (line 1529) | def test_rf_distance(self):
class TestEmpty (line 1534) | class TestEmpty:
method tree (line 1536) | def tree(self):
method tree_other (line 1541) | def tree_other(self):
method test_rf_distance (line 1545) | def test_rf_distance(self):
class TestTreeInNullState (line 1550) | class TestTreeInNullState:
method tsk_tree1 (line 1552) | def tsk_tree1(self):
method tree_other (line 1558) | def tree_other(self):
method test_rf_distance (line 1563) | def test_rf_distance(self):
class TestAllRootsN5 (line 1568) | class TestAllRootsN5:
method tree (line 1570) | def tree(self):
method test_rf_distance (line 1576) | def test_rf_distance(self):
class TestWithPackages (line 1581) | class TestWithPackages:
method to_dendropy (line 1582) | def to_dendropy(self, newick_data, tns):
method dendropy_rf_distance (line 1590) | def dendropy_rf_distance(self, tree1, tree2, weighted=False):
method test_rf_distance_against_dendropy (line 1602) | def test_rf_distance_against_dendropy(self, n):
class TestDistanceBetween (line 1612) | class TestDistanceBetween:
method test_distance_between_sample (line 1617) | def test_distance_between_sample(self, u, v):
method test_distance_between_same_node (line 1626) | def test_distance_between_same_node(self):
method test_distance_between_nodes (line 1633) | def test_distance_between_nodes(self):
method test_distance_between_invalid_nodes (line 1648) | def test_distance_between_invalid_nodes(self):
FILE: python/tests/test_divmat.py
function sv_tables_init (line 50) | def sv_tables_init(parent_array):
function _sv_mrca (line 126) | def _sv_mrca(x, y, lambd, pi, tau, beta, alpha):
function sv_mrca (line 151) | def sv_mrca(x, y, lambd, pi, tau, beta, alpha):
function local_root (line 156) | def local_root(tree, u):
function span_normalise_windows (line 162) | def span_normalise_windows(D, windows):
function sample_set_normalisation (line 169) | def sample_set_normalisation(sample_sets):
function branch_divergence_matrix (line 183) | def branch_divergence_matrix(ts, sample_sets=None, windows=None, span_no...
function divergence_matrix (line 238) | def divergence_matrix(
function stats_api_divergence_matrix (line 261) | def stats_api_divergence_matrix(ts, *args, **kwargs):
function stats_api_genetic_relatedness_matrix (line 265) | def stats_api_genetic_relatedness_matrix(ts, *args, **kwargs):
function stats_api_matrix_method (line 270) | def stats_api_matrix_method(
function group_alleles (line 331) | def group_alleles(genotypes, num_alleles):
function site_divergence_matrix (line 346) | def site_divergence_matrix(ts, sample_sets, *, windows=None, span_normal...
function check_divmat (line 395) | def check_divmat(
class TestExamplesWithAnswer (line 456) | class TestExamplesWithAnswer:
method test_single_tree_zero_samples (line 458) | def test_single_tree_zero_samples(self, mode):
method test_single_tree_zero_samples_windows (line 465) | def test_single_tree_zero_samples_windows(self, num_windows, mode):
method test_single_tree_sites_per_branch (line 472) | def test_single_tree_sites_per_branch(self, m):
method test_single_tree_mutations_per_branch (line 493) | def test_single_tree_mutations_per_branch(self, m):
method test_single_tree_unique_sample_alleles (line 517) | def test_single_tree_unique_sample_alleles(self, n):
method test_single_tree_sequence_length (line 529) | def test_single_tree_sequence_length(self, L):
method test_single_tree_sequence_length_span_normalise (line 549) | def test_single_tree_sequence_length_span_normalise(self, L):
method test_single_tree_diploid_individuals (line 569) | def test_single_tree_diploid_individuals(self, mode):
method test_single_tree_gap_at_end (line 589) | def test_single_tree_gap_at_end(self, num_windows, mode):
method test_single_tree_subset_permuted_samples (line 615) | def test_single_tree_subset_permuted_samples(self, mode):
method test_single_tree_mixed_non_sample_samples (line 635) | def test_single_tree_mixed_non_sample_samples(self, mode):
method test_single_tree_duplicate_samples (line 648) | def test_single_tree_duplicate_samples(self, mode):
method test_single_tree_multiroot (line 661) | def test_single_tree_multiroot(self, mode):
method test_single_tree_interval (line 683) | def test_single_tree_interval(self, left, right):
method test_single_tree_equal_windows (line 703) | def test_single_tree_equal_windows(self, num_windows):
method test_single_tree_no_sites (line 728) | def test_single_tree_no_sites(self, n):
class TestExamples (line 734) | class TestExamples:
method test_all_trees_interval (line 740) | def test_all_trees_interval(self, interval, mode, span_normalise):
method test_all_trees_windows (line 759) | def test_all_trees_windows(self, windows, mode, span_normalise):
method test_all_trees_windows_gap_at_end (line 769) | def test_all_trees_windows_gap_at_end(self, num_windows, mode, span_no...
method test_small_sims (line 781) | def test_small_sims(self, n, seed, mode):
method test_sims_windows (line 797) | def test_sims_windows(self, n, num_windows, mode):
method test_single_balanced_tree (line 819) | def test_single_balanced_tree(self, n, mode):
method test_internal_sample (line 826) | def test_internal_sample(self, mode):
method test_one_internal_sample_sims (line 838) | def test_one_internal_sample_sims(self, seed, mode):
method test_missing_flanks (line 858) | def test_missing_flanks(self, mode):
method test_dangling_on_samples (line 875) | def test_dangling_on_samples(self, n, mode):
method test_dangling_on_all (line 893) | def test_dangling_on_all(self, n, mode):
method test_disconnected_non_sample_topology (line 910) | def test_disconnected_non_sample_topology(self, mode):
class TestSuiteExamples (line 928) | class TestSuiteExamples:
method check (line 935) | def check(
method test_defaults (line 979) | def test_defaults(self, ts, mode):
method test_subset_samples (line 984) | def test_subset_samples(self, ts, mode):
method test_ploidy_sample_sets (line 991) | def test_ploidy_sample_sets(self, ts, mode, ploidy):
method test_windows (line 1000) | def test_windows(self, ts, mode, span_normalise):
method test_threads_no_windows (line 1006) | def test_threads_no_windows(self, ts, mode):
method test_threads_windows (line 1011) | def test_threads_windows(self, ts, mode):
class TestThreadsNoWindows (line 1016) | class TestThreadsNoWindows:
method check (line 1017) | def check(self, ts, num_threads, samples=None, mode=None, span_normali...
method test_all_trees (line 1032) | def test_all_trees(self, num_threads, mode, span_normalise):
method test_all_trees_samples (line 1039) | def test_all_trees_samples(self, samples, mode):
method test_simple_sims (line 1047) | def test_simple_sims(self, n, num_threads, mode):
class TestThreadsWindows (line 1060) | class TestThreadsWindows:
method check (line 1061) | def check(self, ts, num_threads, *, windows, samples=None, mode=None):
method test_all_trees (line 1083) | def test_all_trees(self, num_threads, windows, mode):
method test_all_trees_samples (line 1099) | def test_all_trees_samples(self, samples, windows, mode):
method test_simple_sims (line 1117) | def test_simple_sims(self, num_threads, windows, mode):
class TestChunkByTree (line 1136) | class TestChunkByTree:
method test_all_trees_ts_26 (line 1149) | def test_all_trees_ts_26(self, num_chunks, expected):
method test_all_trees_ts_4 (line 1165) | def test_all_trees_ts_4(self, num_chunks, expected):
method test_all_trees_ts_4_trees_span (line 1183) | def test_all_trees_ts_4_trees_span(self, span, num_chunks, expected):
method test_empty_ts (line 1194) | def test_empty_ts(self, num_chunks):
method test_single_tree (line 1201) | def test_single_tree(self, num_chunks):
method test_bad_chunks (line 1208) | def test_bad_chunks(self, num_chunks):
class TestChunkWindows (line 1214) | class TestChunkWindows:
method test_examples (line 1227) | def test_examples(self, windows, num_chunks, expected):
method test_bad_chunks (line 1232) | def test_bad_chunks(self, num_chunks):
class TestGroupAlleles (line 1237) | class TestGroupAlleles:
method test_examples (line 1250) | def test_examples(self, G, num_alleles, A, offsets):
method test_simple_simulation (line 1255) | def test_simple_simulation(self):
class TestSampleSetParsing (line 1281) | class TestSampleSetParsing:
method test_good_args (line 1299) | def test_good_args(self, arg, flattened, sizes):
method test_nested_bad_types (line 1318) | def test_nested_bad_types(self, arg):
method test_nested_arrays (line 1330) | def test_nested_arrays(self, arg):
method test_string_args (line 1335) | def test_string_args(self, arg):
method test_dict_args (line 1347) | def test_dict_args(self, arg):
method test_bad_arg_types (line 1361) | def test_bad_arg_types(self, arg):
class TestGeneticRelatednessMatrix (line 1366) | class TestGeneticRelatednessMatrix:
method check (line 1367) | def check(self, ts, mode, *, sample_sets=None, windows=None, span_norm...
method test_single_tree (line 1394) | def test_single_tree(self, mode):
method test_single_tree_mutations_per_branch (line 1406) | def test_single_tree_mutations_per_branch(self, m):
method test_single_tree_sample_sets (line 1430) | def test_single_tree_sample_sets(self, mode):
method test_single_tree_single_samples (line 1442) | def test_single_tree_single_samples(self, mode):
method test_single_tree_windows (line 1456) | def test_single_tree_windows(self, mode):
method test_suite_defaults (line 1469) | def test_suite_defaults(self, ts, mode):
method test_suite_span_normalise (line 1475) | def test_suite_span_normalise(self, ts, mode, span_normalise):
method test_suite_sample_sets (line 1481) | def test_suite_sample_sets(self, ts, mode, num_sets):
FILE: python/tests/test_drawing.py
class TestTreeDraw (line 50) | class TestTreeDraw:
method get_binary_tree (line 56) | def get_binary_tree(self):
method get_nonbinary_ts (line 60) | def get_nonbinary_ts(self):
method get_nonbinary_tree (line 73) | def get_nonbinary_tree(self):
method get_zero_edge_tree (line 80) | def get_zero_edge_tree(self):
method get_zero_roots_tree (line 90) | def get_zero_roots_tree(self):
method get_multiroot_tree (line 102) | def get_multiroot_tree(self):
method get_mutations_over_roots_tree (line 120) | def get_mutations_over_roots_tree(self):
method get_unary_node_tree (line 135) | def get_unary_node_tree(self):
method get_empty_tree (line 154) | def get_empty_tree(self):
method get_simple_ts (line 159) | def get_simple_ts(self, use_mutation_times=False):
method get_ts_varying_min_times (line 227) | def get_ts_varying_min_times(self, *args, **kwargs):
method fail (line 249) | def fail(self, *args, **kwargs):
function closest_left_node (line 256) | def closest_left_node(tree, u):
function get_left_neighbour (line 267) | def get_left_neighbour(tree, traversal_order):
class TestClosestLeftNode (line 292) | class TestClosestLeftNode(TestTreeDraw):
method verify (line 297) | def verify(self, tree):
method test_2_binary (line 308) | def test_2_binary(self):
method test_5_binary (line 312) | def test_5_binary(self):
method test_10_binary (line 316) | def test_10_binary(self):
method test_20_binary (line 320) | def test_20_binary(self):
method test_nonbinary (line 324) | def test_nonbinary(self):
method test_zero_edge (line 327) | def test_zero_edge(self):
method test_zero_roots (line 330) | def test_zero_roots(self):
method test_multiroot (line 333) | def test_multiroot(self):
method test_left_child (line 336) | def test_left_child(self):
method test_null_node_left_child (line 343) | def test_null_node_left_child(self):
method test_leaf_node_left_child (line 349) | def test_leaf_node_left_child(self):
class TestOrder (line 357) | class TestOrder(TestTreeDraw):
method test_bad_order (line 362) | def test_bad_order(self):
method test_default_order (line 367) | def test_default_order(self):
method test_order_mapping (line 371) | def test_order_mapping(self):
method test_tree_svg_variants (line 375) | def test_tree_svg_variants(self):
method test_tree_text_variants (line 389) | def test_tree_text_variants(self):
method test_tree_sequence_text_variants (line 403) | def test_tree_sequence_text_variants(self):
method test_tree_sequence_svg_variants (line 414) | def test_tree_sequence_svg_variants(self):
class TestFormats (line 426) | class TestFormats(TestTreeDraw):
method test_svg_variants (line 431) | def test_svg_variants(self):
method test_default (line 438) | def test_default(self):
method test_ascii_variants (line 448) | def test_ascii_variants(self):
method test_unicode_variants (line 457) | def test_unicode_variants(self):
method test_bad_formats (line 466) | def test_bad_formats(self):
class TestDrawText (line 473) | class TestDrawText(TestTreeDraw):
method verify_basic_text (line 481) | def verify_basic_text(self, text):
method test_draw_defaults (line 485) | def test_draw_defaults(self):
method test_draw_nonbinary (line 490) | def test_draw_nonbinary(self):
method test_draw_multiroot (line 495) | def test_draw_multiroot(self):
method test_draw_mutations_over_roots (line 500) | def test_draw_mutations_over_roots(self):
method test_draw_unary (line 505) | def test_draw_unary(self):
method test_draw_empty_tree (line 510) | def test_draw_empty_tree(self):
method test_draw_zero_roots_tree (line 515) | def test_draw_zero_roots_tree(self):
method test_draw_zero_edge_tree (line 520) | def test_draw_zero_edge_tree(self):
method test_even_num_children_tree (line 525) | def test_even_num_children_tree(self):
method test_odd_num_children_tree (line 554) | def test_odd_num_children_tree(self):
method test_node_labels (line 581) | def test_node_labels(self):
method test_long_internal_labels (line 591) | def test_long_internal_labels(self):
method test_no_node_labels (line 597) | def test_no_node_labels(self):
method test_unused_args (line 605) | def test_unused_args(self):
class TestDrawUnicode (line 633) | class TestDrawUnicode(TestDrawText):
class TestDrawTextErrors (line 642) | class TestDrawTextErrors:
method test_bad_orientation (line 647) | def test_bad_orientation(self):
class TestDrawTextExamples (line 654) | class TestDrawTextExamples(TestTreeDraw):
method verify_text_rendering (line 659) | def verify_text_rendering(self, drawn, drawn_tree, debug=False):
method test_simple_tree (line 672) | def test_simple_tree(self):
method test_simple_tree_long_label (line 731) | def test_simple_tree_long_label(self):
method test_four_leaves (line 795) | def test_four_leaves(self):
method test_trident_tree (line 936) | def test_trident_tree(self):
method test_pitchfork_tree (line 991) | def test_pitchfork_tree(self):
method test_stick_tree (line 1076) | def test_stick_tree(self):
method test_draw_forky_tree (line 1127) | def test_draw_forky_tree(self):
method test_draw_multiroot_forky_tree (line 1219) | def test_draw_multiroot_forky_tree(self):
method test_simple_tree_sequence (line 1290) | def test_simple_tree_sequence(self):
method test_tree_sequence_non_minlex (line 1366) | def test_tree_sequence_non_minlex(self):
method test_max_time (line 1435) | def test_max_time(self):
method test_no_repr_svg (line 1472) | def test_no_repr_svg(self):
class TestDrawSvgBase (line 1479) | class TestDrawSvgBase(TestTreeDraw, xmlunittest.XmlTestMixin):
method verify_basic_svg (line 1484) | def verify_basic_svg(self, svg, width=200, height=200, num_trees=1, ha...
class TestDrawSvg (line 1527) | class TestDrawSvg(TestDrawSvgBase):
method test_repr_svg (line 1532) | def test_repr_svg(self):
method test_draw_to_file (line 1541) | def test_draw_to_file(self, tmp_path):
method test_nonimplemented_base_class (line 1569) | def test_nonimplemented_base_class(self):
method test_bad_tick_spacing (line 1578) | def test_bad_tick_spacing(self):
method test_no_mixed_yscales (line 1587) | def test_no_mixed_yscales(self):
method test_draw_defaults (line 1592) | def test_draw_defaults(self):
method test_draw_svg_y_axis_parameter_combos (line 1610) | def test_draw_svg_y_axis_parameter_combos(
method test_draw_multiroot (line 1632) | def test_draw_multiroot(self):
method test_draw_mutations_over_roots (line 1639) | def test_draw_mutations_over_roots(self):
method test_draw_unary (line 1648) | def test_draw_unary(self):
method test_draw_empty (line 1655) | def test_draw_empty(self):
method test_draw_zero_roots (line 1662) | def test_draw_zero_roots(self):
method test_draw_zero_edge (line 1669) | def test_draw_zero_edge(self):
method test_mutations_present (line 1676) | def test_mutations_present(self):
method test_sites_omitted (line 1690) | def test_sites_omitted(self):
method test_width_height (line 1704) | def test_width_height(self):
method test_node_labels (line 1713) | def test_node_labels(self):
method test_one_node_label (line 1723) | def test_one_node_label(self):
method test_no_node_labels (line 1733) | def test_no_node_labels(self):
method test_one_node_colour (line 1740) | def test_one_node_colour(self):
method test_all_nodes_colour (line 1751) | def test_all_nodes_colour(self):
method test_unplotted_node (line 1765) | def test_unplotted_node(self):
method test_one_edge_colour (line 1773) | def test_one_edge_colour(self):
method test_one_mutation_label_colour (line 1784) | def test_one_mutation_label_colour(self):
method test_bad_y_axis (line 1791) | def test_bad_y_axis(self):
method test_bad_time_scale (line 1797) | def test_bad_time_scale(self):
method test_bad_max_time (line 1806) | def test_bad_max_time(self):
method test_bad_min_time (line 1815) | def test_bad_min_time(self):
method test_bad_neg_log_time (line 1824) | def test_bad_neg_log_time(self):
method test_time_scale_time_and_max_time (line 1831) | def test_time_scale_time_and_max_time(self):
method test_time_scale_rank_and_max_time (line 1849) | def test_time_scale_rank_and_max_time(self):
method test_min_tree_time (line 1865) | def test_min_tree_time(self):
method test_min_ts_time (line 1878) | def test_min_ts_time(self):
method test_numeric_max_time_with_mutations_over_roots (line 1889) | def test_numeric_max_time_with_mutations_over_roots(self):
method test_all_edges_colour (line 1919) | def test_all_edges_colour(self):
method test_unplotted_edge (line 1927) | def test_unplotted_edge(self):
method test_mutations_unknown_time (line 1936) | def test_mutations_unknown_time(self):
method test_mutation_labels (line 1946) | def test_mutation_labels(self):
method test_one_mutation_label (line 1953) | def test_one_mutation_label(self):
method test_no_mutation_labels (line 1960) | def test_no_mutation_labels(self):
method test_one_mutation_colour (line 1967) | def test_one_mutation_colour(self):
method test_all_mutations_colour (line 1975) | def test_all_mutations_colour(self):
method test_unplotted_mutation (line 1983) | def test_unplotted_mutation(self):
method test_extra_mutations (line 1994) | def test_extra_mutations(self, all_muts, x_axis):
method test_max_time (line 2019) | def test_max_time(self):
method test_min_time (line 2070) | def test_min_time(self):
method test_draw_sized_tree (line 2106) | def test_draw_sized_tree(self):
method test_canvas_size_tree (line 2111) | def test_canvas_size_tree(self):
method test_draw_bad_sized_treebox (line 2123) | def test_draw_bad_sized_treebox(self):
method test_draw_bad_sized_tree (line 2129) | def test_draw_bad_sized_tree(self):
method test_draw_simple_ts (line 2135) | def test_draw_simple_ts(self):
method test_draw_integer_breaks_ts (line 2140) | def test_draw_integer_breaks_ts(self):
method test_draw_integer_times_ts (line 2152) | def test_draw_integer_times_ts(self):
method test_draw_integer_times_tree (line 2163) | def test_draw_integer_times_tree(self):
method test_draw_even_height_ts (line 2174) | def test_draw_even_height_ts(self):
method test_draw_sized_ts (line 2182) | def test_draw_sized_ts(self):
method test_canvas_size_ts (line 2187) | def test_canvas_size_ts(self):
method test_time_scale (line 2199) | def test_time_scale(self):
method test_x_scale (line 2219) | def test_x_scale(self):
method test_bad_x_scale (line 2226) | def test_bad_x_scale(self):
method test_x_axis (line 2232) | def test_x_axis(self):
method test_y_axis (line 2241) | def test_y_axis(self):
method test_y_axis_noticks (line 2268) | def test_y_axis_noticks(self):
method test_y_axis_tick_warning (line 2277) | def test_y_axis_tick_warning(self, caplog):
method test_symbol_size (line 2296) | def test_symbol_size(self):
method test_no_edges_invalid (line 2310) | def test_no_edges_invalid(self):
method test_no_edges_show_empty (line 2322) | def test_no_edges_show_empty(self):
method test_no_edges_with_muts (line 2339) | def test_no_edges_with_muts(self):
method test_empty_flanks (line 2355) | def test_empty_flanks(self):
method test_bad_xlim (line 2370) | def test_bad_xlim(self):
method test_xlim_on_empty (line 2385) | def test_xlim_on_empty(self):
method test_xlim_edge_cases (line 2394) | def test_xlim_edge_cases(self):
method test_xlim_maintains_tree_ids (line 2417) | def test_xlim_maintains_tree_ids(self):
method test_xlim_maintains_site_and_mutation_ids (line 2427) | def test_xlim_maintains_site_and_mutation_ids(self):
method test_xlim_with_ranks (line 2455) | def test_xlim_with_ranks(self):
method test_half_truncated (line 2463) | def test_half_truncated(self):
method test_tree_root_branch (line 2471) | def test_tree_root_branch(self):
method test_debug_box (line 2496) | def test_debug_box(self):
method test_bad_max_num_trees (line 2508) | def test_bad_max_num_trees(self, max_trees):
method test_max_num_trees (line 2514) | def test_max_num_trees(self, max_trees):
method test_edge_ids (line 2538) | def test_edge_ids(self):
method test_draw_tree_symbol_titles (line 2548) | def test_draw_tree_symbol_titles(self):
method test_nodraw_x_axis (line 2561) | def test_nodraw_x_axis(self):
method test_x_regions_ts (line 2568) | def test_x_regions_ts(self):
method test_x_regions_tree (line 2586) | def test_x_regions_tree(self):
method test_unsupported_x_regions (line 2595) | def test_unsupported_x_regions(self):
method test_bad_x_regions (line 2603) | def test_bad_x_regions(self):
method test_title (line 2614) | def test_title(self):
method test_bad_ts_order (line 2621) | def test_bad_ts_order(self):
method test_good_tree_order (line 2626) | def test_good_tree_order(self):
method test_nonpostorder_tree_order (line 2630) | def test_nonpostorder_tree_order(self):
method test_only_subset_nodes_in_rank (line 2635) | def test_only_subset_nodes_in_rank(self, caplog):
method test_polytomy_collapsing (line 2656) | def test_polytomy_collapsing(self):
method test_preamble (line 2671) | def test_preamble(self, tree_or_ts):
method test_non_svg_preamble (line 2686) | def test_non_svg_preamble(self, tree_or_ts):
class TestDrawKnownSvg (line 2694) | class TestDrawKnownSvg(TestDrawSvgBase):
method verify_known_svg (line 2699) | def verify_known_svg(self, svg, filename, save=False, **kwargs):
method test_known_svg_tree_no_mut (line 2712) | def test_known_svg_tree_no_mut(self, overwrite_viz, draw_plotbox):
method test_known_svg_tree_x_axis (line 2725) | def test_known_svg_tree_x_axis(self, overwrite_viz, draw_plotbox):
method test_known_svg_tree_y_axis_rank (line 2740) | def test_known_svg_tree_y_axis_rank(self, overwrite_viz, draw_plotbox):
method test_known_svg_tree_both_axes (line 2761) | def test_known_svg_tree_both_axes(self, overwrite_viz, draw_plotbox):
method test_known_svg_tree_root_mut (line 2771) | def test_known_svg_tree_root_mut(self, overwrite_viz, draw_plotbox):
method test_known_svg_tree_mut_all_edge (line 2776) | def test_known_svg_tree_mut_all_edge(self, overwrite_viz, draw_plotbox):
method test_known_svg_tree_timed_root_mut (line 2790) | def test_known_svg_tree_timed_root_mut(self, overwrite_viz, draw_plotb...
method test_known_svg_ts (line 2796) | def test_known_svg_ts(self, overwrite_viz, draw_plotbox):
method test_known_svg_ts_title (line 2807) | def test_known_svg_ts_title(self, overwrite_viz, draw_plotbox):
method test_known_svg_ts_no_axes (line 2814) | def test_known_svg_ts_no_axes(self, overwrite_viz, draw_plotbox):
method test_known_svg_ts_internal_sample (line 2827) | def test_known_svg_ts_internal_sample(self, overwrite_viz, draw_plotbox):
method test_known_svg_ts_highlighted_mut (line 2838) | def test_known_svg_ts_highlighted_mut(self, overwrite_viz, draw_plotbox):
method test_known_svg_ts_rank (line 2852) | def test_known_svg_ts_rank(self, overwrite_viz, draw_plotbox):
method test_known_svg_nonbinary_ts (line 2865) | def test_known_svg_nonbinary_ts(self, overwrite_viz, draw_plotbox):
method test_known_svg_ts_plain (line 2874) | def test_known_svg_ts_plain(self, overwrite_viz, draw_plotbox):
method test_known_svg_ts_plain_no_xlab (line 2886) | def test_known_svg_ts_plain_no_xlab(self, overwrite_viz, draw_plotbox):
method test_known_svg_ts_plain_y (line 2897) | def test_known_svg_ts_plain_y(self, overwrite_viz, draw_plotbox):
method test_known_svg_ts_with_xlabel (line 2915) | def test_known_svg_ts_with_xlabel(self, overwrite_viz, draw_plotbox):
method test_known_svg_ts_y_axis (line 2927) | def test_known_svg_ts_y_axis(self, overwrite_viz, draw_plotbox):
method test_known_svg_ts_y_axis_regular (line 2936) | def test_known_svg_ts_y_axis_regular(self, overwrite_viz, draw_plotbox):
method test_known_svg_ts_y_axis_log (line 2948) | def test_known_svg_ts_y_axis_log(self, overwrite_viz, draw_plotbox):
method test_known_svg_ts_mutation_times (line 2960) | def test_known_svg_ts_mutation_times(self, overwrite_viz, draw_plotbox):
method test_known_svg_ts_titles (line 2970) | def test_known_svg_ts_titles(self, overwrite_viz, draw_plotbox):
method test_known_svg_ts_mutation_times_logscale (line 2988) | def test_known_svg_ts_mutation_times_logscale(self, overwrite_viz, dra...
method test_known_svg_ts_mut_no_edges (line 2997) | def test_known_svg_ts_mut_no_edges(self, overwrite_viz, draw_plotbox):
method test_known_svg_ts_timed_mut_no_edges (line 3013) | def test_known_svg_ts_timed_mut_no_edges(self, overwrite_viz, draw_plo...
method test_known_svg_ts_multiroot (line 3032) | def test_known_svg_ts_multiroot(self, overwrite_viz, draw_plotbox):
method test_known_svg_ts_xlim (line 3054) | def test_known_svg_ts_xlim(self, overwrite_viz, draw_plotbox):
method test_known_max_num_trees (line 3061) | def test_known_max_num_trees(self, overwrite_viz, draw_plotbox):
method test_known_max_num_trees_treewise (line 3082) | def test_known_max_num_trees_treewise(self, overwrite_viz, draw_plotbox):
method test_known_svg_tree_collapsed (line 3101) | def test_known_svg_tree_collapsed(self, overwrite_viz, draw_plotbox):
method test_known_svg_tree_subtree (line 3121) | def test_known_svg_tree_subtree(self, overwrite_viz, draw_plotbox):
method test_known_svg_tree_subtrees_with_collapsed (line 3133) | def test_known_svg_tree_subtrees_with_collapsed(self, overwrite_viz, d...
method test_known_svg_tree_polytomy (line 3156) | def test_known_svg_tree_polytomy(self, overwrite_viz, draw_plotbox):
method test_known_svg_tree_polytomy_tracked (line 3167) | def test_known_svg_tree_polytomy_tracked(self, overwrite_viz, draw_plo...
method test_known_svg
Condensed preview — 220 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (7,968K chars).
[
{
"path": ".clang-format",
"chars": 547,
"preview": "Language: Cpp\nBasedOnStyle: GNU\nSortIncludes: false\nAllowShortIfStatementsOnASingleLine: false\nBreakBeforeBraces: Lin"
},
{
"path": ".github/PULL_REQUEST_TEMPLATE.md",
"chars": 582,
"preview": "## Description\n\nThanks for contributing to tskit! :heart:\nA guide to the PR process is [here](https://tskit.dev/tskit/do"
},
{
"path": ".github/workflows/docs.yml",
"chars": 335,
"preview": "name: Build Docs\non:\n pull_request:\n merge_group:\n push:\n branches: [main]\n tags:\n - '*'\n\nenv:\n FORCE_COL"
},
{
"path": ".github/workflows/lint.yml",
"chars": 165,
"preview": "name: Lint\n\non:\n pull_request:\n merge_group:\n\njobs:\n Lint:\n uses: tskit-dev/.github/.github/workflows/lint.yml@v15"
},
{
"path": ".github/workflows/release-c.yml",
"chars": 1132,
"preview": "name: Publish C API release\n\non:\n push:\n branches: [main, test]\n tags: ['*']\n\nenv:\n FORCE_COLOR: 1\n\njobs:\n buil"
},
{
"path": ".github/workflows/tests.yml",
"chars": 5535,
"preview": "name: Tests\n\non:\n pull_request:\n merge_group:\n push:\n branches: [main, test]\n\nenv:\n FORCE_COLOR: 1\n\njobs:\n\n pack"
},
{
"path": ".github/workflows/wheels.yml",
"chars": 1079,
"preview": "name: Publish Python release\n\non:\n push:\n branches: [test-publish]\n release:\n types: [published]\n\njobs:\n build-"
},
{
"path": ".gitignore",
"chars": 116,
"preview": "build-gcc\n.DS_Store\npython/benchmark/*.trees\npython/benchmark/*.json\npython/benchmark/*.html\n.venv\n.env\n.vscode\nenv\n"
},
{
"path": "CONTRIBUTING.md",
"chars": 514,
"preview": "# Contributing\n\nTskit is a free and open-source project that welcomes contributions from everyone.\nThe [Developer docume"
},
{
"path": "LICENSE",
"chars": 1078,
"preview": "MIT License\n\nCopyright (c) 2018-2019 Tskit Developers\n\nPermission is hereby granted, free of charge, to any person obtai"
},
{
"path": "README.md",
"chars": 4087,
"preview": "# tskit <img align=\"right\" width=\"145\" height=\"90\" src=\"https://github.com/tskit-dev/administrative/blob/main/tskit_log"
},
{
"path": "c/.gitignore",
"chars": 20,
"preview": "build\n.*.swp\n.*.swo\n"
},
{
"path": "c/CHANGELOG.rst",
"chars": 25868,
"preview": "--------------------\n[1.3.2] - 2026-XX-XX\n--------------------\n\nIn development\n\n- Add ``tsk_json_struct_metadata_get_blo"
},
{
"path": "c/VERSION.txt",
"chars": 5,
"preview": "1.3.1"
},
{
"path": "c/examples/Makefile",
"chars": 1162,
"preview": "# Simple Makefile for building examples.\n# This will build the examples in the current directory by compiling in the\n# f"
},
{
"path": "c/examples/api_structure.c",
"chars": 826,
"preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <tskit/tables.h>\n\n#define check_tsk_error(val) "
},
{
"path": "c/examples/cpp_sorting_example.cpp",
"chars": 2828,
"preview": "#include <cstddef>\n#include <vector>\n#include <algorithm>\n#include <stdexcept>\n#include <sstream>\n#include <iostream>\n#i"
},
{
"path": "c/examples/error_handling.c",
"chars": 709,
"preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <tskit.h>\n\nint\nmain(int argc, char **argv)\n{\n int ret;\n tsk_treese"
},
{
"path": "c/examples/haploid_wright_fisher.c",
"chars": 3884,
"preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <assert.h>\n#include <err.h>\n\n#include <tskit/tables.h>\n\n#define check_ts"
},
{
"path": "c/examples/json_struct_metadata.c",
"chars": 6388,
"preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <err.h>\n#include <string.h>\n#include <tskit.h>\n\n// these are properties "
},
{
"path": "c/examples/multichrom_wright_fisher.c",
"chars": 8492,
"preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <assert.h>\n#include <err.h>\n#include <string.h>\n\n#include <pthread.h>\n#i"
},
{
"path": "c/examples/multichrom_wright_fisher_singlethreaded.c",
"chars": 4561,
"preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <assert.h>\n#include <err.h>\n#include <string.h>\n\n#include <tskit/tables."
},
{
"path": "c/examples/streaming.c",
"chars": 1183,
"preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <tskit/tables.h>\n\n#define check_tsk_error(val) "
},
{
"path": "c/examples/take_ownership.c",
"chars": 1197,
"preview": "#include <err.h>\n#include <stdlib.h>\n#include <tskit/tables.h>\n#include <tskit/trees.h>\n\n#define check_tsk_error(val) "
},
{
"path": "c/examples/tree_iteration.c",
"chars": 1302,
"preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <err.h>\n\n#include <tskit.h>\n\n#define check_tsk_error(val) "
},
{
"path": "c/examples/tree_traversal.c",
"chars": 3162,
"preview": "#include <stdio.h>\n#include <stdlib.h>\n#include <err.h>\n\n#include <tskit.h>\n\n#define check_tsk_error(val) "
},
{
"path": "c/meson.build",
"chars": 5786,
"preview": "project('tskit', ['c', 'cpp'],\n version: files('VERSION.txt'), \n default_options: ['c_std=c99', 'cpp_std=c++11'"
},
{
"path": "c/meson_options.txt",
"chars": 57,
"preview": "option('build_examples', type : 'boolean', value : true)\n"
},
{
"path": "c/subprojects/kastore/README.md",
"chars": 153,
"preview": "This directory is an abbreviated version of the kastore distribution source.\n\nAll files should be updated when we are up"
},
{
"path": "c/subprojects/kastore/VERSION.txt",
"chars": 6,
"preview": "2.1.2\n"
},
{
"path": "c/subprojects/kastore/kastore.c",
"chars": 33757,
"preview": "#include <stdio.h>\n#include <string.h>\n#include <stdlib.h>\n#include <assert.h>\n#include <errno.h>\n#include <stdbool.h>\n\n"
},
{
"path": "c/subprojects/kastore/kastore.h",
"chars": 21452,
"preview": "/**\n * @file kastore.h\n * @brief Public API for kastore.\n *\n * This is the API documentation for kastore.\n */\n#ifndef KA"
},
{
"path": "c/subprojects/kastore/meson.build",
"chars": 2039,
"preview": "project('kastore', ['c', 'cpp'],\n version: files('VERSION.txt'),\n default_options: [\n 'c_std=c99', \n 'cpp_std=c+"
},
{
"path": "c/tests/meson-subproject/example.c",
"chars": 2473,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2022 Tskit Developers\n *\n * Permission is hereby granted, free of charge, to "
},
{
"path": "c/tests/meson-subproject/meson.build",
"chars": 196,
"preview": "project('example', 'c')\n\ntskit_proj = subproject('tskit')\ntskit_dep = tskit_proj.get_variable('tskit_dep')\n\nexecutable('"
},
{
"path": "c/tests/test_convert.c",
"chars": 4466,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2022 Tskit Developers\n *\n * Permission is hereby granted, free of charge, to "
},
{
"path": "c/tests/test_core.c",
"chars": 22608,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2024 Tskit Developers\n *\n * Permission is hereby granted, free of charge, to "
},
{
"path": "c/tests/test_file_format.c",
"chars": 51799,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2022 Tskit Developers\n *\n * Permission is hereby granted, free of charge, to "
},
{
"path": "c/tests/test_genotypes.c",
"chars": 62287,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2022 Tskit Developers\n *\n * Permission is hereby granted, free of charge, to "
},
{
"path": "c/tests/test_haplotype_matching.c",
"chars": 20426,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2023 Tskit Developers\n *\n * Permission is hereby granted, free of charge, to "
},
{
"path": "c/tests/test_minimal_cpp.cpp",
"chars": 8267,
"preview": "/* * MIT License\n *\n * Copyright (c) 2019-2024 Tskit Developers\n *\n * Permission is hereby granted, free of charge, to a"
},
{
"path": "c/tests/test_stats.c",
"chars": 159068,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2024 Tskit Developers\n *\n * Permission is hereby granted, free of charge, to "
},
{
"path": "c/tests/test_tables.c",
"chars": 508308,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2023 Tskit Developers\n *\n * Permission is hereby granted, free of charge, to "
},
{
"path": "c/tests/test_trees.c",
"chars": 322096,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2024 Tskit Developers\n *\n * Permission is hereby granted, free of charge, to "
},
{
"path": "c/tests/testlib.c",
"chars": 39530,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2024 Tskit Developers\n *\n * Permission is hereby granted, free of charge, to "
},
{
"path": "c/tests/testlib.h",
"chars": 6511,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2024 Tskit Developers\n *\n * Permission is hereby granted, free of charge, to "
},
{
"path": "c/tskit/convert.c",
"chars": 6415,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2018-2025 Tskit Developers\n * Copyright (c) 2015-2017 University of Oxford\n *\n * P"
},
{
"path": "c/tskit/convert.h",
"chars": 1532,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2018-2021 Tskit Developers\n * Copyright (c) 2015-2017 University of Oxford\n *\n * P"
},
{
"path": "c/tskit/core.c",
"chars": 49069,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2025 Tskit Developers\n * Copyright (c) 2015-2018 University of Oxford\n *\n * P"
},
{
"path": "c/tskit/core.h",
"chars": 36754,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2025 Tskit Developers\n * Copyright (c) 2015-2018 University of Oxford\n *\n * P"
},
{
"path": "c/tskit/genotypes.c",
"chars": 29529,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2025 Tskit Developers\n * Copyright (c) 2016-2018 University of Oxford\n *\n * P"
},
{
"path": "c/tskit/genotypes.h",
"chars": 7275,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2022 Tskit Developers\n * Copyright (c) 2016-2018 University of Oxford\n *\n * P"
},
{
"path": "c/tskit/haplotype_matching.c",
"chars": 59738,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2025 Tskit Developers\n *\n * Permission is hereby granted, free of charge, to "
},
{
"path": "c/tskit/haplotype_matching.h",
"chars": 6134,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2024 Tskit Developers\n *\n * Permission is hereby granted, free of charge, to "
},
{
"path": "c/tskit/stats.c",
"chars": 8265,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2018-2025 Tskit Developers\n * Copyright (c) 2016-2017 University of Oxford\n *\n * P"
},
{
"path": "c/tskit/stats.h",
"chars": 2084,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2021 Tskit Developers\n * Copyright (c) 2016-2017 University of Oxford\n *\n * P"
},
{
"path": "c/tskit/tables.c",
"chars": 437888,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2025 Tskit Developers\n * Copyright (c) 2017-2018 University of Oxford\n *\n * P"
},
{
"path": "c/tskit/tables.h",
"chars": 187603,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2024 Tskit Developers\n * Copyright (c) 2017-2018 University of Oxford\n *\n * P"
},
{
"path": "c/tskit/trees.c",
"chars": 361426,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2025 Tskit Developers\n * Copyright (c) 2015-2018 University of Oxford\n *\n * P"
},
{
"path": "c/tskit/trees.h",
"chars": 73304,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2024 Tskit Developers\n * Copyright (c) 2015-2018 University of Oxford\n *\n * P"
},
{
"path": "c/tskit.h",
"chars": 1408,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2024 Tskit Developers\n *\n * Permission is hereby granted, free of charge, to "
},
{
"path": "codecov.yml",
"chars": 571,
"preview": "ignore:\n - \"c/tests/\"\n - \"c/subprojects/**/*\"\n\ncodecov:\n require_ci_to_pass: false\n\ncomment:\n layout: \"header, diff,"
},
{
"path": "docs/.gitignore",
"chars": 19,
"preview": "_build\ndoxygen/xml\n"
},
{
"path": "docs/Makefile",
"chars": 178,
"preview": "BUILDDIR = _build\nDOXYGEN_XML = doxygen/xml\n\nall: ${DOXYGEN_XML}\n\t./build.sh\n\n${DOXYGEN_XML}: ../c/tskit/*.h\n\tcd doxy"
},
{
"path": "docs/_config.yml",
"chars": 3840,
"preview": "# Book settings\n# Learn more at https://jupyterbook.org/customize/config.html\n\ntitle: Tskit manual\nauthor: Tskit Develop"
},
{
"path": "docs/_static/README",
"chars": 36,
"preview": "Placeholder file to keep git happy.\n"
},
{
"path": "docs/_static/bespoke.css",
"chars": 224,
"preview": "/* When a code cell outputs tskit tables in plain text, widen the tab size so column\n contents line up. Invoke this by"
},
{
"path": "docs/_toc.yml",
"chars": 609,
"preview": "format: jb-book\nroot: introduction\nparts:\n- caption: Getting started\n chapters:\n - file: installation\n - file: quicks"
},
{
"path": "docs/build.sh",
"chars": 546,
"preview": "#/bin/bash\n\n# Jupyter-build doesn't have an option to automatically show the \n# saved reports, which makes it difficult "
},
{
"path": "docs/c-api.rst",
"chars": 31742,
"preview": ".. _sec_c_api:\n\n=====\nC API\n=====\n\nThis is the documentation for the ``tskit`` C API, a low-level library\nfor manipulati"
},
{
"path": "docs/changelogs.rst",
"chars": 232,
"preview": ".. note: this is left in rst format to avoid Duplicate ID issues\n\n.. _sec_changelogs:\n\n==========\nChangelogs\n==========\n"
},
{
"path": "docs/citation.md",
"chars": 2391,
"preview": "(sec_citation)=\n\n# Citing tskit\n\nIf you use `tskit` in your work, we recommend citing the [2024 ARG Genetics paper](<htt"
},
{
"path": "docs/cli.md",
"chars": 386,
"preview": "---\njupytext:\n text_representation:\n extension: .md\n format_name: myst\n format_version: 0.12\n jupytext_vers"
},
{
"path": "docs/data-model.md",
"chars": 51687,
"preview": "---\njupytext:\n text_representation:\n extension: .md\n format_name: myst\n format_version: 0.12\n jupytext_vers"
},
{
"path": "docs/development.md",
"chars": 43565,
"preview": "---\njupytext:\n text_representation:\n extension: .md\n format_name: myst\n format_version: 0.12\n jupytext_vers"
},
{
"path": "docs/doxygen/Doxyfile",
"chars": 115019,
"preview": "# Doxyfile 1.9.1\n\n# This file describes the settings to be used by the documentation system\n# doxygen (www.doxygen.org) "
},
{
"path": "docs/export.md",
"chars": 15494,
"preview": "---\njupytext:\n text_representation:\n extension: .md\n format_name: myst\n format_version: 0.12\n jupytext_vers"
},
{
"path": "docs/file-formats.md",
"chars": 9097,
"preview": "---\njupytext:\n text_representation:\n extension: .md\n format_name: myst\n format_version: 0.12\n jupytext_vers"
},
{
"path": "docs/glossary.md",
"chars": 7862,
"preview": "---\njupytext:\n text_representation:\n extension: .md\n format_name: myst\n format_version: 0.12\n jupytext_vers"
},
{
"path": "docs/ibd.md",
"chars": 12056,
"preview": "---\njupytext:\n text_representation:\n extension: .md\n format_name: myst\n format_version: 0.12\n jupytext_vers"
},
{
"path": "docs/installation.md",
"chars": 2518,
"preview": "---\njupytext:\n text_representation:\n extension: .md\n format_name: myst\n format_version: 0.12\n jupytext_vers"
},
{
"path": "docs/introduction.md",
"chars": 1772,
"preview": "---\njupytext:\n text_representation:\n extension: .md\n format_name: myst\n format_version: 0.12\n jupytext_vers"
},
{
"path": "docs/metadata.md",
"chars": 29969,
"preview": "---\njupytext:\n text_representation:\n extension: .md\n format_name: myst\n format_version: 0.12\n jupytext_vers"
},
{
"path": "docs/numba.md",
"chars": 21354,
"preview": "---\njupytext:\n text_representation:\n extension: .md\n format_name: myst\n format_version: 0.12\n jupytext_vers"
},
{
"path": "docs/provenance.md",
"chars": 7588,
"preview": "---\njupytext:\n text_representation:\n extension: .md\n format_name: myst\n format_version: 0.12\n jupytext_vers"
},
{
"path": "docs/python-api.md",
"chars": 39338,
"preview": "---\njupytext:\n text_representation:\n extension: .md\n format_name: myst\n format_version: 0.12\n jupytext_vers"
},
{
"path": "docs/quickstart.md",
"chars": 3578,
"preview": "---\njupytext:\n text_representation:\n extension: .md\n format_name: myst\n format_version: 0.12\n jupytext_vers"
},
{
"path": "docs/stats.md",
"chars": 52574,
"preview": "---\njupytext:\n text_representation:\n extension: .md\n format_name: myst\n format_version: 0.12\n jupytext_vers"
},
{
"path": "docs/substitutions/linear_traversal_warning.rst",
"chars": 240,
"preview": ".. warning:: The current implementation of this operation is linear in the number of\n trees, so may be inefficient fo"
},
{
"path": "docs/substitutions/table_edit_warning.rst",
"chars": 325,
"preview": ".. warning:: The numpy arrays returned by table attribute accesses are copies\n of the underlying data. In particular,"
},
{
"path": "docs/substitutions/table_keep_rows_main.rst",
"chars": 627,
"preview": "Updates this table in-place according to the specified boolean\narray, and returns the resulting mapping from old to new "
},
{
"path": "docs/substitutions/tree_array_warning.rst",
"chars": 452,
"preview": ".. warning:: This is a high-performance interface which\n provides zero-copy access to memory used in the C library.\n "
},
{
"path": "docs/substitutions/virtual_root_array_note.rst",
"chars": 281,
"preview": ".. note:: The length of these arrays is\n equal to the number of nodes in the tree sequence plus 1, with the\n final"
},
{
"path": "docs/topological-analysis.md",
"chars": 12269,
"preview": "---\njupytext:\n text_representation:\n extension: .md\n format_name: myst\n format_version: 0.12\n jupytext_vers"
},
{
"path": "prek.toml",
"chars": 1248,
"preview": "# The prek configuration defining linting requirements. This\n# setup is optimised for long-term stability and determinis"
},
{
"path": "python/.gitignore",
"chars": 63,
"preview": "*.pyc\n*.so\n*.egg-info\nbuild\n.*.swp\n.*.swo\n*/.ipynb_checkpoints\n"
},
{
"path": "python/CHANGELOG.rst",
"chars": 62997,
"preview": "--------------------\n[1.0.3] - 2026-XX-XX\n--------------------\n\nIn development\n\n- Add ``json+struct`` metadata codec tha"
},
{
"path": "python/MANIFEST.in",
"chars": 207,
"preview": "include LICENSE\ninclude lwt_interface/tskit_lwt_interface.h\ninclude lib/subprojects/kastore/kastore.h\ninclude lib/tskit."
},
{
"path": "python/Makefile",
"chars": 332,
"preview": "all: ext3\n\nallchecks: _tskitmodule.c\n\tCFLAGS=\"-std=c99 --coverage -Wall -Wextra -Werror -Wno-unused-parameter -Wno-cast-"
},
{
"path": "python/README.rst",
"chars": 370,
"preview": "\nThe tree sequence toolkit.\n\nTskit is a cross-platform library for the storage and analysis of large-scale\ngenetic genea"
},
{
"path": "python/_tskitmodule.c",
"chars": 402284,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2025 Tskit Developers\n * Copyright (c) 2015-2018 University of Oxford\n *\n * P"
},
{
"path": "python/benchmark/config.yaml",
"chars": 5110,
"preview": "setup: |\n import tskit\n\nbenchmarks:\n - code: ts = tskit.load(\"{filename}\")\n parameters:\n filename: &files\n "
},
{
"path": "python/benchmark/run-for-all-releases.py",
"chars": 973,
"preview": "import json\nimport subprocess\nfrom distutils.version import StrictVersion\nfrom urllib.request import urlopen\n\nimport tqd"
},
{
"path": "python/benchmark/run.py",
"chars": 8389,
"preview": "import json\nimport os.path\nimport platform\nimport sys\nimport timeit\nfrom pathlib import Path\n\nimport click\nimport psutil"
},
{
"path": "python/lwt_interface/CHANGELOG.rst",
"chars": 813,
"preview": "--------------------\n[0.1.4] - 2021-09-02\n--------------------\n\n- Offset columns are now 64 bit in tskit. For compatibil"
},
{
"path": "python/lwt_interface/Makefile",
"chars": 333,
"preview": "\nall: cmodule\n\nallchecks: example_c_module.c\n\tCFLAGS=\"-std=c99 --coverage -Wall -Wextra -Werror -Wno-unused-parameter -W"
},
{
"path": "python/lwt_interface/README.md",
"chars": 2332,
"preview": "# LightweightTableCollection interface\n\nThe files in this directory define the LightweightTableCollection\ninterface used"
},
{
"path": "python/lwt_interface/cython_example/Makefile",
"chars": 280,
"preview": "all: compile run\n\ncompile:\n\tuv run --project=../../ --group=test-lwt setup.py build_ext --inplace\n\nrun:\n\tuv run --projec"
},
{
"path": "python/lwt_interface/cython_example/_lwtc.c",
"chars": 2098,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2020 Tskit Developers\n * Copyright (c) 2015-2018 University of Oxford\n *\n * P"
},
{
"path": "python/lwt_interface/cython_example/example.pyx",
"chars": 2202,
"preview": "from libc.stdint cimport uint32_t\nimport _lwtc\nimport tskit\n\ncdef extern from \"tskit.h\" nogil:\n ctypedef uint32_t tsk"
},
{
"path": "python/lwt_interface/cython_example/pyproject.toml",
"chars": 321,
"preview": "[build-system]\nrequires = [\"setuptools>=64\", \"wheel\", \"Cython\", \"numpy\"]\nbuild-backend = \"setuptools.build_meta\"\n\n[proje"
},
{
"path": "python/lwt_interface/cython_example/setup.py",
"chars": 1054,
"preview": "import glob\nimport os\n\nimport numpy as np\nfrom Cython.Build import cythonize\nfrom setuptools import setup\nfrom setuptool"
},
{
"path": "python/lwt_interface/dict_encoding_testlib.py",
"chars": 29398,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2024 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/lwt_interface/example_c_module.c",
"chars": 4826,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2020 Tskit Developers\n * Copyright (c) 2015-2018 University of Oxford\n *\n * P"
},
{
"path": "python/lwt_interface/setup.py",
"chars": 1730,
"preview": "import os.path\nimport platform\n\nfrom setuptools import Extension, setup\nfrom setuptools.command.build_ext import build_e"
},
{
"path": "python/lwt_interface/test_example_c_module.py",
"chars": 2075,
"preview": "# flake8: noqa\nimport os\nimport sys\n\nimport pytest\n\n# Make sure we use the local tskit version.\n\nsys.path.insert(0, os.p"
},
{
"path": "python/lwt_interface/tskit_lwt_interface.h",
"chars": 68785,
"preview": "/*\n * MIT License\n *\n * Copyright (c) 2019-2021 Tskit Developers\n * Copyright (c) 2015-2018 University of Oxford\n *\n * P"
},
{
"path": "python/pyproject.toml",
"chars": 4433,
"preview": "[build-system]\nrequires = [\"setuptools>=45\", \"wheel\", \"numpy>=2.0\"]\nbuild-backend = \"setuptools.build_meta\"\n\n[project]\nn"
},
{
"path": "python/setup.py",
"chars": 889,
"preview": "import os\nimport platform\n\nimport numpy\nfrom setuptools import Extension, setup\n\nIS_WINDOWS = platform.system() == \"Wind"
},
{
"path": "python/stress_lowlevel.py",
"chars": 3083,
"preview": "import curses\nimport os\nimport random\nimport resource\nimport sys\nimport time\nimport tracemalloc\nfrom contextlib import r"
},
{
"path": "python/tests/__init__.py",
"chars": 12227,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2023 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tests/conftest.py",
"chars": 4529,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2022 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tests/data/SLiM/README",
"chars": 51,
"preview": "The files in this directory are generated by SLiM.\n"
},
{
"path": "python/tests/data/SLiM/minimal-example.txt",
"chars": 388,
"preview": "initialize() {\n initializeTreeSeq(); \n initializeMutationRate(0.0);\n initializeMutationType(\"m1\", 0.5, \"f\", -0."
},
{
"path": "python/tests/data/SLiM/single-locus-example.txt",
"chars": 390,
"preview": "initialize() {\n initializeTreeSeq(); \n initializeMutationRate(0.0);\n initializeMutationType(\"m1\", 0.5, \"f\", -0."
},
{
"path": "python/tests/data/dict-encodings/generate_msprime.py",
"chars": 565,
"preview": "import pathlib\nimport pickle\n\nimport _msprime\nimport msprime\n\npop_configs = [msprime.PopulationConfiguration(5) for _ in"
},
{
"path": "python/tests/data/simplify-bugs/01-edges.txt",
"chars": 632,
"preview": "left right parent child\n0.000000\t4.000000\t5\t2,3\t\n4.000000\t9.000000\t5\t3\t\n22.000000\t28.000000\t5\t3\t\n0.000000\t18.00000"
},
{
"path": "python/tests/data/simplify-bugs/01-mutations.txt",
"chars": 24,
"preview": "site\tnode\tderived_state\n"
},
{
"path": "python/tests/data/simplify-bugs/01-nodes.txt",
"chars": 209,
"preview": "is_sample\ttime\n1\t0.000000\n1\t0.000000\n1\t0.000000\n1\t0.000000\n1\t0.000000\n0\t5.000000\n0\t6.000000\n0\t7.000000\n0\t8.000000\n0\t9.00"
},
{
"path": "python/tests/data/simplify-bugs/01-sites.txt",
"chars": 25,
"preview": "position\tancestral_state\n"
},
{
"path": "python/tests/data/simplify-bugs/02-edges.txt",
"chars": 34054,
"preview": "left\tright\tparent\tchild\n63.824647\t100.000000\t100\t47,85\n41.913156\t100.000000\t101\t81,83\n0.000000\t100.000000\t102\t88,98\n0.00"
},
{
"path": "python/tests/data/simplify-bugs/02-mutations.txt",
"chars": 24,
"preview": "site\tnode\tderived_state\n"
},
{
"path": "python/tests/data/simplify-bugs/02-nodes.txt",
"chars": 2402,
"preview": "is_sample\ttime\n1\t0.000000\n1\t0.000000\n1\t0.000000\n1\t0.000000\n1\t0.000000\n1\t0.000000\n1\t0.000000\n1\t0.000000\n1\t0.000000\n1\t0.00"
},
{
"path": "python/tests/data/simplify-bugs/02-sites.txt",
"chars": 25,
"preview": "position\tancestral_state\n"
},
{
"path": "python/tests/data/simplify-bugs/03-edges.txt",
"chars": 594,
"preview": "left\tright\tparent\tchild\n0.000000\t10000.000000\t50\t29,31\n0.000000\t10000.000000\t51\t11,15\n0.000000\t1554.123401\t52\t1,51\n1554."
},
{
"path": "python/tests/data/simplify-bugs/03-mutations.txt",
"chars": 112,
"preview": "site\tnode\tderived_state\n0\t52\t1\n1\t34\t1\n2\t57\t1\n2\t3\t1\n3\t58\t1\n4\t34\t1\n5\t56\t1\n6\t55\t1\n6\t1\t1\n7\t51\t1\n8\t43\t1\n9\t54\t1\n9\t0\t1\n"
},
{
"path": "python/tests/data/simplify-bugs/03-nodes.txt",
"chars": 952,
"preview": "is_sample\ttime\tpopulation\n1\t0.000000\t-1\t\n1\t0.000000\t-1\t\n1\t0.000000\t-1\t\n1\t0.000000\t-1\t\n1\t0.000000\t-1\t\n1\t0.000000\t-1\t\n1\t0."
},
{
"path": "python/tests/data/simplify-bugs/03-sites.txt",
"chars": 164,
"preview": "position\tancestral_state\n284.252209\t0\n1313.686815\t0\n1554.123401\t0\n1736.203571\t0\n3310.290546\t0\n4208.672558\t0\n4995.288904\t"
},
{
"path": "python/tests/data/simplify-bugs/04-edges.txt",
"chars": 349,
"preview": "left\tright\tparent\tchild\n0.000000\t0.500000\t6\t0,1\n0.500000\t1.000000\t6\t4,5\n0.000000\t0.400000\t7\t2,3\n0.000000\t0.500000\t8\t4,5\n"
},
{
"path": "python/tests/data/simplify-bugs/04-mutations.txt",
"chars": 24,
"preview": "site\tnode\tderived_state\n"
},
{
"path": "python/tests/data/simplify-bugs/04-nodes.txt",
"chars": 266,
"preview": "is_sample\ttime\tpopulation\n1\t0.000000\t-1\t\n1\t0.000000\t-1\t\n1\t0.000000\t-1\t\n1\t0.000000\t-1\t\n1\t0.000000\t-1\t\n1\t0.000000\t-1\t\n0\t1."
},
{
"path": "python/tests/data/simplify-bugs/04-sites.txt",
"chars": 25,
"preview": "position\tancestral_state\n"
},
{
"path": "python/tests/data/simplify-bugs/05-edges.txt",
"chars": 327,
"preview": "left right parent child\n0.0 0.8 5 9\n0.3 1.0 5 10\n0.0 1.0 6 8\n0.0 0.3 6 "
},
{
"path": "python/tests/data/simplify-bugs/05-mutations.txt",
"chars": 24,
"preview": "site\tnode\tderived_state\n"
},
{
"path": "python/tests/data/simplify-bugs/05-nodes.txt",
"chars": 350,
"preview": "id is_sample population time\n0 0 0 6.0\n1 0 0 2.0\n2 0 0 2.0\n3 0 "
},
{
"path": "python/tests/data/simplify-bugs/05-sites.txt",
"chars": 25,
"preview": "position\tancestral_state\n"
},
{
"path": "python/tests/ibd.py",
"chars": 13127,
"preview": "# MIT License\n#\n# Copyright (c) 2020-2024 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tests/simplify.py",
"chars": 31473,
"preview": "# MIT License\n#\n# Copyright (c) 2019-2024 Tskit Developers\n# Copyright (c) 2015-2018 University of Oxford\n#\n# Permission"
},
{
"path": "python/tests/test_avl_tree.py",
"chars": 12361,
"preview": "# MIT License\n#\n# Copyright (c) 2021-2024 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tests/test_balance_metrics.py",
"chars": 11549,
"preview": "# MIT License\n#\n# Copyright (c) 2024 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any person ob"
},
{
"path": "python/tests/test_cli.py",
"chars": 21816,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2025 Tskit Developers\n# Copyright (c) 2017 University of Oxford\n#\n# Permission is h"
},
{
"path": "python/tests/test_coalrate.py",
"chars": 76119,
"preview": "# MIT License\n#\n# Copyright (c) 2024 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any person ob"
},
{
"path": "python/tests/test_combinatorics.py",
"chars": 62309,
"preview": "#\n# MIT License\n#\n# Copyright (c) 2020-2023 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pe"
},
{
"path": "python/tests/test_dict_encoding.py",
"chars": 2045,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2020 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tests/test_distance_metrics.py",
"chars": 59296,
"preview": "# MIT License\n#\n# Copyright (c) 2024 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any person ob"
},
{
"path": "python/tests/test_divmat.py",
"chars": 52137,
"preview": "# MIT License\n#\n# Copyright (c) 2023-2024 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tests/test_drawing.py",
"chars": 123805,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2025 Tskit Developers\n# Copyright (C) 2017 University of Oxford\n#\n# Permission is h"
},
{
"path": "python/tests/test_extend_haplotypes.py",
"chars": 47907,
"preview": "import msprime\nimport numpy as np\nimport pytest\n\nimport _tskit\nimport tests.test_wright_fisher as wf\nimport tskit\nfrom t"
},
{
"path": "python/tests/test_file_format.py",
"chars": 39232,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2025 Tskit Developers\n# Copyright (c) 2016-2018 University of Oxford\n#\n# Permission"
},
{
"path": "python/tests/test_fileobj.py",
"chars": 12006,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2023 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tests/test_genotype_matching.py",
"chars": 54688,
"preview": "import copy\nimport itertools\n\nimport lshmm as ls\nimport msprime\nimport numpy as np\nimport pytest\n\nimport tskit\n\nEQUAL_BO"
},
{
"path": "python/tests/test_genotypes.py",
"chars": 107433,
"preview": "# MIT License\n#\n# Copyright (c) 2019-2023 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tests/test_haplotype_matching.py",
"chars": 45344,
"preview": "# MIT License\n#\n# Copyright (c) 2019-2024 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tests/test_highlevel.py",
"chars": 236488,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2025 Tskit Developers\n# Copyright (c) 2015-2018 University of Oxford\n#\n# Permission"
},
{
"path": "python/tests/test_ibd.py",
"chars": 38570,
"preview": "import collections\nimport io\nimport itertools\n\nimport msprime\nimport numpy as np\nimport pytest\n\nimport tests\nimport test"
},
{
"path": "python/tests/test_immutable_table_collection.py",
"chars": 27513,
"preview": "import inspect\nimport re\n\nimport numpy as np\nimport pytest\n\nimport _tskit\nimport tests.tsutil as tsutil\nimport tskit\n\npy"
},
{
"path": "python/tests/test_intervals.py",
"chars": 33583,
"preview": "# MIT License\n#\n# Copyright (c) 2023-2024 Tskit Developers\n# Copyright (C) 2020-2022 University of Oxford\n#\n# Permission"
},
{
"path": "python/tests/test_jit.py",
"chars": 24791,
"preview": "import itertools\nimport sys\n\nimport msprime\nimport numba\nimport numpy as np\nimport numpy.testing as nt\nimport pytest\n\nim"
},
{
"path": "python/tests/test_ld_matrix.py",
"chars": 86267,
"preview": "# MIT License\n#\n# Copyright (c) 2023-2024 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tests/test_metadata.py",
"chars": 101673,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2025 Tskit Developers\n# Copyright (c) 2017 University of Oxford\n#\n# Permission is h"
},
{
"path": "python/tests/test_ms.py",
"chars": 13574,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2022 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tests/test_parsimony.py",
"chars": 57507,
"preview": "# MIT License\n#\n# Copyright (c) 2019-2022 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tests/test_phylo_formats.py",
"chars": 51375,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2021 Tskit Developers\n# Copyright (c) 2016-2017 University of Oxford\n#\n# Permission"
},
{
"path": "python/tests/test_provenance.py",
"chars": 9867,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2024 Tskit Developers\n# Copyright (C) 2018 University of Oxford\n#\n# Permission is h"
},
{
"path": "python/tests/test_python_c.py",
"chars": 218053,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2025 Tskit Developers\n# Copyright (c) 2015-2018 University of Oxford\n#\n# Permission"
},
{
"path": "python/tests/test_reference_sequence.py",
"chars": 11932,
"preview": "# MIT License\n#\n# Copyright (c) 2021-2022 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tests/test_relatedness_vector.py",
"chars": 51512,
"preview": "# MIT License\n#\n# Copyright (c) 2025 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any person ob"
},
{
"path": "python/tests/test_stats.py",
"chars": 59543,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2021 Tskit Developers\n# Copyright (C) 2016 University of Oxford\n#\n# Permission is h"
},
{
"path": "python/tests/test_table_transforms.py",
"chars": 43959,
"preview": "# MIT License\n#\n# Copyright (c) 2022-2024 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tests/test_tables.py",
"chars": 227840,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2024 Tskit Developers\n# Copyright (c) 2017 University of Oxford\n#\n# Permission is h"
},
{
"path": "python/tests/test_text_formats.py",
"chars": 9383,
"preview": "# MIT License\n#\n# Copyright (c) 2021-2024 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tests/test_threads.py",
"chars": 9442,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2021 Tskit Developers\n# Copyright (c) 2016-2017 University of Oxford\n#\n# Permission"
},
{
"path": "python/tests/test_topology.py",
"chars": 278901,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2024 Tskit Developers\n# Copyright (c) 2016-2017 University of Oxford\n#\n# Permission"
},
{
"path": "python/tests/test_tree_positioning.py",
"chars": 21924,
"preview": "# MIT License\n#\n# Copyright (c) 2023 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any person ob"
},
{
"path": "python/tests/test_tree_stats.py",
"chars": 264122,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2025 Tskit Developers\n# Copyright (C) 2016 University of Oxford\n#\n# Permission is h"
},
{
"path": "python/tests/test_util.py",
"chars": 20749,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2024 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tests/test_utilities.py",
"chars": 7492,
"preview": "# MIT License\n#\n# Copyright (c) 2019-2022 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tests/test_vcf.py",
"chars": 39149,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2024 Tskit Developers\n# Copyright (c) 2016 University of Oxford\n#\n# Permission is h"
},
{
"path": "python/tests/test_version.py",
"chars": 1418,
"preview": "# MIT License\n#\n# Copyright (c) 2020-2024 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tests/test_wright_fisher.py",
"chars": 25540,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2021 Tskit Developers\n# Copyright (C) 2017 University of Oxford\n#\n# Permission is h"
},
{
"path": "python/tests/tsutil.py",
"chars": 91729,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2024 Tskit Developers\n# Copyright (C) 2017 University of Oxford\n#\n# Permission is h"
},
{
"path": "python/tskit/__init__.py",
"chars": 3220,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2025 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pers"
},
{
"path": "python/tskit/__main__.py",
"chars": 67,
"preview": "from . import cli\n\nif __name__ == \"__main__\":\n cli.tskit_main()\n"
},
{
"path": "python/tskit/_version.py",
"chars": 147,
"preview": "# Definitive location for the version number.\n# During development, should be x.y.z.devN\n# For beta should be x.y.zbN\nts"
},
{
"path": "python/tskit/cli.py",
"chars": 8757,
"preview": "#\n# MIT License\n#\n# Copyright (c) 2018-2025 Tskit Developers\n# Copyright (c) 2015-2018 University of Oxford\n#\n# Permissi"
},
{
"path": "python/tskit/combinatorics.py",
"chars": 55861,
"preview": "#\n# MIT License\n#\n# Copyright (c) 2020-2024 Tskit Developers\n#\n# Permission is hereby granted, free of charge, to any pe"
},
{
"path": "python/tskit/drawing.py",
"chars": 111379,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2025 Tskit Developers\n# Copyright (c) 2015-2017 University of Oxford\n#\n# Permission"
},
{
"path": "python/tskit/exceptions.py",
"chars": 2373,
"preview": "# MIT License\n#\n# Copyright (c) 2018-2021 Tskit Developers\n# Copyright (c) 2017 University of Oxford\n#\n# Permission is h"
},
{
"path": "python/tskit/genotypes.py",
"chars": 17829,
"preview": "#\n# MIT License\n#\n# Copyright (c) 2018-2024 Tskit Developers\n# Copyright (c) 2015-2018 University of Oxford\n#\n# Permissi"
},
{
"path": "python/tskit/intervals.py",
"chars": 23932,
"preview": "# MIT License\n#\n# Copyright (c) 2023-2025 Tskit Developers\n# Copyright (C) 2020-2021 University of Oxford\n#\n# Permission"
}
]
// ... and 20 more files (download for full content)
About this extraction
This page contains the full source code of the tskit-dev/tskit GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 220 files (7.3 MB), approximately 1.9M tokens, and a symbol index with 8100 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.