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 Dec 17, 2020
1 parent 9f3561f commit 259614a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
27 changes: 8 additions & 19 deletions src/components/download/downloadButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ 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 (
<>
Expand All @@ -31,28 +32,16 @@ export const DownloadButtons = ({dispatch, t, tree, entropy, metadata, colorBy,
}
</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 259614a

Please sign in to comment.