$npx -y skills add K-Dense-AI/scientific-agent-skills --skill biopythonComprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for
| 1 | # Biopython: Computational Molecular Biology in Python |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Biopython is a comprehensive set of freely available Python tools for biological computation. It provides functionality for sequence manipulation, file I/O, database access, structural bioinformatics, phylogenetics, and many other bioinformatics tasks. The current version is **Biopython 1.87** (released 30 March 2026). It supports **Python 3.10-3.14** and PyPy3.10, and requires NumPy. Biopython 1.87 also addresses **CVE-2025-68463** in `Bio.Entrez.Parser` when parsing untrusted files, so prefer 1.87+ for workflows that parse externally supplied Entrez XML. |
| 6 | |
| 7 | ## When to Use This Skill |
| 8 | |
| 9 | Use this skill when: |
| 10 | |
| 11 | - Working with biological sequences (DNA, RNA, or protein) |
| 12 | - Reading, writing, or converting biological file formats (FASTA, GenBank, FASTQ, PDB, mmCIF, etc.) |
| 13 | - Accessing NCBI databases (GenBank, PubMed, Protein, Gene, etc.) via Entrez |
| 14 | - Running BLAST searches or parsing BLAST results |
| 15 | - Performing sequence alignments (pairwise or multiple sequence alignments) |
| 16 | - Analyzing protein structures from PDB files |
| 17 | - Creating, manipulating, or visualizing phylogenetic trees |
| 18 | - Finding sequence motifs or analyzing motif patterns |
| 19 | - Calculating sequence statistics (GC content, molecular weight, melting temperature, etc.) |
| 20 | - Performing structural bioinformatics tasks |
| 21 | - Working with population genetics data |
| 22 | - Any other computational molecular biology task |
| 23 | |
| 24 | ## Core Capabilities |
| 25 | |
| 26 | Biopython is organized into modular sub-packages, each addressing specific bioinformatics domains: |
| 27 | |
| 28 | 1. **Sequence Handling** - Bio.Seq and Bio.SeqIO for sequence manipulation and file I/O |
| 29 | 2. **Alignment Analysis** - Bio.Align and Bio.AlignIO for pairwise and multiple sequence alignments |
| 30 | 3. **Database Access** - Bio.Entrez for programmatic access to NCBI databases |
| 31 | 4. **BLAST Operations** - Bio.Blast for running and parsing BLAST searches |
| 32 | 5. **Structural Bioinformatics** - Bio.PDB for working with 3D protein structures |
| 33 | 6. **Phylogenetics** - Bio.Phylo for phylogenetic tree manipulation and visualization |
| 34 | 7. **Advanced Features** - Motifs, population genetics, sequence utilities, and more |
| 35 | |
| 36 | ## Installation and Setup |
| 37 | |
| 38 | Install the current stable Biopython release with an explicit version pin for reproducibility: |
| 39 | |
| 40 | ```bash |
| 41 | uv pip install "biopython==1.87" |
| 42 | ``` |
| 43 | |
| 44 | For NCBI database access, always set your email address (required by NCBI). For reusable software, set a stable `Entrez.tool` value and register the tool/email with NCBI. For higher rate limits (10 req/s instead of 3 req/s), read only `NCBI_API_KEY` from the environment — do not hardcode keys or load unrelated environment variables: |
| 45 | |
| 46 | ```python |
| 47 | import os |
| 48 | from Bio import Entrez |
| 49 | |
| 50 | Entrez.email = "your.email@example.com" # required — use your real email |
| 51 | Entrez.tool = "your_tool_name" # optional but recommended for reusable software |
| 52 | |
| 53 | # Optional: register at https://www.ncbi.nlm.nih.gov/account/settings/ |
| 54 | if api_key := os.environ.get("NCBI_API_KEY"): |
| 55 | Entrez.api_key = api_key |
| 56 | ``` |
| 57 | |
| 58 | ## Using This Skill |
| 59 | |
| 60 | This skill provides comprehensive documentation organized by functionality area. When working on a task, consult the relevant reference documentation: |
| 61 | |
| 62 | ### 1. Sequence Handling (Bio.Seq & Bio.SeqIO) |
| 63 | |
| 64 | **Reference:** `references/sequence_io.md` |
| 65 | |
| 66 | Use for: |
| 67 | - Creating and manipulating biological sequences |
| 68 | - Reading and writing sequence files (FASTA, GenBank, FASTQ, etc.) |
| 69 | - Converting between file formats |
| 70 | - Extracting sequences from large files |
| 71 | - Sequence translation, transcription, and reverse complement |
| 72 | - Working with SeqRecord objects |
| 73 | |
| 74 | **Quick example:** |
| 75 | ```python |
| 76 | from Bio import SeqIO |
| 77 | |
| 78 | # Read sequences from FASTA file |
| 79 | for record in SeqIO.parse("sequences.fasta", "fasta"): |
| 80 | print(f"{record.id} |