Metadata-Version: 2.4
Name: sapphyre
Version: 0.12.0
Summary: Gene recovery from genome assemblies and unassembled reads for phylogenomics
Author-email: Kevin Moran <thernn8891@gmail.com>
Maintainer-email: Ashton Pooley <admin@ashi.digital>
License-Expression: GPL-3.0-or-later
Project-URL: Homepage, https://github.com/kevinmoran1988/SAPPHYRE
Project-URL: Repository, https://github.com/kevinmoran1988/SAPPHYRE
Project-URL: Issues, https://github.com/kevinmoran1988/SAPPHYRE/issues
Keywords: phylogenetics,bioinformatics,genomics,phylogenomics,phylogeny,bio,assembly,sequencing
Classifier: Natural Language :: English
Classifier: Environment :: Console
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
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: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: LICENSE-THIRD-PARTY
Requires-Dist: beautifulsoup4>=4.12.3
Requires-Dist: msgspec>=0.18.6
Requires-Dist: needletail>=0.5.0
Requires-Dist: numpy>=2.0.1
Requires-Dist: openpyxl>=3.1.2
Requires-Dist: polars>=2.0.0
Requires-Dist: pyfamsa>=0.5.3
Requires-Dist: requests>=2.32.3
Requires-Dist: sapphyre_tools>=0.13.27
Requires-Dist: scipy>=1.13
Requires-Dist: wrap_rocks>=0.7.9
Requires-Dist: xxhash>=3.4.1
Requires-Dist: isal>=1.7.0
Dynamic: license-file

<div align="center">

<h1>SAPPHYRE</h1>

<p><b>Gene recovery from genome assemblies and unassembled reads, for phylogenomics and comparative genomics</b></p>

<a href="https://pypi.org/project/sapphyre/"><img alt="PyPI" src="https://img.shields.io/pypi/v/sapphyre?color=3775a9"></a>
<img alt="Python 3.10 to 3.14" src="https://img.shields.io/badge/python-3.10%E2%80%933.14-3776ab">
<img alt="Linux x86-64 or WSL2" src="https://img.shields.io/badge/platform-Linux%20x86--64%20%7C%20WSL2-555">
<a href="LICENSE"><img alt="GPL-3.0-or-later" src="https://img.shields.io/badge/license-GPL--3.0--or--later-2ea44f"></a>

<p>
<a href="https://github.com/kevinmoran1988/SAPPHYRE/blob/Release/docs/INSTALL.md"><b>Installation</b></a> &nbsp;·&nbsp;
<a href="https://github.com/kevinmoran1988/SAPPHYRE/blob/Release/docs/USER_GUIDE.md"><b>User Guide</b></a> &nbsp;·&nbsp;
<a href="#quick-start"><b>Quick start</b></a> &nbsp;·&nbsp;
<a href="https://github.com/kevinmoran1988/SAPPHYRE/issues"><b>Issues</b></a>
</p>

</div>

<br>

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/kevinmoran1988/SAPPHYRE/Release/docs/img/pipeline-dark.svg">
  <img alt="SAPPHYRE pipeline: prepare, diamond, hmmsearch, reporter, align, flexcull, outlier and merge run per taxon; reconcile and finalize combine all taxa into per-gene alignments" src="https://raw.githubusercontent.com/kevinmoran1988/SAPPHYRE/Release/docs/img/pipeline-light.svg" width="100%">
</picture>

SAPPHYRE finds every gene of a reference set (an *orthoset*) in each of your genomes or read libraries, builds a gene model
or contig for it, and aligns all samples gene by gene into matrices ready for tree building.

- **Genome assemblies.** Single-copy orthologs by default, or every copy of a multi-copy gene family with `-gfm multi`.
  Gene models carry their exon structure, alternative coding paths and pseudogene tags, with a cluster table and GFF.
- **Unassembled reads.** Short-read libraries are trimmed, searched and assembled gene by gene, with no genome assembly.
- **Sensitive searches.** Translated DIAMOND searches find candidate regions; frameshift-aware BATH profile searches
  confirm them and recover exons DIAMOND missed.

## Install

```bash
pip install sapphyre
```

Linux x86-64 (glibc 2.28 or newer) or WSL2, with CPython 3.10 to 3.14. Install these programs as well and put them on your
`PATH`:

| | Program | Get it |
| :-- | :-- | :-- |
| **Required** | [DIAMOND](https://github.com/bbuchfink/diamond) 2.1.6+ | `mamba install -c bioconda diamond` |
| | [BATH](https://github.com/TravisWheelerLab/BATH) 2.0 | [release binary](https://github.com/TravisWheelerLab/BATH/releases) or source build |
| | [HMMER](http://hmmer.org) 3.4 | `mamba install -c bioconda hmmer` |
| **Optional** | MAFFT, Clustal Omega, BLAST+, SRA Toolkit, Kraken2 | only for the options that use them |

Then check with `sapphyre --version`. The **[Installation Guide](https://github.com/kevinmoran1988/SAPPHYRE/blob/Release/docs/INSTALL.md)** walks through every step.

## Quick start

From a folder that holds `input/MyGenomes/` (one FASTA file per genome) and `orthosets/MySet/` (a reference set built with
`sapphyre makeref`):

```bash
# 1. Find and model every gene in every genome
sapphyre -p 32 -v -os MySet auto input/MyGenomes

# 2. Combine the genomes gene by gene and align them
sapphyre -p 32 -v -os MySet reconcile datasets/MyGenomes -out MyGenomes_MySet

# 3. Filter, rename and package the alignments
sapphyre -p 8 -v finalize MyGenomes_MySet -ct -r
```

The finished alignments are in `MyGenomes_MySet/Processed/Target/`. Global options (`-p`, `-v`, `-os`, `-gfm`) go before
the command name; add `-gfm multi` to all three commands for multi-copy gene families. The
**[User Guide](https://github.com/kevinmoran1988/SAPPHYRE/blob/Release/docs/USER_GUIDE.md)** covers reads, multi-copy families, iteration, building orthosets, output layout and
troubleshooting.

## Commands

| Command | What it does |
| :-- | :-- |
| `auto` | Run the per-taxon pipeline, from any stage (`-s`) and with optional per-stage settings (`-cfg`) |
| `prepare` · `diamond` · `hmmsearch` · `reporter` · `align` · `flexcull` · `outlier` · `merge` | The per-taxon stages, also runnable one at a time |
| `reconcile` · `finalize` | Combine all taxa per gene, align, and package the final matrices |
| `iterate` | Turn recovered copies into extra references for another round (`-gfm multi`) |
| `makeref` | Build an orthoset from per-gene FASTA, OrthoDB downloads or an Orthograph database |
| `toolset` | `download` · `taxonomy` · `repack` · `archive` · `kraken-screen` · `crosscontam` · `decontam` · `refine` · `flanks` · `isoform` |

Every command documents itself: `sapphyre -h`, `sapphyre <command> -h`, `sapphyre toolset <tool> -h`. Exit status is 0 on
success, 1 on failure, 2 for invalid arguments and 3 when some inputs failed while others completed.

## Development

```bash
git clone https://github.com/kevinmoran1988/SAPPHYRE && cd SAPPHYRE
pip install -e . pytest && pytest -q tests   # unit tests need no external tools
```

Bug reports and questions: <https://github.com/kevinmoran1988/SAPPHYRE/issues>.

## Credits and licence

Sapphyre is licensed under GPL-3.0-or-later (`LICENSE`).

<details>
<summary><b>Third-party programs, ported code, data and methods</b></summary>

It uses these programs:

- DIAMOND: Buchfink, Reuter & Drost (2021), Nature Methods 18:366-368
- BATH: Krause, Shands & Wheeler (2024), Bioinformatics Advances 4:vbae088
- HMMER 3: Eddy (2011), PLoS Computational Biology 7:e1002195
- FAMSA: Deorowicz, Debudaj-Grabysz & Gudyś (2016), Scientific Reports 6:33964
- MAFFT (optional): Katoh & Standley (2013), Molecular Biology and Evolution 30:772-780
- Clustal Omega (optional): Sievers et al. (2011), Molecular Systems Biology 7:539
- BLAST+ (`toolset crosscontam`): Camacho et al. (2009), BMC Bioinformatics 10:421
- SRA Toolkit (`toolset download`): NCBI

It contains code ported from:

- NCBI SEG as in BLAST+ (public domain): low-complexity masking; Wootton & Federhen (1993), Computers & Chemistry 17:149-163

Its compiled engine, [sapphyre_tools](https://github.com/mvalentine65/blosum_distance), contains code ported from:

- BATH, HMMER and Easel (BSD 3-clause): profile HMM alignment and its SIMD
- fastp (MIT): read trimming, adapter detection and overlap correction; Chen, Zhou, Chen & Gu (2018), Bioinformatics 34:i884-i890

Its codon alignment (`pn2codon`) began as a port of PAL2NAL and has since been rewritten: Suyama, Torrents & Bork (2006), Nucleic Acids Research 34:W609-W612.

The notices of all of these are in `LICENSE-THIRD-PARTY`.

Data, formats and methods:

- `makeref` reads OrthoDB gene sets: Tegenfeldt et al. (2025), Nucleic Acids Research 53:D516-D522
- `makeref` also reads Orthograph's SQLite ortholog sets: Petersen et al. (2017), BMC Bioinformatics 18:111
- `toolset download` fetches from NCBI Datasets (O'Leary et al. 2024, Scientific Data 11:732) and the Sequence Read Archive (Leinonen, Sugawara & Shumway 2011, Nucleic Acids Research 39:D19-D21)
- `finalize` counts missing data as Dietz et al. (2023), Methods in Ecology and Evolution 14:543-555
- Donor splice site frequencies are from Senapathy, Shapiro & Harris (1990), Methods in Enzymology 183:252-278

</details>
