Get a case's alignment and variant files, QC metrics and exports back out of Franklin, for archiving, a LIMS, or downstream analysis.
All file endpoints return pre-signed URLs, not the files themselves. Download each URL with a plain GET and no Authorization header. The URLs expire quickly, so download immediately and never store them.
GET /v2/analysis/bam_location returns the DNA BAM and BAI, the RNA BAM and BAI for tumor samples, and a checksum file for each:
r = client.request("GET", "/v2/analysis/bam_location", params={"analysis_id": 12345})
r.raise_for_status()
loc = r.json()
if loc.get("error"):
raise RuntimeError(loc["error"])
for name in ("bam", "bai", "bam_checksum", "bai_checksum", "rna_bam", "rna_bai"):
if loc.get(name):
download(loc[name], f"12345.{name}")Fields for files the case doesn't have are null. Use the checksum files to verify large BAM downloads.
GET /v1/analysis/vcf_location returns lists of URLs, since a case can have several VCFs of each kind:
loc = client.request("GET", "/v1/analysis/vcf_location", params={"analysis_id": 12345}).json()
for kind in ("snp_vcfs", "sv_vcfs", "repeat_vcfs"):
for i, url in enumerate(loc.get(kind) or []):
download(url, f"12345.{kind}.{i}.vcf.gz")GET /v1/analysis/qc_metrics returns QC for each sample in the case: categorical text metrics, and numeric range metrics with thresholds and a pass/fail status:
qc = client.request("GET", "/v1/analysis/qc_metrics", params={"analysis_id": 12345}).json()
for sample in qc["samples_qc"]:
for m in sample["sample_qc_metrics"]["range_metrics"]:
print(m["name"], m["value"], m["status"]) # e.g. Mean Coverage 125.5 PASS| Export | Endpoint | Returns |
|---|---|---|
| All SNP variants, one file per sample | GET /v1/analysis/export/variants/snp | sample_name and download_link for each sample |
| Case history (audit log) | GET /v1/analysis/export/history | One download link |
| Coverage as CSV, optionally limited to panels or phenotype genes | POST /v1/analysis/export/coverage_csv | One download link |
| Variants flagged for orthogonal confirmation, e.g. Sanger | GET /v1/analysis/export/orthogonal_confirmation_variants | download_url |
| Quick-filter variants, by link or email | GET /v1/analysis/export/quick_filters_variants | download_url, or email_sent: true |
To page through variants directly instead of downloading a file, use GET /v2/analysis/variants/snp and /v2/analysis/variants/sv. They return up to 500 per page, 200 by default.
import requests
def download(url, path, chunk=1 << 20):
with requests.get(url, stream=True, timeout=600) as r: # pre-signed: no auth header
r.raise_for_status()
with open(path, "wb") as f:
for part in r.iter_content(chunk):
f.write(part)