Metadata-Version: 2.4
Name: py-cdhit
Version: 2.0.0
Summary: A Python interface for CD-HIT package.
Keywords: bioinformatics,sequence-analysis
Author-Email: Xiao Yuan <yuanx749@gmail.com>
License-Expression: GPL-2.0-only
License-File: LICENSE
License-File: licenses/THIRD-PARTY.txt
License-File: vendor/cdhit/license.txt
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Project-URL: Homepage, https://yuanx749.github.io/py-cdhit/
Project-URL: Documentation, https://yuanx749.github.io/py-cdhit/
Project-URL: Repository, https://github.com/yuanx749/py-cdhit
Requires-Python: >=3.11
Requires-Dist: pandas
Provides-Extra: dev
Requires-Dist: pre-commit==4.7.0; extra == "dev"
Requires-Dist: ruff==0.17.6; extra == "dev"
Requires-Dist: pytest==9.2.0; extra == "dev"
Requires-Dist: pytest-cov==7.1.0; extra == "dev"
Requires-Dist: notebook==7.6.5; extra == "dev"
Description-Content-Type: text/markdown

# py-cdhit

[![PyPI version](https://badge.fury.io/py/py-cdhit.svg)](https://badge.fury.io/py/py-cdhit)
[![Downloads](https://static.pepy.tech/badge/py-cdhit/month)](https://pepy.tech/project/py-cdhit)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/197a0be6dcd14961b919e666a0de39eb)](https://app.codacy.com/gh/yuanx749/py-cdhit/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)

A Python package for CD-HIT, clustering protein or nucleotide sequences.

Run CD-HIT from Python and read its output into pandas DataFrames without switching to the shell or writing a custom parser. CD-HIT is bundled, so `pip install py-cdhit` works on Linux, macOS and Windows without installing CD-HIT separately.

## Installation

```bash
python -m pip install py-cdhit
```

Ready-made packages cover 64-bit Linux, macOS 15 or later, and 64-bit Windows. On other systems, pip builds CD-HIT from source (see Development).

To use an external installation, set `CD_HIT_DIR` for the core programs or `CD_HIT_AUXTOOLS_DIR` for the auxiliary tools. An explicit `CDHIT(path=...)` takes precedence.

## Usage

Cluster a protein FASTA file at 90% identity and read the cluster assignments into a pandas DataFrame.

```Python
from pycdhit import cd_hit, read_clstr

cd_hit(i="proteins.fasta", o="nr90", c=0.9, n=5)
df_clstr = read_clstr("nr90.clstr")
```

See the [CD-HIT user guide](https://github.com/weizhongli/cdhit/blob/V4.8.1/doc/cdhit-user-guide.wiki) or try the [example notebook](https://yuanx749.github.io/py-cdhit/examples/examples.html).

## Bundled software and citation

The source distribution includes [CD-HIT 4.8.1](https://github.com/weizhongli/cdhit/releases/tag/V4.8.1) and its GPL license. When publishing results, cite [Li and Godzik (2006)](https://doi.org/10.1093/bioinformatics/btl158) and [Fu et al. (2012)](https://doi.org/10.1093/bioinformatics/bts565).

## Development

Source builds need a C++ compiler with OpenMP and the zlib development files. On Linux, use GCC. On macOS, install `libomp` with Homebrew and set `OpenMP_ROOT` to the output of `brew --prefix libomp`. On Windows, use MinGW-w64 GCC with libgomp and zlib, set `CMAKE_GENERATOR` to `Ninja`, set `CXX` to the full path to `g++.exe`, and add its directory to `PATH`.

From a Git checkout, initialize the pinned CD-HIT source, install the development tools and run the tests.

```bash
git submodule update --init
python -m pip install -e ".[dev]"
python -m pytest
```

To build the source distribution and a wheel for the current platform, run these commands.

```bash
python -m pip install build
python -m build
```

The archives are written to `dist/`. The **Wheels** workflow runs manually. It builds wheels from the source distribution and tests the installed package on Ubuntu by default, or on all supported platforms when **all** is selected. To build the documentation locally, install `docs/requirements.txt` and run `python -m sphinx -b html docs docs/_build/html`.
