From ca00d23c7250745fffd437f9adf1c26fb4ddd883 Mon Sep 17 00:00:00 2001 From: james hadfield Date: Wed, 5 Jun 2024 15:16:45 +1200 Subject: [PATCH] [link out modal] add nextclade link-out Most discussion about this functionality has been happening within the nextclade repo, see and for a good summary. --- src/components/modal/LinkOutModalContents.jsx | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/components/modal/LinkOutModalContents.jsx b/src/components/modal/LinkOutModalContents.jsx index ef753099e..51857c8ec 100644 --- a/src/components/modal/LinkOutModalContents.jsx +++ b/src/components/modal/LinkOutModalContents.jsx @@ -189,6 +189,51 @@ function MicrobeTraceLinkOut() { } +function NextcladeLinkOut() { + const displayName = 'nextclade'; + const {pathname, origin} = clientDetails(); + const {showTreeToo} = useSelector((state) => state.controls) + const {mainTreeNumTips, rootSequence} = useSelector((state) => state.metadata); + + // All datasets which have a root-sequence (either in-line or sidecar) can theoretically work as Nextclade + // datasets. See for more thorough discussion here. + // Excessively big trees may be problematic (as Nextclade was designed around smaller reference trees), but + // exactly what the threshold is isn't known. Here I use a rather ad-hoc tip-count threshold: + const largeTreeWarning = mainTreeNumTips > 4000; + + if ( + showTreeToo || // Tanglegrams won't work (surprise surprise!) + !rootSequence // Root sequence is required for Nextclade + ) { + return ( + + {displayName} + + {`The current dataset isn't viewable in Nextclade as ${ + showTreeToo ? + "tanglegrams aren't supported." : + "this dataset doesn't have a root-sequence (either within the main JSON or as a sidecar JSON)." + }`} + + + ) + } + + const url = `https://clades.nextstrain.org?dataset-json-url=${encodeURIComponent(`${origin}${pathname}`)}` + return ( + + {displayName} + + View this data in Nextclade (learn more). + {largeTreeWarning && ( + + {` Note that large trees such as this may not work in Nextclade!`} + + )} + + + ) +} export const LinkOutModalContents = () => { return ( @@ -210,6 +255,7 @@ export const LinkOutModalContents = () => { + );