fix beauti clone bug and revive CloneTest #130 - #135
Merged
Conversation
Member
Author
|
Look OK now: <stateNode id="birthRate.t:29" spec="beast.base.spec.inference.parameter.RealScalarParam" domain="PositiveReal" value="1.0"/>
<stateNode id="kappa.s:26" spec="beast.base.spec.inference.parameter.RealScalarParam" domain="PositiveReal" value="2.0"/>
<stateNode id="freqParameter.s:26" spec="beast.base.spec.inference.parameter.SimplexParam" dimension="4" domain="UnitInterval">0.25 0.25 0.25 0.25</stateNode>
<stateNode id="freqParameter.s:29" spec="beast.base.spec.inference.parameter.SimplexParam" dimension="4" domain="UnitInterval">0.25 0.25 0.25 0.25</stateNode>
<stateNode id="kappa.s:29" spec="beast.base.spec.inference.parameter.RealScalarParam" domain="PositiveReal" value="2.0"/>
<stateNode id="freqParameter.s:47" spec="beast.base.spec.inference.parameter.SimplexParam" dimension="4" domain="UnitInterval">0.25 0.25 0.25 0.25</stateNode>
<stateNode id="kappa.s:47" spec="beast.base.spec.inference.parameter.RealScalarParam" domain="PositiveReal" value="2.0"/> |
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 #130
Summary
Cloning a site model (e.g. HKY, GTR) across partitions in BEAUti inflated the cloned
freqParameter's dimension from N to N² (4 → 16 for nucleotide frequencies), producing anXML file that BEAST could not run.
Bug location
BeautiDoc.deepCopyPlugin()inbeast-fx/src/main/java/beastfx/app/inputeditor/BeautiDoc.java(~line 2364-2395). When copying a
List-valued input, the code iterated once per elementof the source list, but on each iteration called
copy.setInputValue(input.getName(), input.get())— passing the entire source list, not the current element.
Input.setValue()appends allelements of a given list to the destination (
Input.java:452-461), so this would over-fill thecopy on every pass.
This was previously masked by a special case: if
copy instanceof Parameter.Base, the destinationlist was
clear()-ed before eachsetInputValuecall, so each pass reset-then-refilled to thecorrect size. But
Parameter.Base(beast.base.inference.parameter.Parameter.Base) is BEAST3'snow-
@Deprecatedlegacy parameter class. The new spec-based parameters used by BEAUti'ssite-model templates —
SimplexParam→RealVectorParam→KeyVectorParam→StateNode— nolonger extend it. So
copy instanceof Parameter.Baseisfalsefor aSimplexParam(e.g.freqParameter), theclear()never runs, and the whole source list gets appended once persource element: a dimension-4 list appends 4 times → 16 elements.
The bug was already documented by a disabled regression test:
beast-fx/src/test/java/test/beastfx/app/beauti/CloneTest.java—@Disabled("SimplexParam validation fails when freqParameter is cloned across partitions (dimension mismatch)").Fix
Stop iterating per-element for primitive-valued lists (the loop never used the per-element
value
oanyway — it always re-set the whole list). Instead, detect once whether the sourcelist holds primitives (vs.
BEASTInterfacesub-objects, which still need per-element deduphandling), clear the destination list a single time, and set it once:
This removes the stale
Parameter.Basecast, so it works uniformly for legacy and new-styleparameters, and does the clear-then-set exactly once instead of once per element (also
avoiding the redundant O(n²) work of the old code path).
Changes
BeautiDoc.deepCopyPlugin(): replace the per-element primitive-value copy (gated on thestale
Parameter.Basecheck) with a single wholesale list replace.CloneTest.simpleSiteModelCloneTest: re-enable (was@Disabledpending this fix).