Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve second tree loading & parsing #1788

Merged
merged 5 commits into from
Jun 17, 2024

Conversation

jameshadfield
Copy link
Member

@jameshadfield jameshadfield commented Jun 12, 2024

See commit messages for more details.

  • Checks pass
  • If making user-facing changes, add a message in CHANGELOG.md summarizing the changes in this PR

@nextstrain-bot nextstrain-bot temporarily deployed to auspice-james-improve-s-j9iwou June 12, 2024 02:58 Inactive
const tree1count = this.props.totalStateCounts[filterName]?.get(item.value) ?? 0;
if (this.props.totalStateCountsSecondTree) {
const tree2count = this.props.totalStateCountsSecondTree[filterName]?.get(item.value) ?? 0;
label+=` (L: ${tree1count}, R: ${tree2count})`;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's an example of how this looks:

image

@jameshadfield jameshadfield force-pushed the james/improve-second-tree-loading branch from dd95486 to aea6330 Compare June 12, 2024 03:35
@nextstrain-bot nextstrain-bot temporarily deployed to auspice-james-improve-s-j9iwou June 12, 2024 03:35 Inactive
@jameshadfield jameshadfield requested a review from a team June 12, 2024 03:42
@jameshadfield jameshadfield force-pushed the james/improve-second-tree-loading branch from aea6330 to 265f8ff Compare June 17, 2024 02:46
@nextstrain-bot nextstrain-bot temporarily deployed to auspice-james-improve-s-j9iwou June 17, 2024 02:46 Inactive
@jameshadfield
Copy link
Member Author

Rebased onto master

There are two ways of loading a second tree: upon initial load /
narrative slide progression (logic within `createStateFromQueryOrJSONs`)
or via the sidebar "second tree" UI (logic within `createTreeTooState`).
This commit aims to reduce the duplication of code between these functions,
where possible given the current design.

There is one behavioural change - the second method of loading a tree
now no longer skips the `castIncorrectTypes` error correction function.

Tangentially: the code in this file is fragile and the order of function
calls is crucial. I hope the adoption of TS will improve resilience
here.
Trees define traitNames and traitValues via their `node_attrs` in the
dataset JSON, for instance "traitName=country" and "traitValue=New
Zealand". We populate the filtering dropdowns using these, but had
previously only considered the main (LHS) tree. Behavioural changes:

* traitName & traitValue present on both trees: no change. Filtering
  works as expected.
* traitName on both trees, traitValue only on 2nd tree: functionality
  added here.
* traitName only present on 2nd tree: this now works, but the app
  crashes from an uncaught error in the filter badges shown in the
  header. This will be fixed in the next commit.

In addition, mutations and node ("sample") names unique to the 2nd tree
are added to the available filters.

Closes #1781
The previous implementation only reflected counts in the LHS tree,
irregardless of any occurrences which may or may not be present in the
RHS tree. We now communicate both. This also fixes a bug introduced in
the previous commit where filtering to a traitName not present in the
LHS tree would cause an uncaught exception.
Branch labels were already rendered correctly on the RHS tree if the key
was present in the LHS tree, so all that's required is to add label keys
which are only observed in the RHS tree to appear in the sidebar branch
label selector.

Closes #1780
@jameshadfield jameshadfield force-pushed the james/improve-second-tree-loading branch from 265f8ff to 99e5336 Compare June 17, 2024 03:10
@nextstrain-bot nextstrain-bot temporarily deployed to auspice-james-improve-s-j9iwou June 17, 2024 03:10 Inactive
@jameshadfield
Copy link
Member Author

Rebased onto master (again).

Our CI is passing, including our action which builds the docs. Read the docs' own build is failing, but I don't think that's related to changes here. I'll make a separate issue to track this. Merging.

@jameshadfield jameshadfield merged commit acfb205 into master Jun 17, 2024
25 of 26 checks passed
@jameshadfield jameshadfield deleted the james/improve-second-tree-loading branch June 17, 2024 03:16
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.

3 participants