[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73HXE5K1X8P9GKG2EAVCBJA":3,"skill-same:01M73HXE5K1X8P9GKG2EAVCBJA":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M73HXE5K1X8P9GKG2EAVCBJA","prokka-genome-annotation",null,"Annotate prokaryotic genomes (bacteria, archaea, viruses) via Prokka's BLAST\u002FHMM pipeline. Identifies CDS, rRNA, tRNA, tmRNA, signal peptides against Pfam, TIGRFAMs, RefSeq. Outputs GFF3, GenBank, FASTA, TSV. Use PGAP for NCBI GenBank submission; Bakta for faster NCBI-compatible annotation.","bg-szy\u002FTOP-SKILLS","bg-szy","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F106576190?v=4","01M73A4E8KPV67SFXRY8XZGNBX","ShuZhiyong","01M73A4E96MQ294MHM74TZBVQD",6,"GPL-3.0","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fawesome-skills\u002Fprokka-genome-annotation\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: \"prokka-genome-annotation\"\ndescription: \"Annotate prokaryotic genomes (bacteria, archaea, viruses) via Prokka's BLAST\u002FHMM pipeline. Identifies CDS, rRNA, tRNA, tmRNA, signal peptides against Pfam, TIGRFAMs, RefSeq. Outputs GFF3, GenBank, FASTA, TSV. Use PGAP for NCBI GenBank submission; Bakta for faster NCBI-compatible annotation.\"\nlicense: \"GPL-3.0\"\n---\n\n# Prokka Genome Annotation\n\n## Overview\n\nProkka is a command-line pipeline for rapid annotation of prokaryotic genomes (bacteria, archaea, and viruses). It uses a tiered search strategy: protein-coding genes (CDS) are predicted with Prodigal and searched first against a genus-specific database, then RefSeq proteins, then Pfam\u002FTIGRFAMs HMMs. Non-coding RNA genes (rRNA, tRNA, tmRNA) are identified with Barrnap, Aragorn, and Infernal. Prokka processes a single FASTA assembly in minutes and outputs a comprehensive annotation in GFF3, GenBank, FASTA, and tabular formats.\n\n## When to Use\n\n- Annotating a newly assembled bacterial or archaeal genome from Illumina, PacBio, or Nanopore assemblies\n- Getting functional protein annotations (CDS with product names, EC numbers, GO terms) from a draft or complete genome\n- Preparing annotation files for downstream comparative genomics (Roary pan-genome, OrthoFinder)\n- Annotating viral or phage genomes when kingdom-specific databases are important\n- Performing metagenome-assembled genome (MAG) annotation with the `--metagenome` flag\n- Parsing annotated outputs in Python with BioPython for downstream sequence or feature analysis\n- Use **PGAP** (NCBI Prokaryotic Genome Annotation Pipeline) instead when the goal is NCBI GenBank submission with standards compliance\n- Use **Bakta** instead for faster annotation with built-in NCBI-compatible outputs and a more regularly updated database\n\n## Prerequisites\n\n- **Software**: Prokka ≥ 1.14, Perl 5, Prodigal, Barrnap, HMMER3, BLAST+, Aragorn, Infernal, tbl2asn\n- **Python packages** (for output parsing): `biopython`, `pandas`, `matplotlib`\n- **Input**: assembled genome in FASTA format (complete or draft with multiple contigs)\n- **Environment**: conda strongly recommended to handle the Perl and C dependency stack\n\n> **Check before installing**: The tool may already be available in the current environment (e.g., inside a `pixi` \u002F `conda` env). Run `command -v prokka` first and skip the install commands below if it returns a path. When running inside a pixi project, invoke the tool via `pixi run prokka` rather than bare `prokka`.\n\n```bash\n# Install Prokka via conda\u002Fmamba (recommended)\nconda install -c conda-forge -c bioconda prokka\n\n# Or with mamba (faster)\nmamba install -c conda-forge -c bioconda prokka\n\n# Verify installation and database setup\nprokka --version\n# prokka 1.14.6\n\n# Check that required tools are on PATH\nprokka --depends\n# prokka needs: awk, sed, grep, makeblastdb, blastp, hmmscan, ...\n\n# Install Python parsing dependencies\npip install biopython pandas matplotlib\n```\n\n## Pre-flight Interview\n\nSettle these with the user before writing any analysis code.\n\n```yaml\ndecisions:\n  - id: D1\n    param: kingdom\n    kind: required\n    source: user\n    ask: \"Is this a bacterial, archaeal, viral, or mitochondrial assembly?\"\n    default: \"Bacteria\"\n\n  - id: D2\n    param: organismMetadata\n    kind: required\n    source: user\n    ask: \"Which genus, species, and strain should be recorded, and used to prioritise a genus-specific protein database?\"\n    default: null\n\n  - id: D3\n    param: assemblyOrigin\n    kind: required\n    source: data\n    ask: \"Is this an isolate genome, or a bin recovered from a metagenome?\"\n    default: \"isolate - gene prediction trains on the assembly itself\"\n\n  - id: D4\n    param: rnaPrediction\n    kind: optional\n    source: user\n    ask: \"Should rRNA, tRNA, and other non-coding RNA be predicted alongside coding genes?\"\n    default: \"tRNA and rRNA predicted; Rfam search off as it is slow\"\n\n  - id: D5\n    param: customProteins\n    kind: optional\n    source: user\n    ask: \"Is there a curated protein set that should be searched before the general reference database?\"\n    default: \"none\"\n\n  - id: D6\n    param: hitEvalue\n    kind: optional\n    source: user\n    ask: \"How confident must a database hit be before it names a gene?\"\n    default: \"1e-6\"\n\n  - id: D7\n    param: minContigLength\n    kind: optional_conditional\n    source: data\n    ask: \"Should short contigs be skipped - and does the assembly have enough of them to matter?\"\n    default: \"no minimum\"\n\n  - id: D8\n    param: cpus\n    kind: never_ask\n    source: data\n    reason: \"Affects runtime only, not the annotation\"\n    default: \"min(8, available_cores)\"\n```\n\nD3 changes how genes are predicted rather than how they are named. Prodigal\ntrains its model on the input; a metagenomic bin holding more than one organism\ntrains a blended model, and the resulting gene boundaries are wrong in a way\nthat no downstream step flags.\n\n## Quick Start\n\n```bash\n# Annotate a bacterial genome assembly — results in results\u002F directory\nprokka genome.fasta \\\n    --outdir results\u002F \\\n    --prefix sample1 \\\n    --kingdom Bacteria \\\n    --cpus 4\n\n# Check output summary\ncat results\u002Fsample1.txt\n# Organism: Genus species strain\n# Contigs: 1\n# Bases: 4639675\n# CDS: 4140\n# rRNA: 22\n# tRNA: 86\n\necho \"Annotation complete. Key output files:\"\nls results\u002Fsample1.{gff,gbk,faa,ffn,tsv}\n```\n\n## Workflow\n\n### Step 1: Install and Verify Prokka\n\nInstall Prokka and confirm all dependent tools are accessible in the current environment.\n\n```bash\n# Create a dedicated conda environment\nconda create -n prokka_env -c conda-forge -c bioconda prokka python=3.10 -y\nconda activate prokka_env\n\n# Verify Prokka version and all tool dependencies\nprokka --version\n# prokka 1.14.6\n\nprokka --depends\n# Checking that required tools are installed...\n# OK: makeblastdb is installed (2.13.0+)\n# OK: blastp is installed (2.13.0+)\n# OK: hmmscan is installed (3.3.2)\n# OK: prodigal is installed (2.6.3)\n# OK: barrnap is installed (0.9)\n\n# Check available genus-specific databases bundled with Prokka\nls $(conda info --base)\u002Fenvs\u002Fprokka_env\u002Fdb\u002Fgenus\u002F\n# Archaea  Bacteria  Mitochondria  Viruses\n\n# Install Python parsing tools\npip install biopython pandas matplotlib\n```\n\n### Step 2: Prepare the Input Genome\n\nClean and rename contigs to comply with Prokka's header requirements before annotation.\n\n```python\nfrom Bio import SeqIO\nimport re\n\n# Load and inspect assembly\ninput_fasta = \"genome.fasta\"\nrecords = list(SeqIO.parse(input_fasta, \"fasta\"))\nprint(f\"Input assembly: {len(records)} contigs\")\ntotal_bases = sum(len(r) for r in records)\nprint(f\"Total bases: {total_bases:,}\")\nprint(f\"Largest contig: {max(len(r) for r in records):,} bp\")\nprint(f\"N50 approx: see assembly stats tool\")\n\n# Rename contigs to short IDs compatible with Prokka (max 37 chars)\n# Prokka requires: no spaces, no special characters in header\ncleaned = []\nfor i, rec in enumerate(records, 1):\n    new_id = f\"contig_{i:04d}\"\n    new_rec = rec.__class__(rec.seq, id=new_id, description=f\"len={len(rec.seq)}\")\n    cleaned.append(new_rec)\n\nSeqIO.write(cleaned, \"genome_clean.fasta\", \"fasta\")\nprint(f\"\\nWrote genome_clean.fasta with {len(cleaned)} renamed contigs\")\n# genome_clean.fasta: contig_0001 through contig_NNNN\n```\n\n```bash\n# Alternatively, clean headers with a simple bash one-liner\nawk '\u002F^>\u002F{print \">contig_\" ++i; next}{print}' genome.fasta > genome_clean.fasta\n\n# Filter out short contigs (\u003C 200 bp) to reduce annotation noise\nawk '\u002F^>\u002F{header=$0; next} length($0) >= 200 {print header; print}' \\\n    genome_clean.fasta > genome_filtered.fasta\n\necho \"Filtered assembly ready: $(grep -c '>' genome_filtered.fasta) contigs\"\n```\n\n### Step 3: Run Basic Prokka Annotation\n\nRun Prokka with standard options for a bacterial genome, specifying genus\u002Fspecies for database selection.\n\n```bash\n# Basic annotation with genus\u002Fspecies hint (uses genus-specific protein database first)\nprokka genome_clean.fasta \\\n    --outdir annotation\u002F \\\n    --prefix E_coli_K12 \\\n    --kingdom Bacteria \\\n    --genus Escherichia \\\n    --species coli \\\n    --strain K12 \\\n    --cpus 8 \\\n    --mincontiglen 200\n\n# Expected runtime: 2–10 minutes for a typical 4–6 Mb bacterial genome\n\necho \"Prokka annotation output files:\"\nls annotation\u002F\n# E_coli_K12.err   E_coli_K12.faa   E_coli_K12.ffn\n# E_coli_K12.fna   E_coli_K12.gbk   E_coli_K12.gff\n# E_coli_K12.log   E_coli_K12.sqn   E_coli_K12.tbl\n# E_coli_K12.tsv   E_coli_K12.txt\n```\n\n### Step 4: Parse Annotation Summary (TSV)\n\nLoad the TSV output for a quick overview of annotated features and their functional assignments.\n\n```python\nimport pandas as pd\n\n# Load the annotation TSV (tab-delimited feature table)\ntsv_file = \"annotation\u002FE_coli_K12.tsv\"\ndf = pd.read_csv(tsv_file, sep=\"\\t\")\nprint(f\"Total features: {len(df)}\")\nprint(f\"Columns: {list(df.columns)}\")\n# Columns: [locus_tag, ftype, length_bp, gene, EC_number, COG, product]\n\n# Feature type summary\nprint(\"\\nFeature type counts:\")\nprint(df[\"ftype\"].value_counts().to_string())\n# CDS     4140\n# tRNA      86\n# rRNA      22\n# tmRNA      1\n\n# Functional gene annotations (non-hypothetical CDS)\ncds_df = df[df[\"ftype\"] == \"CDS\"].copy()\nhypothetical = cds_df[\"product\"].str.contains(\"hypothetical\", case=False, na=True)\nprint(f\"\\nCDS with known function: {(~hypothetical).sum()}\")\nprint(f\"Hypothetical proteins: {hypothetical.sum()}\")\n\n# Genes with EC numbers (enzymes)\nec_annotated = cds_df[cds_df[\"EC_number\"].notna() & (cds_df[\"EC_number\"] != \"\")]\nprint(f\"CDS with EC numbers: {len(ec_annotated)}\")\nprint(ec_annotated[[\"locus_tag\", \"gene\", \"EC_number\", \"product\"]].head(5).to_string(index=False))\n```\n\n### Step 5: Parse GenBank Output with BioPython\n\nRead the GenBank file to access per-gene sequences, qualifiers, and feature coordinates.\n\n```python\nfrom Bio import SeqIO\nimport pandas as pd\n\n# Parse GenBank file\ngbk_file = \"annotation\u002FE_coli_K12.gbk\"\nrecords = list(SeqIO.parse(gbk_file, \"genbank\"))\nprint(f\"Contigs in GenBank: {len(records)}\")\n\n# Iterate over CDS features and extract details\nrows = []\nfor rec in records:\n    for feat in rec.features:\n        if feat.type != \"CDS\":\n            continue\n        qualifiers = feat.qualifiers\n        rows.append({\n            \"contig\":      rec.id,\n            \"locus_tag\":   qualifiers.get(\"locus_tag\", [\"?\"])[0],\n            \"gene\":        qualifiers.get(\"gene\", [\"\"])[0],\n            \"product\":     qualifiers.get(\"product\", [\"hypothetical protein\"])[0],\n            \"EC_number\":   qualifiers.get(\"EC_number\", [\"\"])[0],\n            \"protein_id\":  qualifiers.get(\"protein_id\", [\"\"])[0],\n            \"start\":       int(feat.location.start),\n            \"end\":         int(feat.location.end),\n            \"strand\":      feat.location.strand,\n            \"aa_length\":   len(qualifiers.get(\"translation\", [\"\"])[0]),\n        })\n\nfeatures_df = pd.DataFrame(rows)\nprint(f\"CDS features extracted: {len(features_df)}\")\nprint(features_df.head(3).to_string(index=False))\n\n# Retrieve protein sequence for a specific gene\ngene_name = \"dnaA\"\ngene_feat = features_df[features_df[\"gene\"] == gene_name]\nif not gene_feat.empty:\n    idx = gene_feat.index[0]\n    print(f\"\\n{gene_name}: {features_df.loc[idx, 'aa_length']} aa\")\n```\n\n### Step 6: Visualize Annotation Statistics\n\nGenerate a summary barplot of feature types and functional annotation coverage.\n\n```python\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\n\ntsv_file = \"annotation\u002FE_coli_K12.tsv\"\ndf = pd.read_csv(tsv_file, sep=\"\\t\")\n\ncds = df[df[\"ftype\"] == \"CDS\"].copy()\nn_cds = len(cds)\nn_known = (~cds[\"product\"].str.contains(\"hypothetical\", case=False, na=True)).sum()\nn_hypo = n_cds - n_known\nn_ec = cds[\"EC_number\"].notna().sum()\nn_rrna = (df[\"ftype\"] == \"rRNA\").sum()\nn_trna = (df[\"ftype\"] == \"tRNA\").sum()\n\nfig, axes = plt.subplots(1, 2, figsize=(11, 4))\n\n# Left panel: feature type counts\ntypes = df[\"ftype\"].value_counts()\ncolors_left = [\"#2980B9\", \"#27AE60\", \"#E74C3C\", \"#F39C12\"] + [\"#95A5A6\"] * len(types)\naxes[0].bar(types.index, types.values, color=colors_left[:len(types)], edgecolor=\"white\")\naxes[0].set_title(\"Annotated Feature Counts\")\naxes[0].set_xlabel(\"Feature Type\")\naxes[0].set_ylabel(\"Count\")\nfor i, (label, val) in enumerate(types.items()):\n    axes[0].text(i, val + 5, str(val), ha=\"center\", fontsize=9)\n\n# Right panel: CDS functional annotation breakdown\nlabels = [\"Known function\", \"Hypothetical protein\", \"Enzyme (EC number)\"]\nsizes  = [n_known, n_hypo, n_ec]\ncolors_right = [\"#2980B9\", \"#BDC3C7\", \"#E74C3C\"]\nbars = axes[1].bar(labels, sizes, color=colors_right, edgecolor=\"white\")\naxes[1].set_title(f\"CDS Functional Annotation\\n(n={n_cds} total CDS)\")\naxes[1].set_ylabel(\"Count\")\naxes[1].tick_params(axis=\"x\", rotation=15)\nfor bar, val in zip(bars, sizes):\n    axes[1].text(bar.get_x() + bar.get_width() \u002F 2,\n                 val + 10, str(val), ha=\"center\", fontsize=9)\n\nplt.suptitle(\"Prokka Genome Annotation Summary\", fontsize=12, fontweight=\"bold\")\nplt.tight_layout()\nplt.savefig(\"prokka_annotation_summary.png\", dpi=150, bbox_inches=\"tight\")\nprint(f\"Saved prokka_annotation_summary.png\")\nprint(f\"CDS: {n_cds}  |  Known function: {n_known}  |  Hypothetical: {n_hypo}\")\nprint(f\"rRNA: {n_rrna}  |  tRNA: {n_trna}  |  EC-annotated CDS: {n_ec}\")\n```\n\n### Step 7: Batch Annotation Across Multiple Genomes\n\nAnnotate multiple genome assemblies sequentially and collect summary statistics.\n\n```bash\n#!\u002Fbin\u002Fbash\n# batch_prokka.sh — annotate all FASTA files in a directory\n\nINPUT_DIR=\"genomes\u002F\"\nOUTPUT_DIR=\"annotations\u002F\"\nmkdir -p \"$OUTPUT_DIR\"\n\nfor FASTA in \"$INPUT_DIR\"\u002F*.fasta; do\n    SAMPLE=$(basename \"$FASTA\" .fasta)\n    echo \"Annotating: $SAMPLE\"\n    prokka \"$FASTA\" \\\n        --outdir \"${OUTPUT_DIR}\u002F${SAMPLE}\" \\\n        --prefix \"$SAMPLE\" \\\n        --kingdom Bacteria \\\n        --cpus 4 \\\n        --mincontiglen 200 \\\n        --quiet\n    echo \"  Done: ${OUTPUT_DIR}\u002F${SAMPLE}\u002F${SAMPLE}.txt\"\ndone\n\necho \"Batch annotation complete.\"\n```\n\n```python\n# Collect summary statistics from all Prokka .txt files\nfrom pathlib import Path\nimport pandas as pd\n\nannotation_dir = Path(\"annotations\u002F\")\nrows = []\n\nfor txt_file in sorted(annotation_dir.glob(\"*\u002F*.txt\")):\n    sample = txt_file.stem\n    stats = {}\n    with open(txt_file) as f:\n        for line in f:\n            line = line.strip()\n            if \": \" in line:\n                key, val = line.split(\": \", 1)\n                stats[key.strip()] = val.strip()\n    rows.append({\n        \"sample\":   sample,\n        \"contigs\":  int(stats.get(\"Contigs\", 0)),\n        \"bases\":    int(stats.get(\"Bases\", 0)),\n        \"CDS\":      int(stats.get(\"CDS\", 0)),\n        \"rRNA\":     int(stats.get(\"rRNA\", 0)),\n        \"tRNA\":     int(stats.get(\"tRNA\", 0)),\n    })\n\nsummary_df = pd.DataFrame(rows)\nprint(f\"Annotated genomes: {len(summary_df)}\")\nprint(summary_df.to_string(index=False))\nsummary_df.to_csv(\"batch_annotation_summary.csv\", index=False)\nprint(\"\\nSaved: batch_annotation_summary.csv\")\n```\n\n### Step 8: Compare Annotations Between Strains\n\nUse the protein FASTA outputs for cross-strain comparison with identity-based clustering.\n\n```python\nfrom Bio import SeqIO, pairwise2\nimport pandas as pd\n\n# Load protein sequences from two strains\ndef load_proteins(faa_file):\n    \"\"\"Return dict of locus_tag -> protein sequence.\"\"\"\n    return {rec.id: str(rec.seq)\n            for rec in SeqIO.parse(faa_file, \"fasta\")}\n\nstrain_a = load_proteins(\"annotation_A\u002Fstrain_A.faa\")\nstrain_b = load_proteins(\"annotation_B\u002Fstrain_B.faa\")\n\nprint(f\"Strain A proteins: {len(strain_a)}\")\nprint(f\"Strain B proteins: {len(strain_b)}\")\n\n# Compare gene counts and size distributions\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nlen_a = [len(seq) for seq in strain_a.values()]\nlen_b = [len(seq) for seq in strain_b.values()]\n\nfig, ax = plt.subplots(figsize=(8, 4))\nbins = np.linspace(0, 1500, 50)\nax.hist(len_a, bins=bins, alpha=0.6, label=f\"Strain A (n={len(len_a)})\", color=\"#2980B9\")\nax.hist(len_b, bins=bins, alpha=0.6, label=f\"Strain B (n={len(len_b)})\", color=\"#E74C3C\")\nax.set_xlabel(\"Protein Length (aa)\")\nax.set_ylabel(\"Count\")\nax.set_title(\"Protein Length Distribution by Strain\")\nax.legend()\nplt.tight_layout()\nplt.savefig(\"strain_protein_length_comparison.png\", dpi=150, bbox_inches=\"tight\")\nprint(\"Saved strain_protein_length_comparison.png\")\n\n# Find proteins unique to each strain by size\u002Fcount difference\nprint(f\"\\nSize difference: {abs(len(strain_a) - len(strain_b))} proteins\")\nprint(\"→ Use Roary or OrthoFinder for formal pan-genome analysis\")\n```\n\n## Key Parameters\n\n| Parameter | Default | Range \u002F Options | Effect |\n|-----------|---------|-----------------|--------|\n| `--kingdom` | `Bacteria` | `Bacteria`, `Archaea`, `Viruses`, `Mitochondria` | Selects gene prediction model and default databases |\n| `--genus` | — | any genus name string | Prioritizes genus-specific protein database for CDS annotation |\n| `--species` | — | any species name string | Combined with `--genus` for locus_tag prefix and organism metadata |\n| `--strain` | — | any string | Added to organism metadata in GenBank output |\n| `--proteins` | — | path to FASTA file | Custom protein database prepended before RefSeq search |\n| `--hmms` | — | path to HMM file | Additional custom HMM database for specialized annotation |\n| `--evalue` | `1e-6` | `1e-4`–`1e-9` | E-value cutoff for BLAST and HMMER hits |\n| `--cpus` | `8` | `1`–CPU count | Parallel processes for BLAST and HMMER searches |\n| `--mincontiglen` | `1` | any integer | Skip contigs shorter than this length (bp) |\n| `--metagenome` | off | flag | Disables Prodigal training on this genome (for MAGs) |\n| `--rfam` | off | flag | Enable Infernal rRNA\u002FncRNA search against Rfam (slower) |\n| `--norrna` | off | flag | Skip rRNA prediction (use when assembly has no rRNA genes) |\n| `--notrna` | off | flag | Skip tRNA prediction |\n\n## Common Recipes\n\n### Recipe: Annotation with Custom Protein Database\n\nWhen to use: You have closely related reference proteins (e.g., characterized isolate) to improve annotation accuracy.\n\n```bash\n# Use a custom protein database to enhance annotation of a novel strain\n# Custom proteins are searched first, before internal Prokka databases\nprokka genome.fasta \\\n    --proteins reference_proteins.faa \\\n    --outdir custom_annotation\u002F \\\n    --prefix novel_strain \\\n    --kingdom Bacteria \\\n    --cpus 4\n\necho \"Custom DB annotation complete:\"\ngrep \"CDS\" custom_annotation\u002Fnovel_strain.txt\n```\n\n### Recipe: Metagenome-Assembled Genome (MAG) Annotation\n\nWhen to use: Annotating a MAG where Prodigal cannot train on the full genome sequence.\n\n```bash\n# --metagenome disables Prodigal model training (uses meta mode)\n# --mincontiglen 500 discards short, potentially chimeric contigs\nprokka MAG_bin_42.fasta \\\n    --metagenome \\\n    --kingdom Bacteria \\\n    --outdir mag_annotation\u002F \\\n    --prefix MAG_bin_42 \\\n    --mincontiglen 500 \\\n    --cpus 4\n\necho \"MAG annotation complete:\"\ncat mag_annotation\u002FMAG_bin_42.txt\n```\n\n### Recipe: Extract Specific Gene Sequences\n\nWhen to use: Retrieve nucleotide or protein sequences for a target gene or pathway from the annotation.\n\n```python\nfrom Bio import SeqIO\n\n# Extract all sequences for a specific gene name from protein FASTA\nfaa_file = \"annotation\u002FE_coli_K12.faa\"\ntarget_gene = \"dnaA\"\n\nmatches = []\nfor rec in SeqIO.parse(faa_file, \"fasta\"):\n    # Prokka FASTA header: >locus_tag gene product\n    if target_gene in rec.description:\n        matches.append(rec)\n\nprint(f\"Proteins matching '{target_gene}': {len(matches)}\")\nfor rec in matches:\n    print(f\"  {rec.id}: {len(rec.seq)} aa — {rec.description}\")\n\n# Save matching sequences\nif matches:\n    SeqIO.write(matches, f\"{target_gene}_proteins.faa\", \"fasta\")\n    print(f\"Saved: {target_gene}_proteins.faa\")\n```\n\n### Recipe: Convert GFF to Pandas DataFrame\n\nWhen to use: Work with genomic coordinates for feature overlap analysis or visualization.\n\n```python\nimport pandas as pd\n\ndef parse_gff(gff_file):\n    \"\"\"Parse Prokka GFF3 file into a DataFrame (skips sequence section).\"\"\"\n    rows = []\n    with open(gff_file) as f:\n        for line in f:\n            if line.startswith(\"##FASTA\"):\n                break\n            if line.startswith(\"#\") or not line.strip():\n                continue\n            parts = line.rstrip(\"\\n\").split(\"\\t\")\n            if len(parts) \u003C 9:\n                continue\n            attr_dict = {}\n            for item in parts[8].split(\";\"):\n                if \"=\" in item:\n                    k, v = item.split(\"=\", 1)\n                    attr_dict[k] = v\n            rows.append({\n                \"seqname\":  parts[0],\n                \"source\":   parts[1],\n                \"feature\":  parts[2],\n                \"start\":    int(parts[3]),\n                \"end\":      int(parts[4]),\n                \"score\":    parts[5],\n                \"strand\":   parts[6],\n                \"frame\":    parts[7],\n                \"locus_tag\": attr_dict.get(\"ID\", \"\"),\n                \"gene\":     attr_dict.get(\"gene\", \"\"),\n                \"product\":  attr_dict.get(\"product\", \"\"),\n            })\n    return pd.DataFrame(rows)\n\ngff_df = parse_gff(\"annotation\u002FE_coli_K12.gff\")\nprint(f\"GFF features: {len(gff_df)}\")\nprint(gff_df[gff_df[\"feature\"] == \"CDS\"].head(5)[\n    [\"seqname\", \"start\", \"end\", \"strand\", \"gene\", \"product\"]\n].to_string(index=False))\n```\n\n## Expected Outputs\n\n| Output File | Format | Description |\n|-------------|--------|-------------|\n| `{prefix}.gff` | GFF3 | Genome annotation with feature coordinates and attributes; includes FASTA sequence at the end |\n| `{prefix}.gbk` | GenBank | Full GenBank-format annotation for use in Geneious, BioPython, and submission prep |\n| `{prefix}.faa` | FASTA | Predicted protein sequences for all CDS features |\n| `{prefix}.ffn` | FASTA | Nucleotide sequences for all annotated features (CDS, rRNA, tRNA) |\n| `{prefix}.fna` | FASTA | Nucleotide FASTA of the complete assembly (contigs) |\n| `{prefix}.tsv` | TSV | Tab-delimited summary table: locus_tag, ftype, length_bp, gene, EC_number, COG, product |\n| `{prefix}.txt` | Text | One-line summary counts: Contigs, Bases, CDS, rRNA, tRNA, tmRNA |\n| `{prefix}.tbl` | TBL | Feature table format for tbl2asn GenBank submission |\n| `{prefix}.sqn` | SQN | ASN.1 format for NCBI submission (generated by tbl2asn) |\n| `{prefix}.err` | Text | Warnings and errors from tbl2asn validation step |\n| `{prefix}.log` | Text | Full Prokka run log with timing per step |\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| `FATAL: Can't find any tRNA genes` | No tRNA detected on short or highly fragmented assembly | Add `--notrna` flag; check if assembly is too fragmented (N50 \u003C 1 kb) |\n| `Can't exec \"makeblastdb\"` | BLAST+ not on PATH | `conda install -c bioconda blast`; ensure prokka env is activated |\n| `Contig ID too long (>37 chars)` | Assembler produced long contig headers | Pre-process FASTA to shorten headers: `awk '\u002F^>\u002F{print \">contig_\"++i; next}{print}'` |\n| Very high hypothetical protein rate (>60%) | Divergent organism with few database matches | Add `--proteins` with closely related strain FAA; consider `--genus` flag |\n| `ERROR: Argument --proteins: file does not exist` | Path to custom protein file is incorrect | Use absolute path; verify file exists with `ls -la custom.faa` |\n| `tbl2asn error: multiple \u002Fproduct` | Duplicate product qualifiers in annotation | Ignore if exporting for local use; for NCBI submission, use PGAP instead |\n| Annotation is very slow (>30 min for ~5 Mb) | `--cpus` not set or set to 1; `--rfam` enabled | Set `--cpus` to available thread count; disable `--rfam` for faster runs |\n| rRNA count is 0 for complete genome | `--norrna` flag was set, or barrnap threshold too strict | Remove `--norrna`; check barrnap is installed with `barrnap --version` |\n\n## References\n\n- [Prokka GitHub: tseemann\u002Fprokka](https:\u002F\u002Fgithub.com\u002Ftseemann\u002Fprokka) — source code, installation instructions, and detailed parameter reference\n- [Seemann T (2014) Bioinformatics 30(14):2068–2069](https:\u002F\u002Fdoi.org\u002F10.1093\u002Fbioinformatics\u002Fbtu153) — original Prokka paper with benchmarks vs. RAST\n- [Prodigal documentation](https:\u002F\u002Fgithub.com\u002Fhyattpd\u002FProdigal\u002Fwiki) — gene prediction engine used by Prokka for CDS calling\n- [Barrnap GitHub: tseemann\u002Fbarrnap](https:\u002F\u002Fgithub.com\u002Ftseemann\u002Fbarrnap) — rRNA prediction tool bundled with Prokka\n- [BioPython GenBank parsing tutorial](https:\u002F\u002Fbiopython.org\u002Fwiki\u002FSeqIO) — reference for parsing Prokka GenBank output in Python\n","# Prokka Genome Annotation\n\n## Overview\n\nProkka is a command-line pipeline for rapid annotation of prokaryotic genomes (bacteria, archaea, and viruses). It uses a tiered search strategy: protein-coding genes (CDS) are predicted with Prodigal and searched first against a genus-specific database, then RefSeq proteins, then Pfam\u002FTIGRFAMs HMMs. Non-coding RNA genes (rRNA, tRNA, tmRNA) are identified with Barrnap, Aragorn, and Infernal. Prokka processes a single FASTA assembly in minutes and outputs a comprehensive annotation in GFF3, GenBank, FASTA, and tabular formats.\n\n## When to Use\n\n- Annotating a newly assembled bacterial or archaeal genome from Illumina, PacBio, or Nanopore assemblies\n- Getting functional protein annotations (CDS with product names, EC numbers, GO terms) from a draft or complete genome\n- Preparing annotation files for downstream comparative genomics (Roary pan-genome, OrthoFinder)\n- Annotating viral or phage genomes when kingdom-specific databases are important\n- Performing metagenome-assembled genome (MAG) annotation with the `--metagenome` flag\n- Parsing annotated outputs in Python with BioPython for downstream sequence or feature analysis\n- Use **PGAP** (NCBI Prokaryotic Genome Annotation Pipeline) instead when the goal is NCBI GenBank submission with standards compliance\n- Use **Bakta** instead for faster annotation with built-in NCBI-compatible outputs and a more regularly updated database\n\n## Prerequisites\n\n- **Software**: Prokka ≥ 1.14, Perl 5, Prodigal, Barrnap, HMMER3, BLAST+, Aragorn, Infernal, tbl2asn\n- **Python packages** (for output parsing): `biopython`, `pandas`, `matplotlib`\n- **Input**: assembled genome in FASTA format (complete or draft with multiple contigs)\n- **Environment**: conda strongly recommended to handle the Perl and C dependency stack\n\n> **Check before installing**: The tool may already be available in the current environment (e.g., inside a `pixi` \u002F `conda` env). Run `command -v prokka` first and skip the install commands below if it returns a path. When running inside a pixi project, invoke the tool via `pixi run prokka` rather than bare `prokka`.\n\n```bash\n# Install Prokka via conda\u002Fmamba (recommended)\nconda install -c conda-forge -c bioconda prokka\n\n# Or with mamba (faster)\nmamba install -c conda-forge -c bioconda prokka\n\n# Verify installation and database setup\nprokka --version\n# prokka 1.14.6\n\n# Check that required tools are on PATH\nprokka --depends\n# prokka needs: awk, sed, grep, makeblastdb, blastp, hmmscan, ...\n\n# Install Python parsing dependencies\npip install biopython pandas matplotlib\n```\n\n## Pre-flight Interview\n\nSettle these with the user before writing any analysis code.\n\n```yaml\ndecisions:\n  - id: D1\n    param: kingdom\n    kind: required\n    source: user\n    ask: \"Is this a bacterial, archaeal, viral, or mitochondrial assembly?\"\n    default: \"Bacteria\"\n\n  - id: D2\n    param: organismMetadata\n    kind: required\n    source: user\n    ask: \"Which genus, species, and strain should be recorded, and used to prioritise a genus-specific protein database?\"\n    default: null\n\n  - id: D3\n    param: assemblyOrigin\n    kind: required\n    source: data\n    ask: \"Is this an isolate genome, or a bin recovered from a metagenome?\"\n    default: \"isolate - gene prediction trains on the assembly itself\"\n\n  - id: D4\n    param: rnaPrediction\n    kind: optional\n    source: user\n    ask: \"Should rRNA, tRNA, and other non-coding RNA be predicted alongside coding genes?\"\n    default: \"tRNA and rRNA predicted; Rfam search off as it is slow\"\n\n  - id: D5\n    param: customProteins\n    kind: optional\n    source: user\n    ask: \"Is there a curated protein set that should be searched before the general reference database?\"\n    default: \"none\"\n\n  - id: D6\n    param: hitEvalue\n    kind: optional\n    source: user\n    ask: \"How confident must a database hit be before it names a gene?\"\n    default: \"1e-6\"\n\n  - id: D7\n    param: minContigLength\n    kind: optional_conditional\n    source: data\n    ask: \"Should short contigs be skipped - and does the assembly have enough of them to matter?\"\n    default: \"no minimum\"\n\n  - id: D8\n    param: cpus\n    kind: never_ask\n    source: data\n    reason: \"Affects runtime only, not the annotation\"\n    default: \"min(8, available_cores)\"\n```\n\nD3 changes how genes are predicted rather than how they are named. Prodigal\ntrains its model on the input; a metagenomic bin holding more than one organism\ntrains a blended model, and the resulting gene boundaries are wrong in a way\nthat no downstream step flags.\n\n## Quick Start\n\n```bash\n# Annotate a bacterial genome assembly — results in results\u002F directory\nprokka genome.fasta \\\n    --outdir results\u002F \\\n    --prefix sample1 \\\n    --kingdom Bacteria \\\n    --cpus 4\n\n# Check output summary\ncat results\u002Fsample1.txt\n# Organism: Genus species strain\n# Contigs: 1\n# Bases: 4639675\n# CDS: 4140\n# rRNA: 22\n# tRNA: 86\n\necho \"Annotation complete. Key output files:\"\nls results\u002Fsample1.{gff,gbk,faa,ffn,tsv}\n```\n\n## Workflow\n\n### Step 1: Install and Verify Prokka\n\nInstall Prokka and confirm all dependent tools are accessible in the current environment.\n\n```bash\n# Create a dedicated conda environment\nconda create -n prokka_env -c conda-forge -c bioconda prokka python=3.10 -y\nconda activate prokka_env\n\n# Verify Prokka version and all tool dependencies\nprokka --version\n# prokka 1.14.6\n\nprokka --depends\n# Checking that required tools are installed...\n# OK: makeblastdb is installed (2.13.0+)\n# OK: blastp is installed (2.13.0+)\n# OK: hmmscan is installed (3.3.2)\n# OK: prodigal is installed (2.6.3)\n# OK: barrnap is installed (0.9)\n\n# Check available genus-specific databases bundled with Prokka\nls $(conda info --base)\u002Fenvs\u002Fprokka_env\u002Fdb\u002Fgenus\u002F\n# Archaea  Bacteria  Mitochondria  Viruses\n\n# Install Python parsing tools\npip install biopython pandas matplotlib\n```\n\n### Step 2: Prepare the Input Genome\n\nClean and rename contigs to comply with Prokka's header requirements before annotation.\n\n```python\nfrom Bio import SeqIO\nimport re\n\n# Load and inspect assembly\ninput_fasta = \"genome.fasta\"\nrecords = list(SeqIO.parse(input_fasta, \"fasta\"))\nprint(f\"Input assembly: {len(records)} contigs\")\ntotal_bases = sum(len(r) for r in records)\nprint(f\"Total bases: {total_bases:,}\")\nprint(f\"Largest contig: {max(len(r) for r in records):,} bp\")\nprint(f\"N50 approx: see assembly stats tool\")\n\n# Rename contigs to short IDs compatible with Prokka (max 37 chars)\n# Prokka requires: no spaces, no special characters in header\ncleaned = []\nfor i, rec in enumerate(records, 1):\n    new_id = f\"contig_{i:04d}\"\n    new_rec = rec.__class__(rec.seq, id=new_id, description=f\"len={len(rec.seq)}\")\n    cleaned.append(new_rec)\n\nSeqIO.write(cleaned, \"genome_clean.fasta\", \"fasta\")\nprint(f\"\\nWrote genome_clean.fasta with {len(cleaned)} renamed contigs\")\n# genome_clean.fasta: contig_0001 through contig_NNNN\n```\n\n```bash\n# Alternatively, clean headers with a simple bash one-liner\nawk '\u002F^>\u002F{print \">contig_\" ++i; next}{print}' genome.fasta > genome_clean.fasta\n\n# Filter out short contigs (\u003C 200 bp) to reduce annotation noise\nawk '\u002F^>\u002F{header=$0; next} length($0) >= 200 {print header; print}' \\\n    genome_clean.fasta > genome_filtered.fasta\n\necho \"Filtered assembly ready: $(grep -c '>' genome_filtered.fasta) contigs\"\n```\n\n### Step 3: Run Basic Prokka Annotation\n\nRun Prokka with standard options for a bacterial genome, specifying genus\u002Fspecies for database selection.\n\n```bash\n# Basic annotation with genus\u002Fspecies hint (uses genus-specific protein database first)\nprokka genome_clean.fasta \\\n    --outdir annotation\u002F \\\n    --prefix E_coli_K12 \\\n    --kingdom Bacteria \\\n    --genus Escherichia \\\n    --species coli \\\n    --strain K12 \\\n    --cpus 8 \\\n    --mincontiglen 200\n\n# Expected runtime: 2–10 minutes for a typical 4–6 Mb bacterial genome\n\necho \"Prokka annotation output files:\"\nls annotation\u002F\n# E_coli_K12.err   E_coli_K12.faa   E_coli_K12.ffn\n# E_coli_K12.fna   E_coli_K12.gbk   E_coli_K12.gff\n# E_coli_K12.log   E_coli_K12.sqn   E_coli_K12.tbl\n# E_coli_K12.tsv   E_coli_K12.txt\n```\n\n### Step 4: Parse Annotation Summary (TSV)\n\nLoad the TSV output for a quick overview of annotated features and their functional assignments.\n\n```python\nimport pandas as pd\n\n# Load the annotation TSV (tab-delimited feature table)\ntsv_file = \"annotation\u002FE_coli_K12.tsv\"\ndf = pd.read_csv(tsv_file, sep=\"\\t\")\nprint(f\"Total features: {len(df)}\")\nprint(f\"Columns: {list(df.columns)}\")\n# Columns: [locus_tag, ftype, length_bp, gene, EC_number, COG, product]\n\n# Feature type summary\nprint(\"\\nFeature type counts:\")\nprint(df[\"ftype\"].value_counts().to_string())\n# CDS     4140\n# tRNA      86\n# rRNA      22\n# tmRNA      1\n\n# Functional gene annotations (non-hypothetical CDS)\ncds_df = df[df[\"ftype\"] == \"CDS\"].copy()\nhypothetical = cds_df[\"product\"].str.contains(\"hypothetical\", case=False, na=True)\nprint(f\"\\nCDS with known function: {(~hypothetical).sum()}\")\nprint(f\"Hypothetical proteins: {hypothetical.sum()}\")\n\n# Genes with EC numbers (enzymes)\nec_annotated = cds_df[cds_df[\"EC_number\"].notna() & (cds_df[\"EC_number\"] != \"\")]\nprint(f\"CDS with EC numbers: {len(ec_annotated)}\")\nprint(ec_annotated[[\"locus_tag\", \"gene\", \"EC_number\", \"product\"]].head(5).to_string(index=False))\n```\n\n### Step 5: Parse GenBank Output with BioPython\n\nRead the GenBank file to access per-gene sequences, qualifiers, and feature coordinates.\n\n```python\nfrom Bio import SeqIO\nimport pandas as pd\n\n# Parse GenBank file\ngbk_file = \"annotation\u002FE_coli_K12.gbk\"\nrecords = list(SeqIO.parse(gbk_file, \"genbank\"))\nprint(f\"Contigs in GenBank: {len(records)}\")\n\n# Iterate over CDS features and extract details\nrows = []\nfor rec in records:\n    for feat in rec.features:\n        if feat.type != \"CDS\":\n            continue\n        qualifiers = feat.qualifiers\n        rows.append({\n            \"contig\":      rec.id,\n            \"locus_tag\":   qualifiers.get(\"locus_tag\", [\"?\"])[0],\n            \"gene\":        qualifiers.get(\"gene\", [\"\"])[0],\n            \"product\":     qualifiers.get(\"product\", [\"hypothetical protein\"])[0],\n            \"EC_number\":   qualifiers.get(\"EC_number\", [\"\"])[0],\n            \"protein_id\":  qualifiers.get(\"protein_id\", [\"\"])[0],\n            \"start\":       int(feat.location.start),\n            \"end\":         int(feat.location.end),\n            \"strand\":      feat.location.strand,\n            \"aa_length\":   len(qualifiers.get(\"translation\", [\"\"])[0]),\n        })\n\nfeatures_df = pd.DataFrame(rows)\nprint(f\"CDS features extracted: {len(features_df)}\")\nprint(features_df.head(3).to_string(index=False))\n\n# Retrieve protein sequence for a specific gene\ngene_name = \"dnaA\"\ngene_feat = features_df[features_df[\"gene\"] == gene_name]\nif not gene_feat.empty:\n    idx = gene_feat.index[0]\n    print(f\"\\n{gene_name}: {features_df.loc[idx, 'aa_length']} aa\")\n```\n\n### Step 6: Visualize Annotation Statistics\n\nGenerate a summary barplot of feature types and functional annotation coverage.\n\n```python\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\n\ntsv_file = \"annotation\u002FE_coli_K12.tsv\"\ndf = pd.read_csv(tsv_file, sep=\"\\t\")\n\ncds = df[df[\"ftype\"] == \"CDS\"].copy()\nn_cds = len(cds)\nn_known = (~cds[\"product\"].str.contains(\"hypothetical\", case=False, na=True)).sum()\nn_hypo = n_cds - n_known\nn_ec = cds[\"EC_number\"].notna().sum()\nn_rrna = (df[\"ftype\"] == \"rRNA\").sum()\nn_trna = (df[\"ftype\"] == \"tRNA\").sum()\n\nfig, axes = plt.subplots(1, 2, figsize=(11, 4))\n\n# Left panel: feature type counts\ntypes = df[\"ftype\"].value_counts()\ncolors_left = [\"#2980B9\", \"#27AE60\", \"#E74C3C\", \"#F39C12\"] + [\"#95A5A6\"] * len(types)\naxes[0].bar(types.index, types.values, color=colors_left[:len(types)], edgecolor=\"white\")\naxes[0].set_title(\"Annotated Feature Counts\")\naxes[0].set_xlabel(\"Feature Type\")\naxes[0].set_ylabel(\"Count\")\nfor i, (label, val) in enumerate(types.items()):\n    axes[0].text(i, val + 5, str(val), ha=\"center\", fontsize=9)\n\n# Right panel: CDS functional annotation breakdown\nlabels = [\"Known function\", \"Hypothetical protein\", \"Enzyme (EC number)\"]\nsizes  = [n_known, n_hypo, n_ec]\ncolors_right = [\"#2980B9\", \"#BDC3C7\", \"#E74C3C\"]\nbars = axes[1].bar(labels, sizes, color=colors_right, edgecolor=\"white\")\naxes[1].set_title(f\"CDS Functional Annotation\\n(n={n_cds} total CDS)\")\naxes[1].set_ylabel(\"Count\")\naxes[1].tick_params(axis=\"x\", rotation=15)\nfor bar, val in zip(bars, sizes):\n    axes[1].text(bar.get_x() + bar.get_width() \u002F 2,\n                 val + 10, str(val), ha=\"center\", fontsize=9)\n\nplt.suptitle(\"Prokka Genome Annotation Summary\", fontsize=12, fontweight=\"bold\")\nplt.tight_layout()\nplt.savefig(\"prokka_annotation_summary.png\", dpi=150, bbox_inches=\"tight\")\nprint(f\"Saved prokka_annotation_summary.png\")\nprint(f\"CDS: {n_cds}  |  Known function: {n_known}  |  Hypothetical: {n_hypo}\")\nprint(f\"rRNA: {n_rrna}  |  tRNA: {n_trna}  |  EC-annotated CDS: {n_ec}\")\n```\n\n### Step 7: Batch Annotation Across Multiple Genomes\n\nAnnotate multiple genome assemblies sequentially and collect summary statistics.\n\n```bash\n#!\u002Fbin\u002Fbash\n# batch_prokka.sh — annotate all FASTA files in a directory\n\nINPUT_DIR=\"genomes\u002F\"\nOUTPUT_DIR=\"annotations\u002F\"\nmkdir -p \"$OUTPUT_DIR\"\n\nfor FASTA in \"$INPUT_DIR\"\u002F*.fasta; do\n    SAMPLE=$(basename \"$FASTA\" .fasta)\n    echo \"Annotating: $SAMPLE\"\n    prokka \"$FASTA\" \\\n        --outdir \"${OUTPUT_DIR}\u002F${SAMPLE}\" \\\n        --prefix \"$SAMPLE\" \\\n        --kingdom Bacteria \\\n        --cpus 4 \\\n        --mincontiglen 200 \\\n        --quiet\n    echo \"  Done: ${OUTPUT_DIR}\u002F${SAMPLE}\u002F${SAMPLE}.txt\"\ndone\n\necho \"Batch annotation complete.\"\n```\n\n```python\n# Collect summary statistics from all Prokka .txt files\nfrom pathlib import Path\nimport pandas as pd\n\nannotation_dir = Path(\"annotations\u002F\")\nrows = []\n\nfor txt_file in sorted(annotation_dir.glob(\"*\u002F*.txt\")):\n    sample = txt_file.stem\n    stats = {}\n    with open(txt_file) as f:\n        for line in f:\n            line = line.strip()\n            if \": \" in line:\n                key, val = line.split(\": \", 1)\n                stats[key.strip()] = val.strip()\n    rows.append({\n        \"sample\":   sample,\n        \"contigs\":  int(stats.get(\"Contigs\", 0)),\n        \"bases\":    int(stats.get(\"Bases\", 0)),\n        \"CDS\":      int(stats.get(\"CDS\", 0)),\n        \"rRNA\":     int(stats.get(\"rRNA\", 0)),\n        \"tRNA\":     int(stats.get(\"tRNA\", 0)),\n    })\n\nsummary_df = pd.DataFrame(rows)\nprint(f\"Annotated genomes: {len(summary_df)}\")\nprint(summary_df.to_string(index=False))\nsummary_df.to_csv(\"batch_annotation_summary.csv\", index=False)\nprint(\"\\nSaved: batch_annotation_summary.csv\")\n```\n\n### Step 8: Compare Annotations Between Strains\n\nUse the protein FASTA outputs for cross-strain comparison with identity-based clustering.\n\n```python\nfrom Bio import SeqIO, pairwise2\nimport pandas as pd\n\n# Load protein sequences from two strains\ndef load_proteins(faa_file):\n    \"\"\"Return dict of locus_tag -> protein sequence.\"\"\"\n    return {rec.id: str(rec.seq)\n            for rec in SeqIO.parse(faa_file, \"fasta\")}\n\nstrain_a = load_proteins(\"annotation_A\u002Fstrain_A.faa\")\nstrain_b = load_proteins(\"annotation_B\u002Fstrain_B.faa\")\n\nprint(f\"Strain A proteins: {len(strain_a)}\")\nprint(f\"Strain B proteins: {len(strain_b)}\")\n\n# Compare gene counts and size distributions\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nlen_a = [len(seq) for seq in strain_a.values()]\nlen_b = [len(seq) for seq in strain_b.values()]\n\nfig, ax = plt.subplots(figsize=(8, 4))\nbins = np.linspace(0, 1500, 50)\nax.hist(len_a, bins=bins, alpha=0.6, label=f\"Strain A (n={len(len_a)})\", color=\"#2980B9\")\nax.hist(len_b, bins=bins, alpha=0.6, label=f\"Strain B (n={len(len_b)})\", color=\"#E74C3C\")\nax.set_xlabel(\"Protein Length (aa)\")\nax.set_ylabel(\"Count\")\nax.set_title(\"Protein Length Distribution by Strain\")\nax.legend()\nplt.tight_layout()\nplt.savefig(\"strain_protein_length_comparison.png\", dpi=150, bbox_inches=\"tight\")\nprint(\"Saved strain_protein_length_comparison.png\")\n\n# Find proteins unique to each strain by size\u002Fcount difference\nprint(f\"\\nSize difference: {abs(len(strain_a) - len(strain_b))} proteins\")\nprint(\"→ Use Roary or OrthoFinder for formal pan-genome analysis\")\n```\n\n## Key Parameters\n\n| Parameter | Default | Range \u002F Options | Effect |\n|-----------|---------|-----------------|--------|\n| `--kingdom` | `Bacteria` | `Bacteria`, `Archaea`, `Viruses`, `Mitochondria` | Selects gene prediction model and default databases |\n| `--genus` | — | any genus name string | Prioritizes genus-specific protein database for CDS annotation |\n| `--species` | — | any species name string | Combined with `--genus` for locus_tag prefix and organism metadata |\n| `--strain` | — | any string | Added to organism metadata in GenBank output |\n| `--proteins` | — | path to FASTA file | Custom protein database prepended before RefSeq search |\n| `--hmms` | — | path to HMM file | Additional custom HMM database for specialized annotation |\n| `--evalue` | `1e-6` | `1e-4`–`1e-9` | E-value cutoff for BLAST and HMMER hits |\n| `--cpus` | `8` | `1`–CPU count | Parallel processes for BLAST and HMMER searches |\n| `--mincontiglen` | `1` | any integer | Skip contigs shorter than this length (bp) |\n| `--metagenome` | off | flag | Disables Prodigal training on this genome (for MAGs) |\n| `--rfam` | off | flag | Enable Infernal rRNA\u002FncRNA search against Rfam (slower) |\n| `--norrna` | off | flag | Skip rRNA prediction (use when assembly has no rRNA genes) |\n| `--notrna` | off | flag | Skip tRNA prediction |\n\n## Common Recipes\n\n### Recipe: Annotation with Custom Protein Database\n\nWhen to use: You have closely related reference proteins (e.g., characterized isolate) to improve annotation accuracy.\n\n```bash\n# Use a custom protein database to enhance annotation of a novel strain\n# Custom proteins are searched first, before internal Prokka databases\nprokka genome.fasta \\\n    --proteins reference_proteins.faa \\\n    --outdir custom_annotation\u002F \\\n    --prefix novel_strain \\\n    --kingdom Bacteria \\\n    --cpus 4\n\necho \"Custom DB annotation complete:\"\ngrep \"CDS\" custom_annotation\u002Fnovel_strain.txt\n```\n\n### Recipe: Metagenome-Assembled Genome (MAG) Annotation\n\nWhen to use: Annotating a MAG where Prodigal cannot train on the full genome sequence.\n\n```bash\n# --metagenome disables Prodigal model training (uses meta mode)\n# --mincontiglen 500 discards short, potentially chimeric contigs\nprokka MAG_bin_42.fasta \\\n    --metagenome \\\n    --kingdom Bacteria \\\n    --outdir mag_annotation\u002F \\\n    --prefix MAG_bin_42 \\\n    --mincontiglen 500 \\\n    --cpus 4\n\necho \"MAG annotation complete:\"\ncat mag_annotation\u002FMAG_bin_42.txt\n```\n\n### Recipe: Extract Specific Gene Sequences\n\nWhen to use: Retrieve nucleotide or protein sequences for a target gene or pathway from the annotation.\n\n```python\nfrom Bio import SeqIO\n\n# Extract all sequences for a specific gene name from protein FASTA\nfaa_file = \"annotation\u002FE_coli_K12.faa\"\ntarget_gene = \"dnaA\"\n\nmatches = []\nfor rec in SeqIO.parse(faa_file, \"fasta\"):\n    # Prokka FASTA header: >locus_tag gene product\n    if target_gene in rec.description:\n        matches.append(rec)\n\nprint(f\"Proteins matching '{target_gene}': {len(matches)}\")\nfor rec in matches:\n    print(f\"  {rec.id}: {len(rec.seq)} aa — {rec.description}\")\n\n# Save matching sequences\nif matches:\n    SeqIO.write(matches, f\"{target_gene}_proteins.faa\", \"fasta\")\n    print(f\"Saved: {target_gene}_proteins.faa\")\n```\n\n### Recipe: Convert GFF to Pandas DataFrame\n\nWhen to use: Work with genomic coordinates for feature overlap analysis or visualization.\n\n```python\nimport pandas as pd\n\ndef parse_gff(gff_file):\n    \"\"\"Parse Prokka GFF3 file into a DataFrame (skips sequence section).\"\"\"\n    rows = []\n    with open(gff_file) as f:\n        for line in f:\n            if line.startswith(\"##FASTA\"):\n                break\n            if line.startswith(\"#\") or not line.strip():\n                continue\n            parts = line.rstrip(\"\\n\").split(\"\\t\")\n            if len(parts) \u003C 9:\n                continue\n            attr_dict = {}\n            for item in parts[8].split(\";\"):\n                if \"=\" in item:\n                    k, v = item.split(\"=\", 1)\n                    attr_dict[k] = v\n            rows.append({\n                \"seqname\":  parts[0],\n                \"source\":   parts[1],\n                \"feature\":  parts[2],\n                \"start\":    int(parts[3]),\n                \"end\":      int(parts[4]),\n                \"score\":    parts[5],\n                \"strand\":   parts[6],\n                \"frame\":    parts[7],\n                \"locus_tag\": attr_dict.get(\"ID\", \"\"),\n                \"gene\":     attr_dict.get(\"gene\", \"\"),\n                \"product\":  attr_dict.get(\"product\", \"\"),\n            })\n    return pd.DataFrame(rows)\n\ngff_df = parse_gff(\"annotation\u002FE_coli_K12.gff\")\nprint(f\"GFF features: {len(gff_df)}\")\nprint(gff_df[gff_df[\"feature\"] == \"CDS\"].head(5)[\n    [\"seqname\", \"start\", \"end\", \"strand\", \"gene\", \"product\"]\n].to_string(index=False))\n```\n\n## Expected Outputs\n\n| Output File | Format | Description |\n|-------------|--------|-------------|\n| `{prefix}.gff` | GFF3 | Genome annotation with feature coordinates and attributes; includes FASTA sequence at the end |\n| `{prefix}.gbk` | GenBank | Full GenBank-format annotation for use in Geneious, BioPython, and submission prep |\n| `{prefix}.faa` | FASTA | Predicted protein sequences for all CDS features |\n| `{prefix}.ffn` | FASTA | Nucleotide sequences for all annotated features (CDS, rRNA, tRNA) |\n| `{prefix}.fna` | FASTA | Nucleotide FASTA of the complete assembly (contigs) |\n| `{prefix}.tsv` | TSV | Tab-delimited summary table: locus_tag, ftype, length_bp, gene, EC_number, COG, product |\n| `{prefix}.txt` | Text | One-line summary counts: Contigs, Bases, CDS, rRNA, tRNA, tmRNA |\n| `{prefix}.tbl` | TBL | Feature table format for tbl2asn GenBank submission |\n| `{prefix}.sqn` | SQN | ASN.1 format for NCBI submission (generated by tbl2asn) |\n| `{prefix}.err` | Text | Warnings and errors from tbl2asn validation step |\n| `{prefix}.log` | Text | Full Prokka run log with timing per step |\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| `FATAL: Can't find any tRNA genes` | No tRNA detected on short or highly fragmented assembly | Add `--notrna` flag; check if assembly is too fragmented (N50 \u003C 1 kb) |\n| `Can't exec \"makeblastdb\"` | BLAST+ not on PATH | `conda install -c bioconda blast`; ensure prokka env is activated |\n| `Contig ID too long (>37 chars)` | Assembler produced long contig headers | Pre-process FASTA to shorten headers: `awk '\u002F^>\u002F{print \">contig_\"++i; next}{print}'` |\n| Very high hypothetical protein rate (>60%) | Divergent organism with few database matches | Add `--proteins` with closely related strain FAA; consider `--genus` flag |\n| `ERROR: Argument --proteins: file does not exist` | Path to custom protein file is incorrect | Use absolute path; verify file exists with `ls -la custom.faa` |\n| `tbl2asn error: multiple \u002Fproduct` | Duplicate product qualifiers in annotation | Ignore if exporting for local use; for NCBI submission, use PGAP instead |\n| Annotation is very slow (>30 min for ~5 Mb) | `--cpus` not set or set to 1; `--rfam` enabled | Set `--cpus` to available thread count; disable `--rfam` for faster runs |\n| rRNA count is 0 for complete genome | `--norrna` flag was set, or barrnap threshold too strict | Remove `--norrna`; check barrnap is installed with `barrnap --version` |\n\n## References\n\n- [Prokka GitHub: tseemann\u002Fprokka](https:\u002F\u002Fgithub.com\u002Ftseemann\u002Fprokka) — source code, installation instructions, and detailed parameter reference\n- [Seemann T (2014) Bioinformatics 30(14):2068–2069](https:\u002F\u002Fdoi.org\u002F10.1093\u002Fbioinformatics\u002Fbtu153) — original Prokka paper with benchmarks vs. RAST\n- [Prodigal documentation](https:\u002F\u002Fgithub.com\u002Fhyattpd\u002FProdigal\u002Fwiki) — gene prediction engine used by Prokka for CDS calling\n- [Barrnap GitHub: tseemann\u002Fbarrnap](https:\u002F\u002Fgithub.com\u002Ftseemann\u002Fbarrnap) — rRNA prediction tool bundled with Prokka\n- [BioPython GenBank parsing tutorial](https:\u002F\u002Fbiopython.org\u002Fwiki\u002FSeqIO) — reference for parsing Prokka GenBank output in Python\n",{"name":5,"license":15,"description":7},"master","fd76f882a04e445e899d5cfb2732f2105ea054ee","skills\u002Fawesome-skills\u002Fprokka-genome-annotation",0,"https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS","https:\u002F\u002Fbg-szy.github.io\u002FTOP-SKILLS\u002F","https:\u002F\u002Fgithub.com\u002Fbg-szy","https:\u002F\u002Fwww.ecust.edu.cn\u002F","a student of East China University of Science and Technology","2026-11-15 03:38:02",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add bg-szy\u002FTOP-SKILLS --skill prokka-genome-annotation",{"tool":40,"command":41},"bunx","bunx skills add bg-szy\u002FTOP-SKILLS --skill prokka-genome-annotation",{"tool":43,"command":44},"pnpm","pnpm dlx skills add bg-szy\u002FTOP-SKILLS --skill prokka-genome-annotation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fawesome-skills\u002Fprokka-genome-annotation\u002FSKILL.md",true,[],[49,58,65,72,79,86],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":57},"01M7DXW9N826PKXK174PVW3038","serpmaven","Scrape Google search results (SERP) to JSON with SERP Maven (serpmaven) - a real Chrome browser on a residential proxy with sticky sessions. Run it as a CLI, a Python library, a local HTTP search API (`serve`), an MCP server or a Docker image; set the proxy login, workers, pages and cost tracking. Use when the user wants Google results, rank tracking, a self-hosted SERP API, or live Google search for an AI agent.","MIT","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fserpmaven\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":57},"01M7DXVHSTWDV65475QEQ915M7","revnu-landing-page-audit","Find out why a landing page isn't turning visitors into signups, demos or sales. Audits one page against what the ad, post or search that sends people there promised, then checks the first screen, proof, call to action, friction and mobile. Returns at most 7 prioritized fixes, plus what is fine and what could not be checked; rewrites specific lines and fixes the page in the repo when asked. Never promises a conversion lift. Works without a Revnu account. Use when the user says or asks: \"audit my landing page\", \"why isn't this page converting\", \"review my homepage\", \"my ads get clicks but no signups\", \"people bounce from the pricing page\", \"CRO review\", \"improve conversion rate\", \"is my hero section clear\", \"roast my landing page\", \"rewrite my headline\", \"what's wrong with this page\", \"landing page feedback\", \"make the signup page convert better\". Not for SEO or AI-search audits, page speed engineering on its own, or building a new page from scratch.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-landing-page-audit\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":57},"01M7DXV8X2D7B3VTD4HHYYHTGR","revnu-growth-context","Write down once who buys, what they're stuck on, what it costs, what proof you have and what you've already tried, so every growth task starts from facts instead of a questionnaire. Creates or updates .agents\u002Frevnu-growth.md from the repo, the live site and the user, and imports an existing product-marketing.md. Use when the user says \"set up our marketing context\", \"who is our ideal customer\", \"write our ICP\", \"describe the product for marketing\", \"positioning doc\", \"what's our brand voice\", \"remember this about our customers\", \"log what we tried\", \"what have we learned from marketing\", \"we changed pricing, update the context\", \"update our growth notes\", \"summarize the business for the agent\", \"import my product-marketing.md\", \"start a growth doc\", or before a first marketing, SEO, outreach or launch task when no context file exists. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-growth-context\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":57},"01M7DXV0DGJ1G0A60PAHC6J3C5","revnu-get-listed","Get onto the third-party pages AI answers and search cite when buyers ask for the best tool in your category: \"best X\" roundups, directories, review sites, GitHub awesome lists, community threads and comparison pages. Finds which ones are cited, ranks them by fit and effort, and drafts each submission, PR or pitch by the target's own rules. Use when the user says \"get us listed\", \"which directories should we submit to\", \"how do we get into best-of lists\", \"why does ChatGPT recommend competitors and not us\", \"get mentioned in AI answers\", \"submit to awesome lists\", \"get on G2\", \"where are our competitors listed\", \"pitch listicle authors\", \"find backlink opportunities\", \"launch directories\", \"get into roundups\", \"Product Hunt alternatives\", \"where should we be listed\", \"get cited by Perplexity\". Never submits, pays or posts without a yes. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-get-listed\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":57},"01M7DXTSPMGT9D6DSS0HP9BSTA","revnu-ai-readiness-audit","Audit whether your website gives ChatGPT, Perplexity, Claude, Gemini and Google's AI Overviews something worth quoting, and fix the pages that don't. Use when the user says or asks \"is my site ready for AI search\", \"audit my site for AI answers\", \"AEO audit\", \"GEO audit\", \"why doesn't ChatGPT quote our pricing\", \"make our pages citable by AI\", \"do I need llms.txt\", \"does schema help with ChatGPT\", \"check our structured data\", \"is our content visible without JavaScript\", \"AI SEO audit\", \"optimize our homepage for AI answers\", \"LLM SEO check\", \"why does AI get our product wrong\", \"fix our site for AI Overviews\". Checks fetchability and indexability, answers in the raw HTML, entity facts, schema (including JS-injected markup), headings, dates and llms.txt, then gives at most 10 prioritised fixes and edits the repo when asked. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-ai-readiness-audit\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":57},"01M7DXSZHCVTRS620GC3S97JZV","proxy-troubleshooting","Diagnose residential proxy failures, with NodeMaven's gateway as the reference - 407 with correct credentials, 406, 410, 500, a connection that hangs, ERR_TUNNEL_CONNECTION_FAILED in a browser, Playwright or Puppeteer ignoring proxy credentials, a sticky session that changes IP, geo-targeting that is silently ignored, passwords with special characters, and unexpected traffic from headless Chrome. Use when a proxy connection fails, returns the wrong location, or costs more traffic than expected.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fproxy-troubleshooting\u002FSKILL.md",[],[]]