Auto-launch analysis templates by variant caller / VCF source, and per extraction / specimen / patient

Open
#2,898 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend, data

Research direction

Start with analysis/models/models_analysis.py:AutoLaunchAnalysisTemplate and analysis/tasks/auto_analysis_tasks.py:auto_run_analyses_for_vcf, then read SampleNode/SampleSourceLevel and AnalysisVariable to see how launch levels map to template variables. Follow seqauto/upload_links.py and patients/tasks/extraction_matching_tasks.py for late group membership, and VCFSourceSettings for source matching. Done means the new criteria and launch level are visible on analysis/views/views.py:analysis_templates_auto_launch, with a per-group run dedupe model and tests covering complete, error and re-sequencing cases.

Written by the indexing model from the issue text.

Description

Analysis Templates

🤖 Written by Claude

Problem

Auto-launched analysis templates are matched only by enrichment kit and a sample-name regex (analysis/models/models_analysis.py:AutoLaunchAnalysisTemplate), and they launch once per sample on VCF import (analysis/tasks/auto_analysis_tasks.py:auto_run_analyses_for_vcf).

A DRAGEN TSO 500 case arrives as several files across two arms: DNA small variants, gene-level CNV, exon CNV, RNA fusions and RNA splice calls. All share the kit and name their samples alike. Today each file gets its own analysis from the same template. What we want is one analysis per case, with a SampleNode above sample level that holds every arm. SampleNode already supports this (SampleSourceLevel: Sample / Extraction / Specimen / Patient). The two arms of a TSO 500 pair meet at the Specimen: the CombinedVariantOutput import creates the pair's Specimen with a DNA and an RNA Extraction under it.

Proposal

Matching

Add two optional criteria to an auto-launch rule. As with the existing ones, blank means "anything".

  • Variant caller(s): match on the SingleSampleVCF.variant_caller the pipeline registered, which already says what kind of file each one is (e.g. TSO_dragen_cnv_caller, TSO_fusion_caller). This is for deployments posting through the seqauto API.
  • VCF source regex: match against VCF.source (the ##source header), the way VCFSourceSettings does. This is for deployments uploading through the upload page, where there is no SingleSampleVCF.
Launch level

A rule has a launch level: Sample (today's behaviour), Extraction, Specimen or Patient. The template's SampleNode makes the matching field (sample / extraction / specimen / patient) its AnalysisVariable. AnalysisVariable already handles any FK, so no new template mechanism is needed. Sample-level and group-level rules are independent: a deployment configures whichever it wants, and both may fire for the same sample.

When a group launches
  • Expected files: the SingleSampleVCFs registered against the group's SequencingSamples on one sequencing run.
  • Launch: once every expected file has a VCF that imported successfully. The check runs on VCF import success and also when a sample is linked to its extraction (seqauto/upload_links.py, patients/tasks/extraction_matching_tasks.py), since group membership can arrive after the VCFs.
  • Any expected file in an error state: no launch. That is deliberate: an incomplete case analysis is worse than none, and a missing analysis forces the import to be fixed. It should be visible why it didn't launch (e.g. an event log entry), not silent.
  • Re-sequencing: a later run on the same specimen/patient is its own completeness set and gets its own analysis. An analysis already reported from doesn't change underneath anyone.
  • Uploads with no SingleSampleVCF (upload page): there is no expected set, so the group launches on its first matching VCF, and later VCFs in the group reload it (as re-imports already do via reload_auto_analyses_for_vcf).
Dedupe

A run record per (template, group object, sequencing run), alongside SampleAnalysisTemplateRun / CohortAnalysisTemplateRun, so each template runs once per group per run.

Notes

  • For a TSO 500 deployment the expected setup is: a Specimen-level rule matched on kit + callers, with source left blank.
  • The auto-launch test page (analysis/views/views.py:analysis_templates_auto_launch) should show the new criteria and the launch level.
  • Related but separate: #687 (batch running a template over a VCF's samples).
Dominant language
Python
Stars
31
Forks
4
Avg merge
4h 52m
Merged PRs (30d)
183

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SACGF/variantgrid

All issues in SACGF/variantgrid

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.