Biotite

1.6.0 · active · verified Thu Apr 09

Biotite is a comprehensive Python library (current version 1.6.0) for computational molecular biology, offering a broad set of tools for sequence analysis, structural bioinformatics, and accessing data from biological databases. It leverages NumPy arrays for efficient, high-performance operations and provides seamless interfaces to integrate with external bioinformatics software, allowing users to streamline their analyses from basic scripting to developing full software packages. The library maintains an active development and release schedule, with significant updates in recent years.

Warnings

Install

Imports

Quickstart

Downloads two protein sequences (avidin and streptavidin) from the NCBI Entrez database, parses them from a FASTA file, and performs a pairwise optimal sequence alignment using the BLOSUM62 matrix with affine gap penalties.

import biotite.sequence.align as align
import biotite.sequence.io.fasta as fasta
import biotite.database.entrez as entrez
import os

# Download FASTA file for the sequences of avidin and streptavidin
# The 'file_name' should ideally be a path to a temporary file.
# For a runnable example, we'll use a simple name and ensure cleanup in a real scenario.
file_name = "sequences.fasta"
uids = ["CAC34569", "ACL82594"] # Example UIDs for avidin and streptavidin
entrez.fetch_single_file(
    uids=uids,
    file_name=file_name,
    db_name="protein",
    ret_type="fasta"
)

# Parse the downloaded FASTA file and create 'ProteinSequence' objects
fasta_file = fasta.FastaFile.read(file_name)
avidin_seq, streptavidin_seq = fasta.get_sequences(fasta_file).values()

# Align sequences using the BLOSUM62 matrix with affine gap penalty
matrix = align.SubstitutionMatrix.std_protein_matrix()
alignments = align.align_optimal(
    avidin_seq, streptavidin_seq, matrix,
    gap_penalty=(-10, -1),
    terminal_penalty=False
)

print(f"Number of alignments: {len(alignments)}")
if alignments:
    print("First optimal alignment:")
    print(alignments[0])

# Clean up the downloaded file
os.remove(file_name)

view raw JSON →