NCBI
Access NCBI's suite of databases — Gene, PubMed, Nucleotide, Protein, and more — via the ncbi_search and ncbi_fetch tools.
TOOL
ncbi_searchSearch any NCBI database using Entrez query syntax. Returns structured records.
| Parameter | Type | Description |
|---|---|---|
| database * | string | gene, pubmed, nucleotide, protein, snp, clinvar. |
| query * | string | Entrez query string, e.g. BRCA1[Gene] AND Homo sapiens[Organism]. |
| maxResults | integer | Records to return (default 10, max 100). |
| sort | string | relevance or date. |
Gene search
from smartsbio import SmartsBio
client = SmartsBio(api_key="sk_live_...")
result = client.tools.run(
tool_id="ncbi_search",
input={
"database": "gene",
"query": "BRCA1[Gene Name] AND Homo sapiens[Organism]",
"maxResults": 1,
},
)
gene = result["results"][0]
print(f"Gene ID : {gene['id']}")
print(f"Symbol : {gene['symbol']}")
print(f"Name : {gene['name']}")
print(f"Location : chr{gene['chromosome']}:{gene['start']}-{gene['stop']}")
print(f"Summary : {gene['summary'][:300]}")PubMed literature search
from smartsbio import SmartsBio
client = SmartsBio(api_key="sk_live_...")
ws_id = client.workspaces.list()[0].id
result = client.tools.run(
tool_id="ncbi_search",
input={
"database": "pubmed",
"query": "IDH1 R132H glioma AND 2020:2025[PDAT]",
"maxResults": 10,
"sort": "date",
"workspace_id": ws_id,
"output_format": "bibtex",
"output_path": "literature/",
},
)
print(f"Total hits : {result['total_hits']}")
for p in result["articles"][:5]:
print(f" PMID {p['pmid']} ({p['year']}) {p['title'][:65]}...")
# Download BibTeX
bib = client.files.download(result["output_path"], workspace_id=ws_id, dest="./refs/")
print(f"BibTeX saved to {bib}")Nucleotide sequence fetch
Download a nucleotide record by accession and save the FASTA to your workspace.
from smartsbio import SmartsBio
client = SmartsBio(api_key="sk_live_...")
ws_id = client.workspaces.list()[0].id
# Fetch NM_007294 (BRCA1 mRNA, RefSeq)
result = client.tools.run(
tool_id="ncbi_fetch",
input={
"database": "nucleotide",
"accession": "NM_007294",
"format": "fasta",
"workspace_id": ws_id,
"output_path": "sequences/",
},
)
print(f"Length : {result['sequence_length']} bp")
print(f"Path : {result['file_path']}")
# Download FASTA
fasta = client.files.download(result["file_path"], workspace_id=ws_id, dest="./sequences/")
print(f"FASTA saved to {fasta}")