Skip to content

Add optional per-seed match dates to include_samples - #625

Open
jeromekelleher wants to merge 2 commits into
mainfrom
force-seed-date
Open

Add optional per-seed match dates to include_samples#625
jeromekelleher wants to merge 2 commits into
mainfrom
force-seed-date

Conversation

@jeromekelleher

Copy link
Copy Markdown
Member

Opening this so we can see it, but probably won't be merged.

Each include_samples entry may now be a (strain, match_date) tuple in
addition to a bare strain ID. A non-None match_date matches the seed in
on that date instead of its actual date; it may be before the actual
date, in which case the seed node retains its actual date via a negative
("in the future") node time relative to the match-day time-zero. This
lets widely-diverged seeds (e.g. Omicron BA.1/BA.2/BA.3) be matched in on
the same early day so a rudimentary ancestry tree forms before other
tree building, instead of matching to derived samples with many
reversions.

Also detach future (negative-time) nodes when setting up match_tsinfer,
so that other samples cannot copy from a node that lies in the future
relative to the current time-zero.
@codecov-commenter

codecov-commenter commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.24%. Comparing base (3c342d8) to head (2656af6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #625      +/-   ##
==========================================
+ Coverage   88.13%   88.24%   +0.11%     
==========================================
  Files          12       12              
  Lines        4163     4204      +41     
  Branches      596      606      +10     
==========================================
+ Hits         3669     3710      +41     
  Misses        363      363              
  Partials      131      131              
Flag Coverage Δ
python-tests 88.24% <100.00%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

A seed strain in include_samples that is not present in the dataset now
raises a ValueError up-front in extend() instead of being silently
warned-and-skipped, so typos and bad configs fail fast. The no-alignment
corner case is handled the same as for any other sample (no seed-specific
path).

detach_future_nodes now fully detaches negative-time nodes: in addition
to removing incident edges, it drops mutations over those nodes and
clears their NODE_IS_SAMPLE flag so the matcher cannot treat them as
ancestors, recomputing mutation parents afterwards. Node IDs and times
are preserved.

Rewrite the detach_future_nodes tests with hand-drawn topologies
(including recombination) following the conventions in test_tree_ops.py.
@jeromekelleher
jeromekelleher marked this pull request as ready for review July 28, 2026 20:40
@jeromekelleher

Copy link
Copy Markdown
Member Author

This should work now, and allow us to do something like this:

include_samples = [
  #BA.1
"SRR17089889", #	2021-11-13	OXFORD_NANOPORE	South Africa
"SRR17089888", #	2021-11-13	OXFORD_NANOPORE	South Africa

# BA.2 - forced in on the day after BA.1
["SRR17089886", "2021-11-14"], 	# 2021-11-17	OXFORD_NANOPORE	South Africa
# BA.3 - also forced in same day as BA.2?
"SRR17258788",  "2021-11-14"], # 2021-11-30	OXFORD_NANOPORE	South Africa
...
]

So, the include_samples array now has entries of two forms:

  1. The existing sample_id string a
  2. A tuple [sample_id, override_date], which specifies the sample ID and its override date.

The sample will be inserted at its real date, meaning that it is initially inserted as a "future" node (negative time). This PR also includes a function to detach future nodes so that they are not available for matching against.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants