A Python package that converts DNA sequences into 'oiia' sounds.
Project description
DNA2oiia 🧬🎵🐱
DNA2oiia is a Python package that converts DNA/RNA sequences into sound using the "oiia" phonetics. It supports both command-line interface (CLI) and Python API usage, handling DNA input as either raw sequences or FASTA files with single or multiple sequences.
🚀 Getting started
📥 Installation
pip install dna2oiia
Or install from source:
pip install git+https://github.com/ChenHsieh/DNA2oiia.git
Optional extras:
pip install dna2oiia[mp3] # MP3 export support (requires pydub)
pip install dna2oiia[streamlit] # Streamlit web app
🛠️ CLI Usage
Convert a DNA Sequence Directly
dna2oiia -s ATCGGATTA -o my_dna
Convert an RNA Sequence
dna2oiia -s AUCGGAUUA -o my_rna
Convert a FASTA File
dna2oiia -f example.fasta -o fasta_output
If the file contains multiple sequences, output files will be named with header suffixes (e.g., fasta_output_seq1.wav, fasta_output_seq2.wav).
Pipe from stdin
echo "ATCGATCG" | dna2oiia -o piped_output
cat sequence.txt | dna2oiia --play
🎧 Play Audio Directly
dna2oiia -s ATCGGATTA --play
Uses afplay (macOS), aplay (Linux), or PowerShell (Windows).
⏩ Speed Control
dna2oiia -s ATCGATCG --speed 2.0 # Double speed
dna2oiia -s ATCGATCG --speed 0.5 # Half speed
🔁 Repeat
dna2oiia -s ATCG --repeat 4 # Repeat the audio 4 times
🧬 Reverse Complement
dna2oiia -s ATCGGATTA --reverse-complement
Converts to the reverse complement strand before sonification (A↔T, C↔G, U→A).
🎵 MP3 Output
dna2oiia -s ATCGGATTA --format mp3
Requires pydub: pip install dna2oiia[mp3]
🔥 Streaming Mode
dna2oiia -s ATCGGATTA --stream
Outputs audio as an in-memory stream instead of writing to disk.
🧑💻 Python API Usage
Convert a Single Sequence
from dna2oiia import dna_to_oiia
dna_to_oiia({"example": "ATCGGATTA"}, "output") # Creates output.wav
Convert a FASTA File
from dna2oiia import dna_to_oiia, process_fasta
sequences = process_fasta("example.fasta")
dna_to_oiia(sequences, "output")
Stream Audio to a Buffer
import io
from dna2oiia import dna_to_oiia
buf = io.BytesIO()
dna_to_oiia({"example": "ATCGGATTA"}, output_buffer=buf)
# buf now contains WAV data, seeked to start
Speed and Repeat
from dna2oiia import dna_to_oiia
dna_to_oiia({"fast": "ATCGATCG"}, "fast_output", speed=2.0, repeat=3)
Reverse Complement
from dna2oiia import reverse_complement
rc = reverse_complement("ATCG") # "CGAT"
Validate a Sequence
from dna2oiia import validate_dna_sequence, InvalidDNASequenceError
validated = validate_dna_sequence("atcgu") # Returns "ATCGU"
try:
validate_dna_sequence("HELLO")
except InvalidDNASequenceError as e:
print(e) # Invalid characters: E, H, L, O
🌐 Streamlit Web App
Run an interactive web app to convert DNA/RNA sequences to audio:
pip install dna2oiia[streamlit]
streamlit run st_dna2oiia.py
Features:
- Paste a sequence or upload a FASTA file
- Adjust playback speed with a slider
- Play and download generated audio
🎉 Acknowledgments
This project was inspired by a conversation with my IOB friends Nathan and Ibukun during a hackathon trip. Their creative thinking sparked the idea of transforming DNA sequences into sound. Huge thanks for the inspiration!
🎶 Audio Source Attribution
The "oiia" sound used in this project was sourced from the following YouTube video:
The meme itself originates from viral internet content. This project does not claim ownership of the original meme audio but uses it under fair use for creative and educational purposes.
🤖 AI Assistance
This project was developed with assistance from AI tools to improve code structure, refine documentation, and troubleshoot issues.
📜 License
This project is licensed under the MIT License.
🤝 Contributing
Contributions are welcome! Feel free to open issues and pull requests.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dna2oiia-0.1.0.tar.gz.
File metadata
- Download URL: dna2oiia-0.1.0.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aeb6174db0be74d54c8994750ff0b7973a76cae2d49ede0f640bb9030ba3e2bb
|
|
| MD5 |
898bbfa849e0ab98f47518b19a6d34a1
|
|
| BLAKE2b-256 |
79cfe8d7a4432ec3f21a51f2499d0f5c50074b89ce49965b48a21bd1522c37cb
|
Provenance
The following attestation bundles were made for dna2oiia-0.1.0.tar.gz:
Publisher:
publish.yml on ChenHsieh/dna2oiia
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dna2oiia-0.1.0.tar.gz -
Subject digest:
aeb6174db0be74d54c8994750ff0b7973a76cae2d49ede0f640bb9030ba3e2bb - Sigstore transparency entry: 1276460114
- Sigstore integration time:
-
Permalink:
ChenHsieh/dna2oiia@b8e706ef83d55e58b373c9b8686ed27cc381693e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ChenHsieh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b8e706ef83d55e58b373c9b8686ed27cc381693e -
Trigger Event:
release
-
Statement type:
File details
Details for the file dna2oiia-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dna2oiia-0.1.0-py3-none-any.whl
- Upload date:
- Size: 1.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d27969452729e2068abc660bfb70bd7616386d616ddbbda84fc5536cd7fb9dd
|
|
| MD5 |
3c3f1cbedd3d31e9ec92969a55c85d5d
|
|
| BLAKE2b-256 |
95aa67f745c486ac269d094a4a88150e6f6422d0070d9fa87f407645cd589278
|
Provenance
The following attestation bundles were made for dna2oiia-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on ChenHsieh/dna2oiia
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dna2oiia-0.1.0-py3-none-any.whl -
Subject digest:
8d27969452729e2068abc660bfb70bd7616386d616ddbbda84fc5536cd7fb9dd - Sigstore transparency entry: 1276460226
- Sigstore integration time:
-
Permalink:
ChenHsieh/dna2oiia@b8e706ef83d55e58b373c9b8686ed27cc381693e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ChenHsieh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b8e706ef83d55e58b373c9b8686ed27cc381693e -
Trigger Event:
release
-
Statement type: