Metadata-Version: 2.4
Name: reset-bio
Version: 1.3.0
Summary: Reference genome Selection Tool
Project-URL: Repository, https://github.com/JaspervB-tud/ReSeT
Project-URL: Changelog, https://github.com/JaspervB-tud/ReSeT/blob/main/CHANGELOG.md
Author-email: Jasper van Bemmelen <jaspervanbemmelen@hotmail.com>
License: MIT License
        
        Copyright (c) 2025 Jasper van Bemmelen
        
        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.
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.10
Requires-Dist: numpy<3.0,>=2.0
Requires-Dist: scipy<2.0,>=1.14
Provides-Extra: dashboard
Requires-Dist: pandas<3.0,>=2.0; extra == 'dashboard'
Requires-Dist: streamlit<2.0,>=1.37; extra == 'dashboard'
Provides-Extra: test
Requires-Dist: pytest<9,>=8; extra == 'test'
Description-Content-Type: text/markdown

# ReSeT — Reference genome Selection Tool

**ReSeT** selects a minimal, representative subset of sequences from a pre-clustered collection. Given a pairwise distance matrix and cluster labels, it minimises an objective that penalises (1) the cost of selecting each sequence, (2) within-cluster coverage gaps, and (3) cross-cluster similarity between selected sequences. The result is a compact reference set that covers every taxon while avoiding redundancy.

## Installation

```bash
pip install reset-bio
```

## Quick start

```python
import numpy as np
from reset import Solution

# Distance matrix (n × n) and cluster assignments (integer, length n)
D = np.array([[0.0, 0.2, 0.8], [0.2, 0.0, 0.7], [0.8, 0.7, 0.0]])
clusters = np.array([0, 0, 1])

sol = Solution(D, clusters, selection_cost=0.1)
sol.local_search(max_runtime=10)
print(np.flatnonzero(sol.selection))   # indices of selected sequences
```

## Command-line interface

```bash
reset \
  --clusters     clusters.csv \
  --distances    distances.tsv \
  --distance_format mash \
  --selection_cost 1e-1 \
  --scale 1e-5 \
  --output selected.txt
```

Supported distance formats: `mash`, `sourmash_cosine`, `sourmash_jaccard`, `generic`.

## Distance formats

| Format | Description |
|--------|-------------|
| `mash` | Mash lower-triangular output (`mash triangle`) |
| `sourmash_cosine` | Sourmash CSV (column 12 = cosine distance) |
| `sourmash_jaccard` | Sourmash CSV (column 6 = Jaccard distance) |
| `generic` | Any delimited `(i, j, distance)` file |

## Multiprocessing

Use `Solution_shm` for parallel local search:

```python
from reset import Solution_shm
sol = Solution_shm(D, clusters, selection_cost=0.1)
sol.local_search(num_processes=4, max_runtime=60)
```

## Dashboard

An interactive Streamlit dashboard is included. Install with dashboard extras and launch:

```bash
pip install "reset-bio[dashboard]"
streamlit run $(python -c "import reset.dashboard.app as a; import os; print(os.path.abspath(a.__file__))")
```

The dashboard defaults to the bundled toy example — no configuration needed.

## License

MIT — see [LICENSE](https://github.com/JaspervB-tud/ReSeT/blob/main/LICENSE).
