{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Download case files and QC","description":"Reference, guides and recipes for the Franklin API — create cases, link sample files, retrieve variants and reports."},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"download-case-files-and-qc","__idx":0},"children":["Download case files and QC"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Get a case's alignment and variant files, QC metrics and exports back out of Franklin, for archiving, a LIMS, or downstream analysis."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["All file endpoints return ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["pre-signed URLs"]},", not the files themselves. Download each URL with a plain ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GET"]}," and ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["no"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Authorization"]}," header. The URLs expire quickly, so download immediately and never store them."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"alignment-files","__idx":1},"children":["Alignment files"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/api/openapi/file-locations/getbamlocationv2"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["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:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"r = client.request(\"GET\", \"/v2/analysis/bam_location\", params={\"analysis_id\": 12345})\nr.raise_for_status()\nloc = r.json()\nif loc.get(\"error\"):\n    raise RuntimeError(loc[\"error\"])\nfor name in (\"bam\", \"bai\", \"bam_checksum\", \"bai_checksum\", \"rna_bam\", \"rna_bai\"):\n    if loc.get(name):\n        download(loc[name], f\"12345.{name}\")\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Fields for files the case doesn't have are ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["null"]},". Use the checksum files to verify large BAM downloads."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"variant-files","__idx":2},"children":["Variant files"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/api/openapi/file-locations/getvcflocation"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GET /v1/analysis/vcf_location"]}]}," returns lists of URLs, since a case can have several VCFs of each kind:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"loc = client.request(\"GET\", \"/v1/analysis/vcf_location\", params={\"analysis_id\": 12345}).json()\nfor kind in (\"snp_vcfs\", \"sv_vcfs\", \"repeat_vcfs\"):\n    for i, url in enumerate(loc.get(kind) or []):\n        download(url, f\"12345.{kind}.{i}.vcf.gz\")\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"qc-metrics","__idx":3},"children":["QC metrics"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/api/openapi/qc-metrics/getqcmetrics"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["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:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"qc = client.request(\"GET\", \"/v1/analysis/qc_metrics\", params={\"analysis_id\": 12345}).json()\nfor sample in qc[\"samples_qc\"]:\n    for m in sample[\"sample_qc_metrics\"][\"range_metrics\"]:\n        print(m[\"name\"], m[\"value\"], m[\"status\"])       # e.g. Mean Coverage 125.5 PASS\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"exports","__idx":4},"children":["Exports"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Export"},"children":["Export"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Endpoint"},"children":["Endpoint"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Returns"},"children":["Returns"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["All SNP variants, one file per sample"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/api/openapi/analysis-export/exportanalysissnpvariants"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GET /v1/analysis/export/variants/snp"]}]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sample_name"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["download_link"]}," for each sample"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Case history (audit log)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/api/openapi/analysis-export/exportanalysishistory"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GET /v1/analysis/export/history"]}]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["One download link"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Coverage as CSV, optionally limited to panels or phenotype genes"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/api/openapi/analysis-export/exportcoveragecsv"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /v1/analysis/export/coverage_csv"]}]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["One download link"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Variants flagged for orthogonal confirmation, e.g. Sanger"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/api/openapi/analysis-export/exportorthogonalconfirmationvariants"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GET /v1/analysis/export/orthogonal_confirmation_variants"]}]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["download_url"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Quick-filter variants, by link or email"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/api/openapi/analysis-export/exportquickfiltervariants"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GET /v1/analysis/export/quick_filters_variants"]}]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["download_url"]},", or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["email_sent: true"]}]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To page through variants directly instead of downloading a file, use ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/api/openapi/analysis-query/getanalysissnpvariants"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GET /v2/analysis/variants/snp"]}]}," and ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/api/openapi/analysis-query/getanalysissvvariants"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/v2/analysis/variants/sv"]}]},". They return up to 500 per page, 200 by default."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"helper","__idx":5},"children":["Helper"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import requests\n\ndef download(url, path, chunk=1 << 20):\n    with requests.get(url, stream=True, timeout=600) as r:    # pre-signed: no auth header\n        r.raise_for_status()\n        with open(path, \"wb\") as f:\n            for part in r.iter_content(chunk):\n                f.write(part)\n","lang":"python"},"children":[]}]},"headings":[{"value":"Download case files and QC","id":"download-case-files-and-qc","depth":1},{"value":"Alignment files","id":"alignment-files","depth":2},{"value":"Variant files","id":"variant-files","depth":2},{"value":"QC metrics","id":"qc-metrics","depth":2},{"value":"Exports","id":"exports","depth":2},{"value":"Helper","id":"helper","depth":2}],"frontmatter":{"seo":{"title":"Download case files and QC"}},"lastModified":"2026-09-30T21:14:32.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/recipes/download-case-files","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}