Skip to content

Commit

Permalink
Downloaded tree units represent current view
Browse files Browse the repository at this point in the history
This makes behavior consistent with the idea that downloaded data represents the current view. It also prevents a bug when trying to download a temporally scaled tree for a non-temporal dataset.
  • Loading branch information
jameshadfield committed Jan 5, 2021
1 parent 9f3561f commit 0b0c01b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
35 changes: 12 additions & 23 deletions src/components/download/downloadButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,32 @@ const iconWidth = 25;
* A React Component displaying buttons which trigger data-downloads. Intended for display within the
* larger Download modal component
*/
export const DownloadButtons = ({dispatch, t, tree, entropy, metadata, colorBy, mutType, panelsToDisplay, panelLayout, filters, visibility, visibleStateCounts, relevantPublications}) => {
export const DownloadButtons = ({dispatch, t, tree, entropy, metadata, colorBy, mutType, distanceMeasure, panelsToDisplay, panelLayout, filters, visibility, visibleStateCounts, relevantPublications}) => {
const totalTipCount = metadata.mainTreeNumTips;
const selectedTipsCount = getNumSelectedTips(tree.nodes, tree.visibility);
const partialData = selectedTipsCount !== totalTipCount;
const filePrefix = getFilePrefix();
const temporal = distanceMeasure === "num_date";

return (
<>
<div style={{fontWeight: 500, marginTop: "0px", marginBottom: "20px"}}>
{partialData ?
`The current view is displaying data for ${selectedTipsCount}/${totalTipCount} tips. Downloaded data is representative of this (i.e. it is a subset of the entire dataset).` :
`Download data for the entire dataset (${totalTipCount} tips).`
}
Downloaded data represents the currently displayed view.
By zooming the tree, changing the branch-length metric, applying filters etc, the downloaded data will change accordingly.
<p/>
{partialData ? `Currently ${selectedTipsCount}/${totalTipCount} tips are displayed and will be downloaded.` : `Currently the entire dataset (${totalTipCount} tips) will be downloaded.`}
</div>
<Button
name="Tree (Newick)"
description="Phylogenetic tree in Newick format with branch lengths in units of divergence."
name={`${temporal ? 'TimeTree' : 'Tree'} (Newick)`}
description={`Phylogenetic tree in Newick format with branch lengths in units of ${temporal?'years':'divergence'}.`}
icon={<RectangularTreeIcon width={iconWidth} selected />}
onClick={() => helpers.exportTree({isNewick: true, dispatch, filePrefix, tree, temporal: false})}
onClick={() => helpers.exportTree({isNewick: true, dispatch, filePrefix, tree, temporal})}
/>
<Button
name="TimeTree (Newick)"
description="Phylogenetic tree in Newick format with branch lengths measured in years."
name={`${temporal ? 'TimeTree' : 'Tree'} (Nexus)`}
description={`Phylogeny in Nexus format with branch lengths in units of ${temporal?'years':'divergence'}. Colorings are included as annotations.`}
icon={<RectangularTreeIcon width={iconWidth} selected />}
onClick={() => helpers.exportTree({isNewick: true, dispatch, filePrefix, tree, temporal: true})}
/>
<Button
name="Tree (Nexus)"
description="Phylogeny in Nexus format with branch lengths in units of divergence. Colorings are included as annotations."
icon={<RectangularTreeIcon width={iconWidth} selected />}
onClick={() => helpers.exportTree({dispatch, filePrefix, tree, colorings: metadata.colorings, colorBy, temporal: false})}
/>
<Button
name="TimeTree (Nexus)"
description="Phylogeny in Neexus format with branch lengths measured in years. Colorings are included as annotations."
icon={<RectangularTreeIcon width={iconWidth} selected />}
onClick={() => helpers.exportTree({dispatch, filePrefix, tree, colorings: metadata.colorings, colorBy, temporal: true})}
onClick={() => helpers.exportTree({dispatch, filePrefix, tree, colorings: metadata.colorings, colorBy, temporal})}
/>
<Button
name="Metadata (TSV)"
Expand Down
1 change: 1 addition & 0 deletions src/components/download/downloadModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const publications = {
browserDimensions: state.browserDimensions.browserDimensions,
show: state.controls.showDownload,
colorBy: state.controls.colorBy,
distanceMeasure: state.controls.distanceMeasure,
metadata: state.metadata,
entropy: state.entropy,
mutType: state.controls.mutType,
Expand Down

0 comments on commit 0b0c01b

Please sign in to comment.