Genomics
Variant annotation, GWAS lookups, and gene search pipelines using direct tool calls and file upload/download.
Upload → annotate → download a VCF
Upload a raw VCF, run GATK variant annotation, then download the annotated output.
from smartsbio import SmartsBio
client = SmartsBio(api_key="sk_live_...")
ws_id = client.workspaces.list()[0].id
# 1. Upload the raw VCF
upload = client.files.upload("sample.vcf", workspace_id=ws_id, path="raw/")
vcf_key = upload["key"]
print(f"Uploaded: {vcf_key}")
# 2. Run GATK annotation tool
result = client.tools.run(
tool_id="gatk_variant_annotation",
input={
"file_path": vcf_key,
"workspace_id": ws_id,
"annotations": ["ClinVar", "gnomAD_AF", "CADD", "dbSNP"],
"output_path": "annotated/",
},
)
print(f"Status: {result['status']}")
annotated_key = result["output_path"]
# 3. Download the annotated VCF
local = client.files.download(annotated_key, workspace_id=ws_id, dest="./output/")
print(f"Saved to {local}")import { SmartsBio } from '@smartsbio/sdk';
const client = new SmartsBio({ apiKey: 'sk_live_...' });
const [workspace] = await client.workspaces.list();
// 1. Upload the raw VCF
const upload = await client.files.upload('./sample.vcf', {
workspaceId: workspace.id,
path: 'raw/',
});
console.log('Uploaded:', upload.key);
// 2. Run GATK annotation tool
const result = await client.tools.run('gatk_variant_annotation', {
input: {
filePath: upload.key,
workspaceId: workspace.id,
annotations: ['ClinVar', 'gnomAD_AF', 'CADD', 'dbSNP'],
outputPath: 'annotated/',
},
});
console.log('Status:', result.status);
// 3. Download the annotated VCF
const localPath = await client.files.download(result.outputPath, workspace.id, './output/');
console.log('Saved to', localPath);# 1. Upload the VCF
FILE_PATH=$(curl -s -X POST https://api.smarts.bio/v1/files/upload \
-H "Authorization: Bearer sk_live_..." \
-F "file=@sample.vcf" -F "workspace_id=ws_abc123" -F "path=raw/" \
| jq -r '.data.path')
# 2. Run GATK annotation
curl -s -X POST https://api.smarts.bio/v1/tools/gatk_variant_annotation/run \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d "{\"input\": {\"file_path\": \"$FILE_PATH\", \"workspace_id\": \"ws_abc123\", \"annotations\": [\"ClinVar\", \"gnomAD_AF\", \"CADD\", \"dbSNP\"], \"output_path\": \"annotated/\"}}" \
| jq '{status, output_path}'# 1. Upload the raw VCF smarts file upload sample.vcf --to raw/ # 2. Run GATK annotation tool smarts tool run gatk_variant_annotation \ --param file_path=raw/sample.vcf \ --param annotations=ClinVar,gnomAD_AF,CADD,dbSNP \ --param output_path=annotated/ # 3. Download the annotated VCF smarts file download annotated/sample.vcf -o ./output/
NCBI Gene lookup
Call the ncbi_search tool directly for structured gene records — no agent overhead, no prompt.
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"Location : chr{gene['chromosome']}:{gene['start']}-{gene['stop']}")
print(f"Summary : {gene['summary'][:300]}")import { SmartsBio } from '@smartsbio/sdk';
const client = new SmartsBio({ apiKey: 'sk_live_...' });
const result = await client.tools.run('ncbi_search', {
input: {
database: 'gene',
query: 'BRCA1[Gene Name] AND Homo sapiens[Organism]',
maxResults: 1,
},
});
const gene = result.results[0];
console.log('Gene ID :', gene.id);
console.log('Location:', `chr${gene.chromosome}:${gene.start}-${gene.stop}`);
console.log('Summary :', gene.summary.slice(0, 300));curl -X POST https://api.smarts.bio/v1/tools/ncbi_search/run \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"input": {
"database": "gene",
"query": "BRCA1[Gene Name] AND Homo sapiens[Organism]",
"maxResults": 1
}
}'# Direct structured gene lookup smarts tool run ncbi_search \ --param database=gene \ --param "query=BRCA1[Gene Name] AND Homo sapiens[Organism]" \ --param maxResults=1
GWAS lookup + agent interpretation
Fetch structured GWAS associations with a direct tool call, then stream the agent's clinical interpretation of the top hits.
from smartsbio import SmartsBio
client = SmartsBio(api_key="sk_live_...")
ws_id = client.workspaces.list()[0].id
# Step 1: structured GWAS data (direct tool call)
gwas = client.tools.run(
tool_id="gwas_catalog_search",
input={"trait": "type 2 diabetes", "pvalue_threshold": 5e-8, "limit": 10},
)
top_snps = gwas["associations"][:10]
print(f"Top {len(top_snps)} associations fetched")
# Step 2: streaming clinical interpretation
for chunk in client.query.stream(
prompt=f"Interpret these GWAS hits for type 2 diabetes: {top_snps[:3]}. "
"Focus on the nearest genes and their biological roles.",
workspace_id=ws_id,
):
if chunk.type == "content":
print(chunk.content, end="", flush=True)import { SmartsBio } from '@smartsbio/sdk';
const client = new SmartsBio({ apiKey: 'sk_live_...' });
const [workspace] = await client.workspaces.list();
// Step 1: structured GWAS data
const gwas = await client.tools.run('gwas_catalog_search', {
input: { trait: 'type 2 diabetes', pvalue_threshold: 5e-8, limit: 10 },
});
const topSnps = gwas.associations.slice(0, 10);
console.log(`Top ${topSnps.length} associations fetched`);
// Step 2: streaming interpretation
for await (const chunk of client.query.stream({
prompt: `Interpret these GWAS hits for type 2 diabetes: ${JSON.stringify(topSnps.slice(0, 3))}. Focus on the nearest genes and their biological roles.`,
workspaceId: workspace.id,
})) {
if (chunk.type === 'content') process.stdout.write(chunk.content ?? '');
}# Step 1: structured GWAS data (direct tool call)
TOP_SNPS=$(curl -s -X POST https://api.smarts.bio/v1/tools/gwas_catalog_search/run \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{"input": {"trait": "type 2 diabetes", "pvalue_threshold": 5e-8, "limit": 10}}' \
| jq '.associations[:3]')
echo "Top SNPs: $TOP_SNPS"
# Step 2: streaming clinical interpretation
curl -N -X POST https://api.smarts.bio/v1/query/stream \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d "{\"prompt\": \"Interpret these GWAS hits for type 2 diabetes: $TOP_SNPS. Focus on the nearest genes and their biological roles.\", \"workspace_id\": \"ws_abc123\"}"# Step 1: structured GWAS data (direct tool call) smarts tool run gwas_catalog_search \ --param trait="type 2 diabetes" \ --param pvalue_threshold=5e-8 \ --param limit=10 # Step 2: stream the agent's clinical interpretation of the top hits smarts query "Interpret the top GWAS hits for type 2 diabetes. \ Focus on the nearest genes and their biological roles."
Convert VCF to annotated TSV
Upload a VCF, convert to TSV with selected fields, then download for spreadsheet analysis.
from smartsbio import SmartsBio
client = SmartsBio(api_key="sk_live_...")
ws_id = client.workspaces.list()[0].id
# Upload
vcf = client.files.upload("variants.vcf", workspace_id=ws_id, path="input/")
# Convert to TSV
conv = client.tools.run(
tool_id="convert_format",
input={
"file_path": vcf["key"],
"workspace_id": ws_id,
"output_format": "tsv",
"fields": ["CHROM", "POS", "REF", "ALT", "QUAL", "INFO/AF", "INFO/DP"],
"output_path": "converted/",
},
)
# Download TSV
tsv_path = client.files.download(conv["output_path"], workspace_id=ws_id, dest="./")
print(f"TSV saved to {tsv_path}")import { SmartsBio } from '@smartsbio/sdk';
const client = new SmartsBio({ apiKey: 'sk_live_...' });
const [workspace] = await client.workspaces.list();
// Upload
const vcf = await client.files.upload('./variants.vcf', { workspaceId: workspace.id, path: 'input/' });
// Convert to TSV
const conv = await client.tools.run('convert_format', {
input: {
filePath: vcf.key,
workspaceId: workspace.id,
outputFormat: 'tsv',
fields: ['CHROM', 'POS', 'REF', 'ALT', 'QUAL', 'INFO/AF', 'INFO/DP'],
outputPath: 'converted/',
},
});
// Download TSV
const tsvPath = await client.files.download(conv.outputPath, workspace.id, './');
console.log('TSV saved to', tsvPath);# 1. Upload the VCF
FILE_PATH=$(curl -s -X POST https://api.smarts.bio/v1/files/upload \
-H "Authorization: Bearer sk_live_..." \
-F "file=@variants.vcf" -F "workspace_id=ws_abc123" -F "path=input/" \
| jq -r '.data.path')
# 2. Convert to TSV
curl -s -X POST https://api.smarts.bio/v1/tools/convert_format/run \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{"input": {"file_path": "'"$FILE_PATH"'", "workspace_id": "ws_abc123", "output_format": "tsv", "fields": ["CHROM","POS","REF","ALT","QUAL","INFO/AF","INFO/DP"], "output_path": "converted/"}}' \
| jq '{output_path}'# 1. Upload the VCF smarts file upload variants.vcf --to input/ # 2. Convert to TSV with selected fields smarts tool run convert_format \ --param file_path=input/variants.vcf \ --param output_format=tsv \ --param fields=CHROM,POS,REF,ALT,QUAL,INFO/AF,INFO/DP \ --param output_path=converted/ # 3. Download the TSV smarts file download converted/variants.tsv -o ./