Skip to content

Commit

Permalink
Disallow newick trees with quotes
Browse files Browse the repository at this point in the history
The newick parser we use is known to have issues with quoted node names,
as it will parse the node name content as newick. As a quick fix,
disallow trees with quotes. The result is that the trees in #66 and
<https://discussion.nextstrain.org/t/displaying-trees-from-ncbi-pathogen-browser-in-auspice-us/1456/4>
will now result in an error. The downside is trees with quoted names but
no newick-like structure within the node name will also fail to load.
  • Loading branch information
jameshadfield committed Dec 6, 2023
1 parent 669f170 commit 83b227e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions auspice_client_customisation/parseNewick.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
export const parseNewick = (nwk) => {
const ancestors = [];
let tree = {};

/**
* This newick parser is known to have issues with quoted node names, as it
* will parse the node name content as newick. As a quick fix, disallow trees
* with quotes.
*/
if (nwk.includes('"') || nwk.includes("'")) {
throw new Error("Auspice.us cannot currently parse Newick files with single or double quotes in them!")
}


const tokens = nwk.split(/\s*(;|\(|\)|,|:)\s*/);
for (let i=0; i<tokens.length; i++) {
const token = tokens[i];
Expand Down

0 comments on commit 83b227e

Please sign in to comment.