Przejdź do treści
Biblioteka skilli
Nauka i badania · Research

ncbi-sequence-fetch

/ncbi-sequence-fetch

Pobiera sekwencje białek i nukleotydów z baz NCBI przez E-utilities, po numerze akcesyjnym, nazwie genu lub identyfikatorze PubMed.

Licencja
Apache-2.0
Ostatnia zmiana repozytorium
08.11.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
8
Skrypty
1
Komentarze HTML
0
Adresy URL w SKILL.md
5
Przestarzałość

Brak sygnałów. Repozytorium zmienione 08.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

Co sprawdzić przed instalacją
  • 1 skrypt w paczce. Przejrzyj je przed instalacją, bo Claude może je uruchomić.

Skrypty: scripts/ncbi_fetch.py

Co robi i kiedy

Pobiera sekwencje białek i nukleotydów z baz NCBI przez E-utilities, po numerze akcesyjnym, nazwie genu lub identyfikatorze PubMed.

Oryginalny opis (EN)

Retrieve protein and nucleotide sequences from NCBI databases using E-utilities. Supports direct accession lookup, CDS translation, gene+organism search, locus lookup, PubMed-linked sequences, patent protein extraction, and organism+length fallback search. Use when you need to fetch biological sequences by accession, gene name, locus tag, PubMed ID, or patent number.

Jak działa

  1. Prerequisites
  2. Core Rules
  3. Overview
  4. Utility Scripts
  5. Workflow
  6. Reference
Sekcje z nagłówków SKILL.md, w oryginale · 230 linii, 1 205 słów
Podgląd SKILL.md
---
name: ncbi-sequence-fetch
description: 'Retrieve protein and nucleotide sequences from NCBI databases using
  E-utilities. Supports direct accession lookup, CDS translation, gene+organism search,
  locus lookup, PubMed-linked sequences, patent protein extraction, and organism+length
  fallback search. Use when you need to fetch biological sequences by accession, gene
  name, locus tag, PubMed ID, or patent number.

  '
metadata:
  category: sequence
  legacy_category: databases
  taxonomy_version: enzyme-agent/taxonomy/v1
  capability_ids:
  - sequence.analysis
---

# NCBI Sequence Fetch

## Prerequisites

1.  **Python**: Run scripts directly with `python`; do not require `uv` unless the script explicitly fails without it.
2.  **User Notification**: If LICENSE_NOTIFICATION.txt does not already exist in
    this skill directory then (1) prominently notify the user to check the terms
    at https://www.ncbi.nlm.nih.gov/ and
    https://www.ncbi.nlm.nih.gov/home/about/policies/, then (2) create the file
    recording the notification text and timestamp.
3.  **`.env` file**: Make sure the `.env` file exists in your home directory.
    Create one if it does not exist.
4.  **`NCBI_API_KEY`** (optional): Raises the NCBI rate limit from 3 to 10
    requests/second. The skill works without it, but a key is recommended if the
    user plans many queries or encounters a 429 error. The user can obtain one
    for free by registering at https://www.ncbi.nlm.nih.gov/account/settings/.
    If the variable is missing from `.env`, do NOT ask the user to paste it into
    the chat (this would leak the key into the agent's context). Instead, give
    the user this command — **substituting `ENV_FILE` with the resolved literal
    path to the `.env` file**:

    ```bash
    printf "Enter NCBI API key (typing hidden): " && read -s key && echo && echo "NCBI_API_KEY=$key" >> "ENV_FILE" && echo "Saved."
    ```

    The scripts load credentials automatically via `dotenv`. **NEVER** read,
    print, or inspect the `.env` file or its variables (e.g. no `cat`, `grep`,
    `echo`, `printenv`, or `os.environ.get` on keys). Credentials must stay out
    of the agent's context.

## Core Rules

-   **Use the Wrapper**: ALWAYS execute the provided helper scripts to query the
    database rather than accessing the database directly. The scripts
    automatically enforce the required rate limit gracefully.
-   **API Key Support**: If the user provides an `NCBI_API_KEY` in their
    environment, the query speed limits are automatically increased
    significantly.
-   **Notification**: If this skill is used, ensure this is mentioned in the
    output.

## Overview

Wraps NCBI's Entrez E-utilities (efetch, esearch, elink, esummary) for
retrieving protein and nucleotide sequences. Provides 10 subcommands covering
the full range of sequence retrieval workflows:

-   `fetch-protein` — Direct protein accession lookup (GenPept, RefSeq)
-   `fetch-nucleotide` — Direct nucleotide accession lookup
-   `cds-translate` — Fetch CDS and translate to protein (3 methods)
-   `search` — Free-text search of any NCBI database
-   `elink` — Follow cross-database links (PubMed→Protein, etc.)
-   `gene-protein` — Search protein by gene name + organism
-   `locus-protein` — Search protein by locus tag + organism
-   `pubmed-proteins` — Find proteins linked to a PubMed article
-   `patent-search` — Extract protein sequences from patents
-   `organism-length` — Last-resort search by organism + exact AA length

## Utility Scripts

**`scripts/ncbi_fetch.py`** — Single script with subcommands.

All subcommands write structured JSON output. Use `--output FILE` to save to a
file, or omit it to print to stdout. A human-readable summary is always printed
to stdout.

### 1. Fetch Protein by Accession

Fetches protein FASTA from NCBI by accession (XP_, NP_, GenPept, etc.)

```bash
python scripts/ncbi_fetch.py fetch-protein XP_022033624 -o /tmp/result.json
python scripts/ncbi_fetch.py fetch-protein NP_001234567 ABC12345.1
```

### 2. Fetch Nucleotide by Accession

Fetches nucleotide FASTA from NCBI by accession.

```bash
python scripts/ncbi_fetch.py fetch-nucleotide MK034466 -o /tmp/result.json
```

### 3. CDS Translate

Fetches a CDS/nucleotide accession and translates to protein sequence. Tries
three approaches in order: 1. NCBI's pre-translated CDS protein (`fasta_cds_aa`)
2. GenBank XML CDS annotation translations 3. Raw nucleotide → 6-frame ORF
finding

```bash
python scripts/ncbi_fetch.py cds-translate MK034466 -o /tmp/result.json
python scripts/ncbi_fetch.py cds-translate HQ662330 --target-length 1043
```

If the accession is a **genomic record** (not mRNA/CDS), the tool will report
`is_genomic: true` so you can fall back to a homology-based approach instead.

### 4. Search Any Database

Free-text search using Entrez query syntax. Supports all NCBI databases.

```bash
# Search protein database
python scripts/ncbi_fetch.py search "WRR4B[Gene Name] AND Arabidopsis[Organism]" \
  --database protein --retmax 5 --fetch-sequences

# Search nucleotide database
python scripts/ncbi_fetch.py search "Rz2[Gene Name] AND Beta vulgaris[Organism]" \
  --database nuccore --retmax 10

# Search with patent filter
python scripts/ncbi_fetch.py search "disease resistance AND Solanum[Organism] AND patent[Properties]" \
  --database protein --fetch-sequences

# Search by sequence length
python scripts/ncbi_fetch.py search '"Oryza sativa"[Organism] AND 1043[SLEN]' \
  --database protein --fetch-sequences --retmax 50
```

### 5. Cross-Database Links (elink)

Follow NCBI's cross-database links (e.g., PubMed article → linked proteins).

```bash
python scripts/ncbi_fetch.py elink 24896089 --dbfrom pubmed --db protein \
  --fetch-sequences -o /tmp/linked.json
```

### 6. Gene + Organism Search

Searches for protein sequences by gene name and organism. Searches NCBI Protein
with `[Gene Name]` and `[Organism]` qualifiers.

```bash
python scripts/ncbi_fetch.py gene-protein WRR4B --organism "Arabidopsis thaliana"
python scripts/ncbi_fetch.py gene-protein Pikh-2 --organism "Oryza sativa" \
  --target-length 1043 -o /tmp/result.json
```

### 7. Locus Tag Search

Searches by locus tag in both NCBI Protein and Nuccore databases. Extracts CDS
translations from GenBank XML when direct protein hits aren't available.

```bash
python scripts/ncbi_fetch.py locus-protein At1g56540 --organism "Arabidopsis thaliana"
python scripts/ncbi_fetch.py locus-protein Niben101Scf02422g02015.1 \
  --organism "Nicotiana benthamiana" -o /tmp/result.json
```

### 8. PubMed-Linked Proteins

Finds protein sequences linked to a PubMed article. Searches NCBI Protein by
PMID, follows elink PubMed→Protein, and extracts CDS translations from linked
Nuccore records.

```bash
python scripts/ncbi_fetch.py pubmed-proteins 30692254 --identifier WRR4B
python scripts/ncbi_fetch.py pubmed-proteins 24896089 --identifier "K2" \
  -o /tmp/result.json
```

### 9. Patent Sequence Search

Two modes:

**By patent number** — fetches all protein sequences from a specific patent:
`bash python scripts/ncbi_fetch.py patent-search --patent-number US10123456 -o
/tmp/patent.json`

**By keywords** — searches NCBI Protein with `patent[Properties]` filter: `bash
python scripts/ncbi_fetch.py patent-search --keywords WRR4B Albugo --organism
"Arabidopsis thaliana" -o /tmp/patent.json`

> [!IMPORTANT] **Patent convention**: In molecular biology patents, SEQ ID NO: 1
> is typically the DNA sequence and SEQ ID NO: 2 is the primary protein. Higher
> SEQ ID NOs are variants or related sequences. Prefer Sequence 2 when selecting
> the primary protein of interest.

### 10. Organism + Length Search

Last-resort search when only organism and expected protein length are known.
Uses NCBI's `[SLEN]` filter for exact length matching.

```bash
python scripts/ncbi_fetch.py organism-length \
  --organism "Arabidopsis thaliana" --length 1048 --retmax 50 \
  -o /tmp/result.json
```

> [!NOTE] This often returns multiple candidates. Use the JSON output headers to
> identify the correct protein.

## Workflow

### Standard Sequence Retrieval Cascade

When trying to find a protein sequence, follow this priority order:

1.  **Direct accession** — `fetch-protein` with GenPept/RefSeq accession
2.  **CDS translation** — `cds-translate` with nucleotide/CDS accession
3.  **PubMed-linked** — `pubmed-proteins` with PMID + gene name
4.  **Locus lookup** — `locus-protein` with locus tag + organism
5.  **Gene + organism** — `gene-protein` with gene name + organism
6.  **Patent search** — `patent-search` with patent number or keywords
7.  **Organism + length** — `organism-length` as last resort

### Interpreting Results

-   All subcommands return JSON with a `results` array
-   Each result has `sequence` (AA string), `length`, and `header`/metadata
-   When multiple results are returned, select by:
    -   Closest match to expected length (`target_length`)
    -   Header relevance (matching gene name, "disease resistance" keywords)
    -   Source priority (RefSeq > GenPept > patent)

## Reference

-   **NCBI E-utilities docs**: https://www.ncbi.nlm.nih.gov/books/NBK25499/
-   **Entrez search syntax**: https://www.ncbi.nlm.nih.gov/books/NBK49540/
-   **Database list**: protein, nuccore, gene, pubmed, pmc, biosample, etc.
-   **Common accession formats**:
    -   `XP_` / `NP_` — NCBI RefSeq protein
    -   `AAA` to `AZZ` + digits — GenPept (translated GenBank)
    -   `MK`, `MN`, `HQ`, etc. + digits — GenBank nucleotide
    -   `ENSG`, `ENST`, `ENSP` — Ensembl (use `ensembl-database` skill instead)
    -   `Q`, `P`, `O` + digits — UniProt (use `uniprot-database` skill instead)
Pliki w paczce (8)
  • SKILL.md 10 KB
  • execution_profile.json 1 KB
  • scientific_contract.yaml 1 KB
  • stability_evidence.json 1 KB
  • agents/openai.yaml 1 KB
  • fixtures/stability/invalid.json 1 KB
  • fixtures/stability/valid.json 1 KB
  • scripts/ncbi_fetch.py 35 KB

Wersje

RepozytoriumWynikLicencja
Ta strona · ekko8600/enzyme_design_harness100Apache-2.0
google-deepmind/science-skills95Apache-2.0
mkurman/zorai95MIT

Migawka bazy z 13.11.2026 · wersja paczki f94d7c2d0a9a (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 1 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100tooluniverse-sequence-retrieval
    Pobiera sekwencje DNA, RNA i białek z NCBI i ENA, z ujednoznacznieniem genów i obsługą numerów akcesyjnych.
  • 95pubmed-database
    Przeszukuje PubMed przez NCBI E-utilities: zapytania MeSH, wyszukiwanie PMID, cytowania i monitoring literatury.
  • 100ncbi-entrez
    Odpytuje NCBI E-utilities o sekwencje z GenBank, informacje o genach, SNP-y, warianty ClinVar i powiązania z literaturą.
  • 95pubmed-database
    Prowadzi wyszukiwanie w PubMed i NCBI E-utilities: zapytania MeSH, wyszukiwanie PMID i pobieranie cytowań z literatury biomedycznej.
  • 100scientific-db-pubmed-database
    Prowadzi wyszukiwanie w PubMed i NCBI E-utilities: literatura biomedyczna, zapytania MeSH, wyszukiwanie po PMID, pobieranie cytowań i monitoring literatury przez API.
  • 95gene_comprehensive_lookup
    Zbiera dane o genie z NCBI, Ensembl i UniProt oraz szlaki KEGG po nazwie genu lub białka.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.