Metadata-Version: 2.4
Name: pysnptools
Version: 1.1.0
Summary: PySnpTools
Keywords: gwas,bioinformatics,sets,intervals,ranges,regions,plink,genomics,file-format,reader,genotype,bed-format,writer,python,snps
Author: FaST-LMM Team
Author-email: FaST-LMM Team <fastlmm-dev@python.org>
License-Expression: Apache-2.0
License-File: LICENSE.md
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Requires-Dist: scipy>=1.9.3 ; python_full_version < '3.12'
Requires-Dist: scipy>=1.11.3 ; python_full_version == '3.12.*'
Requires-Dist: scipy>=1.14.1 ; python_full_version == '3.13.*'
Requires-Dist: scipy>=1.16.1 ; python_full_version == '3.14.*'
Requires-Dist: scipy>=1.18.1 ; python_full_version >= '3.15'
Requires-Dist: numpy>=1.23.5 ; python_full_version < '3.12'
Requires-Dist: numpy>=1.26.0 ; python_full_version == '3.12.*'
Requires-Dist: numpy>=2.1.0 ; python_full_version == '3.13.*'
Requires-Dist: numpy>=2.3.5 ; python_full_version == '3.14.*'
Requires-Dist: numpy>=2.5.4 ; python_full_version >= '3.15'
Requires-Dist: psutil>=6.1.0
Requires-Dist: pandas>=1.5.3,<4 ; python_full_version < '3.12'
Requires-Dist: pandas>=2.1.1,<4 ; python_full_version == '3.12.*'
Requires-Dist: pandas>=2.2.3,<4 ; python_full_version == '3.13.*'
Requires-Dist: pandas>=2.3.3,<4 ; python_full_version >= '3.14'
Requires-Dist: cloudpickle>=3.1.0
Requires-Dist: threadpoolctl>=3.5.0 ; python_full_version < '3.15'
Requires-Dist: threadpoolctl>=3.8.0 ; python_full_version >= '3.15'
Requires-Dist: bed-reader[samples]>=1.3.0
Requires-Dist: more-itertools>=10.5.0
Requires-Dist: cbgen>=1.0.6 ; extra == 'bgen'
Requires-Dist: bgen-reader>=4.0.9 ; extra == 'bgen'
Requires-Dist: cupy-cuda13x>=14.2,<15 ; extra == 'cupy'
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: pytest-cov ; extra == 'dev'
Requires-Dist: pytest-doctestplus ; extra == 'dev'
Requires-Dist: pytest-datadir ; extra == 'dev'
Requires-Dist: limix-sphinx-theme>=0.0.4 ; extra == 'dev'
Requires-Dist: pytest-sphinx>=0.2.2 ; extra == 'dev'
Requires-Dist: sphinx>=6.2.1 ; extra == 'dev'
Requires-Dist: sphinx-rtd-theme>=3.0.1 ; extra == 'dev'
Requires-Dist: ruff>=0.7.2 ; extra == 'dev'
Requires-Dist: h5py>=3.12.1 ; python_full_version < '3.14' and extra == 'hdf5'
Requires-Dist: h5py>=3.15.0 ; python_full_version >= '3.14' and extra == 'hdf5'
Requires-Python: >=3.11.5
Project-URL: Homepage, https://fastlmm.github.io/
Project-URL: Documentation, https://fastlmm.github.io/PySnpTools
Project-URL: Issues, https://github.com/fastlmm/PySnpTools/issues
Project-URL: Source, https://github.com/fastlmm/PySnpTools
Provides-Extra: bgen
Provides-Extra: cupy
Provides-Extra: dev
Provides-Extra: hdf5
Description-Content-Type: text/markdown

PySnpTools
====================

[![PyPI version](https://badge.fury.io/py/pysnptools.svg)](https://badge.fury.io/py/pysnptools)
[![Build Status](https://github.com/fastlmm/PySnpTools/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastlmm/PySnpTools/actions/workflows/ci.yml)
![Python versions](https://img.shields.io/pypi/pyversions/pysnptools)

PySnpTools is a library for reading and manipulating genetic data.

Main Features:

* **New: [GPU standardization and kernels](https://github.com/fastlmm/PySnpTools/blob/main/doc/source/gpu.rst).** PySnpTools reads genotypes on the CPU, then transfers them to [CuPy](https://cupy.dev/), the NumPy-compatible GPU array library, for GPU standardization and kernel construction. A main use is FaST-LMM's single-kernel `single_snp`, which ran over 10 times as fast with float32 on an RTX 3060 as with the default CPU float64, in a synthetic benchmark with 14,925 individuals and 100,000 SNPs. See also the [GPU workflow notebook](https://github.com/fastlmm/PySnpTools/blob/main/doc/ipynb/gpu_workflow.ipynb).

* [SnpReader](http://fastlmm.github.io/PySnpTools): Efficiently read genetic PLINK formats including \*.bed/bim/fam files.
          Also, efficiently read parts of files, read kernel data, and standardize data.
          Features include multi-threaded BED reading, cluster-ready BED data, on-the-fly SNP generation,
          and larger in-memory data.

* [DistReader](https://fastlmm.github.io/PySnpTools/#module-pysnptools.distreader): Efficiently work with
         unphased BGEN format and other diploid, biallelic distribution data.
          Also, efficiently read parts of files. See [Distribution IPython Notebook](https://nbviewer.jupyter.org/github/fastlmm/PySnpTools/blob/main/doc/ipynb/Dist.ipynb).

* [util](https://fastlmm.github.io/PySnpTools/#module-pysnptools.util): In one line, intersect and re-order IIDs from snpreader and other sources.
          Also, efficiently extract a submatrix from an ndarray.

* [IntRangeSet](https://fastlmm.github.io/PySnpTools/#util-intrangeset): Efficiently manipulate ranges of integers - for example, genetic position - with set operators including union, intersection, and set difference.

* [mapreduce1](https://fastlmm.github.io/PySnpTools/#module-pysnptools.util.mapreduce1): Run loops locally, on multiple processors, or on any cluster.

* [filecache](https://fastlmm.github.io/PySnpTools/#module-pysnptools.util.filecache):  Read and write files locally or from/to any remote storage.

Install
-------

    pip install pysnptools

Requires Python 3.11.5 or later. Core Python 3.15 support excludes HDF5, BGEN,
and CuPy because their required wheels are not currently available together.

Install the `cupy` extra to use an NVIDIA GPU.

    pip install "pysnptools[cupy]"

GPU support requires NVIDIA CUDA on x86-64 Windows or Linux, including WSL2.
Python 3.15 is currently CPU-only: CuPy has no Python 3.15 wheel yet, so
`pip install "pysnptools[cupy]"` fails there. Install `pysnptools` without the
extra on Python 3.15. See the GPU guide for driver and CUDA setup.

HDF5 support is optional. To read or write HDF5 files, install:

    pip install pysnptools[hdf5]

Existing HDF5 users upgrading from an earlier release should install this extra.

*If you need support for BGEN files, instead do:*

    pip install pysnptools[bgen]

Documentation
-------------

* [Main Documentation](http://fastlmm.github.io/PySnpTools/) with examples. It includes links to tutorial slides, notebooks, and video.
* [Project Home and Full Annotated Bibliography](https://fastlmm.github.io/)

Code
----

* [PyPi](https://pypi.org/project/pysnptools/)
* [GitHub](https://github.com/fastlmm/PySnpTools)
* [Change Log](https://github.com/fastlmm/PySnpTools/blob/main/CHANGELOG.md)

Contacts
--------

* Email the developers at <fastlmm-dev@python.org>.
* [Join](mailto:fastlmm-user-join@python.org?subject=Subscribe) the user discussion and announcement list (or use [web sign up](https://mail.python.org/mailman3/lists/fastlmm-user.python.org)).
* [Open an issue](https://github.com/fastlmm/PySnpTools/issues) on GitHub.

## Testing

PySnpTools has two test runners. Run `pytest` from the repository root for
pytest tests and doctests in Python modules, reStructuredText, and Markdown.
Run `python -m pysnptools.test` for the legacy unittest suite, which assembles
reader, standardizer, utility, optional-format, and doctest checks. These runners
cover overlapping but different sets of tests.

Two doctest examples in `pysnptools.distreader.bgen` require external QCTool v2:
`Bgen.genwrite` and `Bgen.write`. Install QCTool v2 from the [official QCTool
site](https://www.well.ox.ac.uk/~gav/qctool/), then set `QCTOOLPATH` to the
command or executable path used to launch it. For example, on Linux or macOS:

```sh
export QCTOOLPATH=/absolute/path/to/qctool
```

On Windows, install QCTool in WSL and set `QCTOOLPATH` to the WSL launch command
and Linux executable path, as described in the `Bgen.write` API documentation.
The BGEN doctest fails with a message naming qctool when this configuration is
missing; it does not silently skip.
