Skip to content

Commit

Permalink
Reenable tree confidence intervals
Browse files Browse the repository at this point in the history
Previously we checked for the presence of num_date confidence on the
first node (nodes[0]). Prior to auspice handling subtrees (arrays of
trees), nodes[0] was guaranteed to be the root node, but this is no
longer the case. Checking a single node wasn't the best approach anyway
as we should check for _any_ node with confidence set, which this
commit now does.
  • Loading branch information
jameshadfield committed Oct 20, 2022
1 parent e8e1e74 commit 4e61fd5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/actions/recomputeReduxState.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ const modifyControlsStateViaTree = (state, tree, treeToo, colorings) => {
coloringsToCheck = Object.keys(colorings);
}
let [aaMuts, nucMuts] = [false, false];
let num_date_confidence = false; /* flag. Is confidence defined anywhere on the tree? */
const examineNodes = function examineNodes(nodes) {
nodes.forEach((node) => {
/* check colorBys */
Expand All @@ -375,6 +376,10 @@ const modifyControlsStateViaTree = (state, tree, treeToo, colorings) => {
if (keys.length > 1 || (keys.length === 1 && keys[0]!=="nuc")) aaMuts = true;
if (keys.includes("nuc")) nucMuts = true;
}
/* check num_date confidence */
if (!num_date_confidence && getTraitFromNode(node, "num_date", {confidence: true})) {
num_date_confidence = true;
}
});
};
examineNodes(tree.nodes);
Expand Down Expand Up @@ -414,9 +419,8 @@ const modifyControlsStateViaTree = (state, tree, treeToo, colorings) => {
state.selectedBranchLabel = "clade";
}

state.temporalConfidence = getTraitFromNode(tree.nodes[0], "num_date", {confidence: true}) ?
{exists: true, display: true, on: false} :
{exists: false, display: false, on: false};
state.temporalConfidence = {exists: num_date_confidence, display: num_date_confidence, on: false};

return state;
};

Expand Down

0 comments on commit 4e61fd5

Please sign in to comment.