Re-sending a single-sample VCF through the backend API leaves the old VCF linked to the sequencing run alongside the new one

Open
#2,923 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
64/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
django, python

Research direction

Read seqauto/upload_links.py, especially create_backend_vcf_links and link_samples_and_vcfs_to_sequencing, to trace how the old upload link is lost before the run VCF is removed. Add a test that sends the same caller's file twice and checks the sequencing run has only one VCF for that caller.

Written by the indexing model from the issue text.

Description

🤖 Written by Claude

Problem

When a pipeline re-sends a single-sample VCF through the backend API (same registered SingleSampleVCF path, new content), the earlier VCF from that caller is meant to be unlinked from the sequencing run and replaced. It isn't: the run ends up with both VCFs for the same caller. Anything built from the run then shows both sets of calls. For example, a Specimen-level auto-launched analysis (#2898) lists both the old and the new VCF in its sample node.

Found in agent testing of #2898 (https://github.com/SACGF/variantgrid/issues/2898#issuecomment-7187938517): after re-sending one arm's CNV file, VCFFromSequencingRun held both VCFs for that caller. This predates #2898: the code has worked this way since #2490.

Cause

seqauto/upload_links.py:create_backend_vcf_links runs first and calls BackendVCF.objects.update_or_create(single_sample_vcf=..., defaults={"uploaded_vcf": <new upload>}). That repoints the one BackendVCF from the old upload to the new one.

seqauto/upload_links.py:link_samples_and_vcfs_to_sequencing then looks for the earlier VCF to remove with vcf__uploadedvcf__backendvcf__single_sample_vcf__variant_caller=.... The old VCF's UploadedVCF no longer has a BackendVCF, so the query only finds the new one (or nothing), and the old VCFFromSequencingRun stays.

Proposed

Find the VCF being replaced without going through the BackendVCF that was just repointed. Either read the BackendVCF's previous uploaded_vcf before the update, or match VCFFromSequencingRun rows by the sequencing sample and the SingleSampleVCF's variant caller as recorded on the row. Add a test that sends one file twice and checks the run is left with one VCF for that caller.

Related: #1192 (reload a VCF in place, a separate feature).

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.