💎 Diamononpy 🐍
A Python wrapper for the ultra-fast DIAMOND sequence alignment tool. This package provides a clean, Pythonic API for DIAMOND's powerful sequence search capabilities with seamless pandas integration for efficient bioinformatics data analysis and processing. Perfect for researchers and bioinformaticians working with large genomic datasets who need both speed and ease of use.
✨ Features
- 🚀 Full support for all DIAMOND V commands
- 📊 Results returned as pandas DataFrames for easy analysis
- 🗑️ Automatic temporary file management
- 🔍 Type hints for better IDE support
- 🧪 Comprehensive test suite
- 📦 Minimal dependencies (only pandas and numpy)
📥 Installation
First, ensure you have DIAMOND installed and accessible in your PATH. Then install this package:
pip install diamononpy
For installation directly from the GitHub repository, use the following command:
pip install git+https://github.com/EnzoAndree/diamondonpy.git
For development installation (including test dependencies):
pip install -e ".[dev]"
🚀 Usage
Basic Usage
from diamononpy import Diamond
# Initialize the wrapper
diamond = Diamond()
# Create a database
diamond.makedb(
db="mydb.dmnd",
input_file="sequences.fasta",
threads=4
)
# Run BLASTP search - results as DataFrame
results_df = diamond.blastp(
db="mydb.dmnd",
query="query.fasta",
evalue=1e-10,
threads=4
)
# Access results using pandas
print(results_df.head())
print(f"Found {len(results_df)} hits")
print(f"Average identity: {results_df['pident'].mean():.2f}%")
# Filter results
significant_hits = results_df[
(results_df['evalue'] < 1e-30) &
(results_df['pident'] > 90)
]
📊 Working with Results
All BLAST-like commands (blastp, blastx) return pandas DataFrames with the following columns:
- qseqid: Query sequence identifier
- sseqid: Subject sequence identifier
- pident: Percentage of identical matches
- length: Alignment length
- mismatch: Number of mismatches
- gapopen: Number of gap openings
- qstart: Start of alignment in query
- qend: End of alignment in query
- sstart: Start of alignment in subject
- send: End of alignment in subject
- evalue: Expect value
- bitscore: Bit score
# BLASTP with output file
results_df = diamond.blastp(
db="mydb.dmnd",
query="query.fasta",
out="results.txt", # Optional: save to file
evalue=1e-10
)
# Clustering with results as DataFrame
clusters_df = diamond.cluster(
db="mydb.dmnd",
approx_id=90.0
)
print(clusters_df.head())
# Bidirectional Best Hit analysis
bbh_df = diamond.bidirectional_best_hit(
db1="db1.dmnd",
db2="db2.dmnd",
evalue=1e-10
)
print(bbh_df.head())
🛠️ Available Commands
All major DIAMOND commands are supported with enhanced result handling:
makedb: Build DIAMOND database from a FASTA fileblastp: Align protein sequences (returns DataFrame)blastx: Align DNA sequences (returns DataFrame)view: View DAA files (returns DataFrame for tabular output)cluster: Cluster sequences (returns DataFrame)linclust: Linear-time clustering (returns DataFrame)getseq: Retrieve sequencesdbinfo: Database informationbidirectional_best_hit: Perform bidirectional best hit analysis between two databases
🧠 Advanced Features
Custom Output Formats
# Custom BLAST output format
results_df = diamond.blastp(
db="mydb.dmnd",
query="query.fasta",
outfmt="6 qseqid sseqid pident evalue bitscore qcovhsp"
)
# Non-tabular output
text_output = diamond.view(
daa="alignment.daa",
outfmt=0 # BLAST pairwise format
)
🧹 Temporary File Management
The package automatically manages temporary files:
with Diamond() as diamond:
results_df = diamond.blastp(
db="mydb.dmnd",
query="query.fasta"
)
# Temporary files are automatically cleaned up
🔄 Cluster Analysis
Analyze clustering results with built-in parser:
# Perform clustering
clusters_df = diamond.cluster(
db="mydb.dmnd",
approx_id=90.0
)
# Data contains cluster IDs and members
print(f"Number of clusters: {clusters_df['cluster_id'].nunique()}")
📋 Requirements
- Python ≥ 3.6
- DIAMOND (must be installed separately and accessible in PATH)
- pandas ≥ 1.0.0
- numpy ≥ 1.18.0
🧪 Development
First, install development dependencies:
pip install -e ".[dev]"
To run tests:
# Run basic tests
pytest
# Run tests with coverage report
pytest --cov=diamononpy
# Run tests with detailed coverage report
pytest --cov=diamononpy --cov-report=term-missing
# Run tests verbosely
pytest -v
# Run a specific test file
pytest tests/test_diamond.py
# Run a specific test function
pytest tests/test_diamond.py::test_blastp
📚 References
This package is a wrapper for the DIAMOND bioinformatics tool.
When using DIAMOND in published research, please cite:
- Buchfink B, Reuter K, Drost HG, "Sensitive protein alignments at tree-of-life scale using DIAMOND", Nature Methods 18, 366–368 (2021). doi:10.1038/s41592-021-01101-x
For sequence clustering:
- Buchfink B, Ashkenazy H, Reuter K, Kennedy JA, Drost HG, "Sensitive clustering of protein sequences at tree-of-life scale using DIAMOND DeepClust", bioRxiv 2023.01.24.525373; doi: doi:10.1101/2023.01.24.525373
Original publication to cite DIAMOND until v0.9.25:
- Buchfink B, Xie C, Huson DH, "Fast and sensitive protein alignment using DIAMOND", Nature Methods 12, 59-60 (2015). doi:10.1038/nmeth.3176
📄 License
This project is licensed under the GNU General Public License v3 (GPLv3) - see the LICENSE file for details.
Metadata
Release files for diamondonpy 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| diamondonpy-0.1.1.tar.gz | 33.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| diamondonpy-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 67.3 kB
Release files / diamondonpy-0.1.1.tar.gz
| Download URL | diamondonpy-0.1.1.tar.gz |
|---|---|
| Size | 33.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
38c88155b7075271755f982bb8ddac5986a01f0a1199abfb10e69d2ef30a07f1
|
|
BLAKE2b-256 checksum How to use checksums |
7a57a0b49798719bb26c2528163a2c016ba46a5fe74aff90aad8f84699d2c38d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / diamondonpy-0.1.1-py3-none-any.whl
| Download URL | diamondonpy-0.1.1-py3-none-any.whl |
|---|---|
| Size | 33.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0bae7fded5d80c5a7b44c13868ee8a245b270b3200419098caf8a906a147397c
|
|
BLAKE2b-256 checksum How to use checksums |
a38210eac9aab14ed0dc2c761e50e9e1b585cd5af393c8256675926665e9227a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Security for diamondonpy 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.