PyHIV: A Python Package for Local HIV-1 Sequence Alignment, Subtyping, and Gene Splitting
Overview
PyHIV is a Python package that aligns HIV nucleotide sequences against reference genomes to determine the most similar subtype and optionally split the aligned sequences into gene regions.
Key Features:
- 🧬 Local HIV-1 sequence alignment against reference genomes
- 🏷️ Automated subtyping with comprehensive reference database
- ✂️ Gene region splitting (gag, pol, env, etc.)
- 📊 Detailed reporting with summary tables and visualizations
- ⚡ Parallel processing for efficient analysis
- 🖥️ Command-line interface for easy integration
Installation
pip install pyhiv-tools
Quick Start
Command Line Interface
# Basic usage
pyhiv run /path/to/fasta/files
# With custom options
pyhiv run /path/to/fasta/files -o results/ -j 4 -v
# Validate inputs first
pyhiv validate /path/to/fasta/files
Python API
from pyhiv import PyHIV
PyHIV(
fastas_dir="path/to/fasta/files",
subtyping=True,
splitting=True, # True/"subtype", "hxb2"/"reference", or False/"none"
output_dir="results_folder",
n_jobs=4,
reporting=True,
alignment_tool="edlib-HW",
kmer_size=15,
reference_top_k=30,
reference_groups="M"
)
When subtyping=False, any active splitting mode uses HXB2 coordinates.
What PyHIV Produces
- Best reference alignment per sequence
- Subtype and reference metadata
- Ranked top 3 closest HIV-1 subtypes
- Gene-region–specific FASTA files (optional)
- Final summary table (
final_table.tsv) - PDF reports with sequence visualizations (optional)
Output Structure
PyHIV_results/
├── final_table.tsv # Summary of results
├── best_alignment_<sequence>.fasta # Alignment to best reference
├── PyHIV_report_all_sequences.pdf # PDF report (if enabled)
├── gag/ # Gene regions (if splitting enabled)
│ ├── <sequence>_gag.fasta
│ └── ...
├── pol/
│ ├── <sequence>_pol.fasta
│ └── ...
└── env/
├── <sequence>_env.fasta
└── ...
Requirements
- Python 3.10+
- pandas
- biopython
- edlib
- pyfamsa
- click
- matplotlib
- parasail (optional, only for
--alignment-tool parasail-NW; install withpip install pyhiv-tools[parasail])
PyHIV supports edlib-HW (default), parasail-NW/parasail, PyFamsa, and MAFFT as alignment tool names. parasail-NW requires the optional parasail extra. MAFFT requires an external mafft executable. Before final alignment, PyHIV ranks references using query/reference k-mer containment and aligns only the top candidates by default. Use reference_top_k=0 to keep the original all-reference strategy. By default, subtyping uses group M references from reference_fastas, selected through the group column in sequences_with_locations.tsv; set reference_groups="M,N,O,P" to include groups N, O, and P. The final table and PDF report include the best Group/Subtype call plus a ranked Closest Subtypes field with the top 3 closest unique group/subtype calls.
PyHIV resolves MAFFT from PYHIV_MAFFT_BIN, then mafft on PATH.
Input sequences longer than 12000 nucleotides are skipped with this warning: The submitted sequence is longer than the HIV-1 genome.
Documentation
- Full Documentation: https://pyhiv.readthedocs.io/
- CLI Reference: Available in the package documentation
- GitHub Repository: https://github.com/anaapspereira/PyHIV
Citation
If you use PyHIV in your research, please cite:
@software{pyhiv2024,
title={PyHIV: A Python Package for Local HIV-1 Sequence Alignment, Subtyping and Gene Splitting},
author={Santos-Pereira, Ana},
year={2024},
url={https://github.com/anaapspereira/PyHIV},
license={MIT}
}
Note: Manuscript in preparation. Please cite this repository if you use PyHIV in your research.
License
This project is licensed under the MIT License. See LICENSE file for details.
Project Links
- Source Code: https://github.com/anaapspereira/PyHIV
- Issues: https://github.com/anaapspereira/PyHIV/issues
- PyPI Package: https://pypi.org/project/pyhiv-tools/
Metadata
Release files for pyhiv-tools 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyhiv_tools-1.0.0.tar.gz | 2.8 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyhiv_tools-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.5 MB
Release files / pyhiv_tools-1.0.0.tar.gz
| Download URL | pyhiv_tools-1.0.0.tar.gz |
|---|---|
| Size | 2.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e84eee717dc9e600877bc83a65fb933b5b9de5c5a476f96577d62ac2076f173f
|
|
BLAKE2b-256 checksum How to use checksums |
2cc5188de727d55a8d9cfa9a1e8c8e3b32f165d9b27d2c2e20c48b662387c12d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pyhiv_tools-1.0.0-py3-none-any.whl
| Download URL | pyhiv_tools-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.7 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e94067b973c05540c7778fea9942213e6d14b187a929bc62cfe01445cb856a3
|
|
BLAKE2b-256 checksum How to use checksums |
92dc0c48619e745144ffa10c10de825012c108e80fa1dbc72c50fe197296447c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|