Repository navigation
fix: rebuild consensus predictions when weights change on re-run (#100) - #105
Merged
nextgenusfs merged 3 commits intoOct 25, 2026
Merged
Conversation
…tgenusfs#100) On a re-run, predict reused misc/consensus.predictions.gff3 whenever it existed, so new -w/--weights were calculated and logged but never used (nextgenusfs#100). The UTR-refined consensus was reused the same way. The weights used to build the consensus are now recorded in consensus.predictions.weights.json. On re-run the consensus is reused only if the current weights match the record; otherwise (or when there is no record, e.g. a run folder from before this change) the stale consensus, UTR-refined consensus, pre-refinement backup and record are removed and consensus is regenerated, with the reason logged. The decision and file removal live in small helpers in utilities.py, covered by tests/unit/test_utilities_consensus.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Define the UTR-refined and pre-refinement backup paths once, before the consensus rebuild check, instead of again inside the UTR-refinement block, and read the weights record with the existing load_json helper. No behaviour change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ence inputs change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #100.
Problem
Re-running
predictinto an existing output folder with different-w/--weightsgave identical results. The new weights were calculated and logged ("Calculated ab initio weights from data: …"), but the consensus step reusedmisc/consensus.predictions.gff3whenever it existed. Sogenerate_consensusnever saw the new weights. When a BAM was given, the UTR-refined consensus was reused the same way, so even a rebuilt consensus would have been replaced by the stale refined file.(The other symptom in #100, a requested
augustus-hiqweight being overridden on a fresh run, was already fixed in c3c7da8.)Fix
After consensus is generated, the weights it was built with are written to
misc/consensus.predictions.weights.json.On a re-run, the existing consensus is reused only if the current weights match that record, in any order. Otherwise these files are removed and consensus is regenerated:
The log says why, e.g.
Re-generating consensus predictions: weights changed (helixer: 2 -> 4).A consensus with no record, such as a run folder from before this change, is treated as stale and rebuilt once. Its weights are unknown, and reusing it is the bug being fixed.
The record is written only after
generate_consensusreturns. A failed run leaves no record, so the next run rebuilds.The decision and file removal live in three small helpers in
utilities.py.predict()just calls them at the existing checkpoint. Only the weights trigger a rebuild. Other consensus inputs (max intron, the set of prediction files, alignments) keep today's reuse behaviour.Tests
New
tests/unit/test_utilities_consensus.py(12 tests) covers:Full suite run locally on Windows: 261 passed on this branch vs 249 on
main, a difference of exactly the 12 new tests. The failure and collection-error set is identical on both: CLI/subprocess tests, the/tmptmpdir test, and modules that needgapmm2, which doesn't build on Windows. That's whytest_predict*.pydidn't run locally.The tests cover the helpers, not a full
predictrun. The existingtest_predict.pydoesn't call the realpredict(), and I haven't run the pipeline end-to-end on a genome with these changes.Possible follow-up
The same staleness applies to the other consensus inputs. Relatedly, re-runs reuse
abinitio_algorithm_scoring.json, so a new-eprediction added on a re-run isn't scored and only gets a weight if-wnames it. Happy to extend the record to cover those if useful.🤖 Generated with Claude Code