--- id: pyfaidx version: "0.9.0.4" license: BSD-3-Clause license_treatment: permissive maintenance: active --- # pyfaidx — pyfaidx: efficient pythonic random access to fasta subsequences License: permissive · Maintenance: active · Downloads: 529.9K/mo ## What it is and what it does pyfaidx is a pure Python implementation of samtools' faidx functionality, enabling efficient random access to any subsequence in a FASTA file without loading the entire file into memory. It creates a small flat index file (.fai) that allows seeking directly to the sequence you need. The package provides both a Python API (with dictionary-like and method-based access) and a command-line tool for FASTA manipulation without programming. The library supports slicing, reverse complements, spliced sequences, and coordinate transformations (1-based and 0-based). It works with sequences indexed by name or position, handles custom key functions for flexible naming schemes, and can filter sequences during indexing. The API is compatible with pygr's seqdb module, making it a drop-in replacement for existing bioinformatics workflows. Use it for: - Extract specific genomic regions from reference genomes for variant analysis or annotation pipelines. - Build sequence databases for rapid lookup of genes or transcripts by identifier without full file loads. - Perform reverse-complement operations on DNA sequences for primer design or alignment validation. - Slice and manipulate FASTA sequences programmatically in Python-based bioinformatics workflows. - Use the faidx command-line tool to extract or modify FASTA records without writing custom scripts. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides fast random access to subsequences in FASTA files using a samtools-compatible index, with a pure Python implementation for indexing, retrieval, and in-place modification. Yes. pyfaidx is production-stable, actively maintained, has no known vulnerabilities, and solves a real problem in bioinformatics workflows. Low install friction and permissive licensing make it a straightforward choice for anyone working with FASTA files in Python. ## Install pip install pyfaidx uv add pyfaidx poetry add pyfaidx ## Installing pyfaidx Before you install: Low friction: pure Python with only two lightweight runtime dependencies (importlib_metadata and packaging). Active maintenance with a recent release 148 days ago and 489 repository stars. License in practice: BSD-3-Clause is permissive; you can use this package freely in commercial and proprietary projects with minimal restrictions. Quickstart: pip install pyfaidx from pyfaidx import Fasta genes = Fasta('genes.fasta') seq = genes['sequence_id'][200:230] print(seq.seq) Verify before relying: - Whether the command-line faidx script is reliably available after installation on all supported platforms. - Performance characteristics when working with very large FASTA files or many concurrent accesses. ## Package facts - License: BSD-3-Clause (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 529.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags fasta file random access, faidx index python, sequence retrieval fasta, dna sequence slicing, fasta subsequence extraction, samtools faidx python, genomic sequence indexing, bioinformatics, genomics, fasta-indexing [View on SkillFed](https://skillfed.io/packages/pyfaidx) · [View on PyPI](https://pypi.org/project/pyfaidx/)