Open pmckenz1 opened 3 years ago
h1newick = "((r5,(r4,(r3,((r2,(r0,r1):4.268188213461936):2.9023407392778653)#H9:10.0::0.7093477022612464):3.2038798063864555):10.0):10.0,r6,(r7,#H9:0.0::0.2906522977387535):10.0);" tree, admix = toytree.utils.parse_network(h1newick)
--------------------------------------------------------------------------- NewickError Traceback (most recent call last) <ipython-input-190-34a9c85f9024> in <module> 1 h1newick = "((r5,(r4,(r3,((r2,(r0,r1):4.268188213461936):2.9023407392778653)#H9:10.0::0.7093477022612464):3.2038798063864555):10.0):10.0,r6,(r7,#H9:0.0::0.2906522977387535):10.0);" ----> 2 tree, admix = toytree.utils.parse_network(h1newick) /moto/eaton/users/pfm2119/pkgs/toytree/toytree/utils.py in parse_network(net, disconnect, root) 156 157 # parse cleaned newick and set empty gamma on all nodes --> 158 net = toytree.tree(net, tree_format=1) 159 160 # store admix data /moto/eaton/users/pfm2119/pkgs/toytree/toytree/Toytree.py in __init__(self, newick, tree_format, **kwargs) 68 # parse a str, URL, or file 69 elif isinstance(newick, (str, bytes)): ---> 70 self.treenode = TreeParser(newick, tree_format).treenodes[0] 71 72 # make an empty tree /moto/eaton/users/pfm2119/pkgs/toytree/toytree/TreeParser.py in __init__(self, intree, tree_format, multitree, debug) 78 # parse intree 79 if not self.debug: ---> 80 self._run() 81 82 /moto/eaton/users/pfm2119/pkgs/toytree/toytree/TreeParser.py in _run(self) 94 95 # parse newick strings to treenodes list ---> 96 self.get_treenodes() 97 98 # apply names from tdict /moto/eaton/users/pfm2119/pkgs/toytree/toytree/TreeParser.py in get_treenodes(self) 162 163 # extract one tree --> 164 self.treenodes.append(extractor.newick_from_string()) 165 166 else: /moto/eaton/users/pfm2119/pkgs/toytree/toytree/TreeParser.py in newick_from_string(self) 265 closing_internal = closing_internal.rstrip(";") 266 # read internal node data and go up one level --> 267 self.apply_node_data(closing_internal, "internal") 268 self.current_parent = self.current_parent.up 269 return self.root /moto/eaton/users/pfm2119/pkgs/toytree/toytree/TreeParser.py in apply_node_data(self, subnw, node_type) 327 self.current_node.add_feature(fname, fvalue) 328 else: --> 329 raise NewickError("Unexpected newick format {}".format(subnw)) 330 331 NewickError: Unexpected newick format #H9:10.0::0.7093477022612464
I will look for what's causing this but wanted to drop it here too in case you're able to beat me to it!
Occassionally snaq returns a network that toytree cannot parse. Here's an example of something that gives an error:
Full error text:
I will look for what's causing this but wanted to drop it here too in case you're able to beat me to it!