Metadata-Version: 2.4
Name: hapnet
Version: 0.1.0
Summary: Population-aware haplotype network analysis and visualization in Python.
Author: Andrew A. Davinack
License: MIT
Project-URL: Homepage, https://github.com/parasiteguy/hapnet
Project-URL: Repository, https://github.com/parasiteguy/hapnet
Project-URL: Issues, https://github.com/parasiteguy/hapnet/issues
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: biopython>=1.80
Requires-Dist: networkx>=3.0
Requires-Dist: matplotlib>=3.7
Requires-Dist: numpy>=1.24
Requires-Dist: scipy>=1.9
Dynamic: license-file

# hapnet

**hapnet** is a Python package for building **population-aware haplotype networks** from aligned FASTA files.  
It integrates haplotype inference, population membership, and visualization into a reproducible, command-line workflow.

hapnet constructs minimum spanning tree (MST) haplotype networks in which node size reflects haplotype frequency and shared haplotypes are represented as population-colored pie charts.

---

## Features

- Aligned FASTA input
- Population parsed directly from FASTA headers
- Minimum spanning tree (MST) haplotype networks
- Haplotype nodes sized by frequency
- Population-aware pie charts for shared haplotypes
- Mutation tick marks on network edges
- Reproducible TSV logs and summary statistics

---

## Installation

```bash
pip install hapnet

Python 3.9 or newer is required

---

USAGE

hapnet input.fasta --out network.png --log-prefix run1

This command produces:
network.png - haplotype network visualization
run1_haplotypes.tsv - haplotype definitions and frequencies
run1_membership.tsv - sequence-to-haplotype membership
run1_shared_haplotypes.tsv - haplotypes shared among populations
run1_summary.tsv - summary statistics (total haplotypes, shared vs private, etc.)

FASTA HEADER FORMAT

Population identity must be encoded as the final underscore-delimited token in each FASTA header.

Examples:
Ind1_Pop1
Ind7_SiteA_2019_Pop3
MN605578_Pneocaeca_RI

In all cases, the population is interpreted as the final token (Pop1, Pop3, RI).
Sequences must be aligned and of equal length.

SCALABILITY and VISUALIZATION NOTES

Hapnet scales computationally with the number of distinct haplotypes, not the number of input sequences. Static network visualizations are typically most interpretable for datasets containing tens to low hundreds of haplotypes, depending on network structure and frequency distribution. All haplotypes and population memberships are retained in the output logs regardless of visualization complexity. 

LICENSE
Hapnet is released under the MIT License 

