$npx -y skills add ai4protein/VenusFactory2 --skill ncbi_sequenceNCBI E-utilities for biological sequences — fetch protein/nucleotide FASTA by accession, run BLAST, translate CDS to protein, search NCBI Protein by gene+organism. Use when the user provides an NCBI accession (NP_, XP_, NM_, NR_, etc.), asks for a sequence by gene name + species,
| 1 | # NCBI Sequence Tools |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Wraps NCBI E-utilities (`efetch`, `esearch`) for sequence-centric workflows. Honors `NCBI_API_KEY` env var to raise the QPS limit from 3 → 10. Set `USER_EMAIL` env var to identify yourself to NCBI as a good citizen. |
| 6 | |
| 7 | ## Project Tools (VenusFactory2) |
| 8 | |
| 9 | | Tool | Args | Returns | Description | |
| 10 | |------|------|---------|--------------| |
| 11 | | **download_ncbi_sequence** | `ncbi_id`, `out_dir`, `db` (default `protein`) | rich JSON envelope; FASTA file | Fetch a single sequence by accession from `protein` or `nuccore`. | |
| 12 | | **download_ncbi_metadata** | `ncbi_id`, `out_path`, `db` | rich JSON envelope; metadata JSON | Fetch GenBank-style metadata for an accession. | |
| 13 | | **download_ncbi_blast** | (see existing schema) | rich JSON envelope | NCBI-hosted BLAST. **Prefer `download_mmseqs2_homologs_by_sequence` (faster) or `download_blast_homologs_by_sequence` (EBI mirror) for protein-protein searches.** | |
| 14 | | **translate_ncbi_cds_to_protein** | `accession` (nuccore, e.g. `NM_000518` for HBB mRNA), `out_dir`, `target_length` (default `0` = longest), `timeout` | rich JSON envelope; FASTA at `<out_dir>/<accession>_protein.fasta`; `biological_metadata.method="fasta_cds_aa"` | Use `efetch(rettype=fasta_cds_aa)` to get the CDS-translated protein, pick the translation closest to `target_length` (or longest). | |
| 15 | | **search_ncbi_protein_by_gene_and_organism** | `gene` (e.g. `TP53`), `organism` (`"Homo sapiens"`), `out_dir`, `target_length` (default `0` = no length filter; non-zero filters to ±25 aa window), `retmax` (default `10`), `timeout` | rich JSON envelope; multi-FASTA + `<stem>.json` summary; `biological_metadata.summary_path` for the per-hit JSON | Search NCBI Protein DB with `<gene>[Gene Name] AND <organism>[Organism]`, fetch all hits as multi-FASTA. | |
| 16 | |
| 17 | ## Workflow: "Get the protein sequence for gene X in species Y" |
| 18 | |
| 19 | 1. **Try `search_ncbi_protein_by_gene_and_organism`** first — if it finds 1-5 hits, pick the canonical one. |
| 20 | 2. **If you know the mRNA accession** (e.g. from a Gene record), use `translate_ncbi_cds_to_protein` for the canonical CDS-derived protein (no ambiguity from isoforms). |
| 21 | 3. **Fallback**: keyword search via `download_ncbi_metadata` to find an accession, then `download_ncbi_sequence`. |
| 22 | |
| 23 | ## Workflow: "Translate this mRNA to protein" |
| 24 | |
| 25 | - Direct: `translate_ncbi_cds_to_protein(accession=..., target_length=expected_aa_count)`. The tool uses NCBI's pre-translated CDS protein when available — no client-side translation needed, no codon-table issues. |
| 26 | |
| 27 | ## Common Mistakes |
| 28 | |
| 29 | - **Confusing `protein` and `nuccore` DBs**: protein accessions (NP_, XP_, AAA-style) go to `db=protein`; mRNA/genomic (NM_, NC_, etc.) go to `db=nuccore`. `translate_ncbi_cds_to_protein` always uses `nuccore` internally. |
| 30 | - **Mismatched gene+organism**: NCBI is strict; `TP53 AND Homo sapiens` works, `tp53 AND human` may not. |
| 31 | - **Forgetting `NCBI_API_KEY`**: at 3 QPS you'll hit rate limits with batch operations. Set the env var to bump to 10 QPS. |
| 32 | - **target_length too narrow**: `search_ncbi_protein_by_gene_and_organism` applies ±25 aa filter; if your target_length is uncertain, pass 0 and pick from results. |
| 33 | |
| 34 | ## References |
| 35 | |
| 36 | - [E-utilities](https://www.ncbi.nlm.nih.gov/books/NBK25501/) |
| 37 | - [Get an NCBI API key](https://www.ncbi.nlm.nih.gov/account/settings/) (free) |
| 38 | - [Entrez query syntax](https://www.ncbi.nlm.nih.gov/books/NBK3837/) |