Metadata-Version: 2.4
Name: bioalign
Version: 0.1.0
Summary: Homology search, multiple sequence alignment, Shannon conservation analytics, Neighbor-Joining phylogenetics, and multi-format MSA conversion
Author-email: Alper Karagöl <akaragol@mit.edu>, Taner Karagöl <karagolt@mit.edu>
License-Expression: MIT
Project-URL: Homepage, https://www.karagolresearch.com/bioalign
Project-URL: Documentation, https://www.karagolresearch.com/bioalign
Project-URL: Preprint, https://doi.org/10.1101/2024.08.01.606148
Keywords: bioinformatics,multiple-sequence-alignment,phylo,neighbor-joining,conservation,blast,clustal-omega,mafft
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
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.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.20.0
Dynamic: license-file

# bioalign

[![PyPI version](https://img.shields.io/pypi/v/bioalign)](https://pypi.org/project/bioalign/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

`bioalign` is the standalone Python library and command-line interface for the [BioAlign](https://www.karagolresearch.com/bioalign) workbench. It combines local affine-gap progressive alignment (BLOSUM62 and nucleotide scoring), optional EMBL-EBI Job Dispatcher remote search and alignment (`ncbiblast`, `clustalo`, `muscle`, `mafft`, `tcoffee`, `kalign`), per-column Shannon entropy and conservation profiling, Poisson-corrected distance matrices, Neighbor-Joining and UPGMA tree reconstruction, and multi-format alignment conversion (`FASTA`, `Clustal`, `PHYLIP`, `Stockholm`, `MSF`, `NEXUS`, `Newick`, `SVG`, `CSV`, and `JSON`).

## Installation

```bash
pip install bioalign
```

## Command-Line Usage

### 1. Align Unaligned Sequences (Offline Progressive Needleman-Wunsch or Remote EMBL-EBI)

```bash
bioalign align unaligned.fasta -o aligned.fasta
bioalign align unaligned.fasta --engine clustalo --email researcher@institute.edu -o aligned.fasta
```

### 2. Compute Conservation, Shannon Entropy, Consensus, and Pairwise Identity

```bash
bioalign stats aligned.fasta -o alignment_summary.json --csv per_column_metrics.csv
```

### 3. Reconstruct Neighbor-Joining or UPGMA Trees (Newick + Publication SVG)

```bash
bioalign tree aligned.fasta --method nj -o tree.nwk --svg tree.svg
bioalign tree aligned.fasta --method upgma --cladogram --svg cladogram.svg
```

### 4. Convert Alignments Across Standard Formats

```bash
bioalign convert aligned.fasta --to clustal -o aligned.aln
bioalign convert aligned.fasta --to stockholm -o aligned.sto
bioalign convert aligned.fasta --to phylip -o aligned.phy
bioalign convert aligned.fasta --to nexus -o aligned.nex
bioalign convert aligned.fasta --to msf -o aligned.msf
```

### 5. Run Homolog Search + Alignment Pipeline via EMBL-EBI Job Dispatcher

```bash
bioalign search query.fasta --email researcher@institute.edu --align clustalo -o results_dir
```

## Python API

```python
from bioalign import (
    align_sequences,
    build_tree,
    compute_alignment_stats,
    format_alignment,
    parse_fasta,
    to_newick,
)

records = parse_fasta("unaligned.fasta")
aligned = align_sequences(records)
stats = compute_alignment_stats(aligned)
tree = build_tree(
    [r.id for r in aligned],
    stats["identity_matrix"],
    method="nj",
)
print("Consensus:", stats["consensus"])
print("Newick:", to_newick(tree))
print(format_alignment(aligned, fmt="clustal"))
```

## Citation

Karagöl, A., Karagöl, T. An Evolutionary Statistics Toolkit for Simplified Sequence Analysis on Web with Client-Side Processing. *bioRxiv* (2024). https://doi.org/10.1101/2024.08.01.606148

## License

Released under the MIT License.
