Bio
The 'bio' library provides common bioinformatics algorithms and data structures implemented in Python. It is a lightweight alternative to larger bioinformatics packages, focusing on core functionalities like sequence manipulation, alignment, and motif analysis. The current version is 1.8.1, with a release cadence of a few updates per year, mainly for bug fixes and minor feature enhancements.
Warnings
- gotcha The 'bio' library is distinct from 'Biopython'. While both handle bioinformatics, 'bio' is a smaller, more focused library by a different author. Do not confuse their APIs or expect interoperability without explicit conversion.
- gotcha Sequence objects (e.g., `bio.seq.Seq`) are immutable. Methods like `.rc()`, `.transcribe()`, or `.translate()` return *new* `Seq` objects rather than modifying the original in-place. Always assign the result of these methods to a new variable.
- breaking The 'bio' library requires Python 3.10 or newer. Attempting to install or run it on older Python versions (e.g., Python 3.9 or earlier) will result in installation failures or runtime errors.
Install
-
pip install bio
Imports
- Seq
from bio import seq; s = seq.Seq(...)
- global_alignment
from bio import align; aln = align.global_alignment(...)
- motifs
from bio import motifs
Quickstart
from bio import seq
# Create a DNA sequence object
dna_sequence = seq.Seq("ATGATCCAGGGC", seq.DNA)
# Get the reverse complement
reverse_complement = dna_sequence.rc()
print(f"Original DNA: {dna_sequence}")
print(f"Reverse complement: {reverse_complement}")
# Get the RNA transcription
rna_sequence = dna_sequence.transcribe()
print(f"RNA: {rna_sequence}")
# Translate to protein (starts from first codon)
protein_sequence = rna_sequence.translate()
print(f"Protein: {protein_sequence}")