1---2name: ncbi-blast-skill3description: Submit, poll, and summarize NCBI BLAST Common URL API jobs (Blast.cgi) for nucleotide or protein sequences. Use when a user wants RID status, BLAST results, or compact top-hit summaries; fetch raw Text/JSON2 only on request.4---56## Operating rules78- Use `scripts/ncbi_blast.py` for all concrete BLAST work.9- Honor NCBI limits: `>=10s` between requests and `>=60s` between polls for the same RID.10- Always surface the `RID` in the response so the job can be resumed or refetched later.11- If the conversation is long or multiple tool calls have occurred, refetch from the `RID` instead of trusting older context.12- If a prior turn saved raw output to disk, do not read it back into context unless the user asks for a specific follow-up.1314## Execution behavior1516- Return compact BLAST summaries first.17- Do not paste full `JSON2` or long Text alignments into chat by default.18- Default to `max_hits=5` and `max_queries=5`.19- If the user asks for raw output, write it to a file and report the path.20- Only provide Python code when the user explicitly asks for code or execution is unavailable.21- For normal user-facing answers, summarize the script JSON in markdown; if the user explicitly asks for machine-readable output, return the JSON verbatim.2223## Input2425- The script reads one JSON object from stdin.26- `action` must be one of `submit`, `status`, `fetch`, or `run`.27- `submit` and `run` require `program`, `database`, `query_fasta`, and `email` (or `NCBI_EMAIL`).28- `status` and `fetch` require `rid`.29- `program` must be one of `blastn`, `blastp`, `blastx`, `tblastn`, or `tblastx`.30- `result_format` defaults to `json2` for `run` and `fetch`.31- `tool` defaults to `NCBI_TOOL`, then `ncbi-blast-skill`.32- `max_hits` defaults to `5`; `max_queries` defaults to `5`.33- `hitlist_size` defaults to `50`; `descriptions` and `alignments` default to `5`.34- `wait_timeout_sec` defaults to `900`.35- `save_raw` defaults to `false`.36- If `save_raw=true` and `raw_output_path` is omitted, the script writes to `/tmp/ncbi-blast-<rid>.<json|txt>`.37- `query_fasta` may contain multi-FASTA input; compact summaries still cap per-query output with `max_hits` and `max_queries`.3839## Output4041- Common success fields: `ok`, `source`, `action`, `warnings`.42- `submit` returns `rid`, `rtoe_seconds`, and `status="SUBMITTED"`.43- `status` returns `rid`, normalized `status`, and `has_hits`.44- `run` and `fetch` with `result_format=json2` return `rid`, `status`, `has_hits`, `result_format`, `query_count_returned`, `query_count_available`, `query_summaries_truncated`, `query_summaries`, and `raw_output_path`.45- Each `query_summary` contains `query_title`, `hit_count_returned`, `hit_count_available`, `truncated`, and `top_hits`.46- Each `top_hit` contains `rank`, `accession`, `title`, `evalue`, and `bit_score`.47- `fetch` with `result_format=text` returns `text_head` capped at 800 characters unless `save_raw=true`; when `save_raw=true`, it returns only the artifact path.48- Failures return `ok=false`, `error.code`, `error.message`, and `warnings`.4950## Execution5152- Run `python scripts/ncbi_blast.py`.53- If `requests` is missing, install it once before first use with `python -m pip install requests`.5455```bash56echo '{"action":"run","program":"blastp","database":"swissprot","query_fasta":">q1\nMTEYK...","email":"you@example.com"}' | python scripts/ncbi_blast.py57```5859## References6061- Load `references/blast-common-url-api.txt` only for parameter details or uncommon BLAST options.62- Do not load `references/intent-notes.txt` during normal skill execution; it is not runtime guidance.