Skip to content
Last updated

From workbench to signed report

When your analysts have reviewed a case in Franklin, the variants they selected are in its workbench. This recipe pulls those variants back into your system, produces the report, and downloads the signed PDF.

1. Get the workbench

GET /v1_3/analysis/workbench returns the selected SNVs, SVs and compound pairs, the case's panels and comments, and germline biomarkers (UPD, SMN, GBA, HBA).

r = client.request("GET", "/v1_3/analysis/workbench", params={"analysis_id": "12345"})
r.raise_for_status()
wb = r.json()

for v in wb["snp_variants"]:
    tx = v["annotations"]["transcripts"][0]
    print(tx["gene"], tx["transcript"], tx["hgvc_c"], tx["hgvc_p"],
          v["sample_data"]["zygosity"], v["classification"]["acmg_classification"])
Response partContains
snp_variants[]variant (coordinates), sample_data (depth, VAF, zygosity, inheritance), annotations (transcripts, frequencies, predictions, ClinVar), classification (ACMG call, rules, tags), variant_franklin_link
sv_variants[]The same structure for structural variants and CNVs
compound_snp_variants[], compound_snp_sv_variants[]Compound-heterozygous pairs
case_detailsPanels and case comments
biomarkersUPD, SMN, GBA and HBA results

Oncology cases use /v1_3/somatic_analysis/workbench instead. It adds TMB, MSI, HRD, MMR and MET exon 14 skipping.

2. Produce the report

Pick one of two paths.

A: Your analysts build and sign the report in Franklin. Nothing to call; go to step 3 once it's signed.

B: Automated reporting from the workbench. POST /v1/analysis/workbench/generate_report adds every workbench variant to the report, fills in missing interpretations, and publishes the report, for many cases at once:

r = client.request("POST", "/v1/analysis/workbench/generate_report",
                   json={"analysis_ids": ["12345", "12346"]})
r.raise_for_status()
for analysis_id, result in r.json()["reports"].items():
    if result.get("error"):
        print(analysis_id, "failed:", result["error"])
    else:
        print(analysis_id, "report", result["report_id"])

The call returns 200 even when some cases fail. Check each entry's error.

To publish a report that already has its variants, without regenerating it, call POST /v1/analysis/report/publish with {"analysis_id": "12345"}. Publishing makes it the official signed report, and a report with no variants can't be published.

3. Download the signed report

GET /v1/analysis/signed_report_file with format set to pdf, doc or docx:

r = client.request("GET", "/v1/analysis/signed_report_file",
                   params={"analysis_id": "12345", "format": "pdf"})
r.raise_for_status()
body = r.json()
if body.get("download_link"):
    pdf = requests.get(body["download_link"]).content     # pre-signed URL, no auth header
    open("12345.pdf", "wb").write(pdf)
else:
    print("not available:", body.get("error"))

The link is pre-signed and short-lived, so download it right away and don't store the URL.

Find newly signed reports

Instead of polling each case, list the reports signed since your last run with GET /v1/reports/list:

r = client.request("GET", "/v1/reports/list", params={
    "signed_after": "2024-01-15T00:00:00Z",   # ISO-8601 with timezone, or a Unix timestamp
    "report_status": ["FINAL", "AMENDED"],
    "ordering": "signed_date",
    "page_number": 1,
})
page = r.json()          # {"num_pages": 5, "page_number": 1, "reports": [...]}

Each entry has analysis_id, report_id, report_status, signed_at and signed_by. Only the latest report per case is listed. Page through with page_number up to num_pages. A date without a timezone, such as 2024-01-15, is rejected with 400.

Other report outputs

NeedEndpoint
The report as structured JSONGET /v3_4/analysis/report
The current report as a PDF, DOC, DOCX or HTML fileGET /v1/analysis/report_file
Report data for rendering in your own template engineGET /v1/report