我正在尝试使用以下代码从文件中加载 newick 字符串:
filename = templist[1].lower().replace(" ","") + ".nwk"
tt = Tree(filename, format=1)
但出现以下错误:
tt = Tree(filename, format=1) # Loads a tree structure from a newick string. The returned variable tt is the root node for the tree.
File "/python2.7/dist-packages/ete2-2.2.1072-py2.7.egg/ete2/coretype/tree.py", line 225, in __init__
read_newick(newick, root_node = self, format=format)
File "/python2.7/dist-packages/ete2-2.2.1072-py2.7.egg/ete2/parser/newick.py", line 237, in read_newick
'Unexisting tree file or Malformed newick tree structure.'
ete2.parser.newick.NewickError: Unexisting tree file or Malformed newick tree structure.
我已经验证了文件格式,没问题。我想我以错误的方式传递变量,请指导我将文件名作为变量传递。
当我将文件名作为字符串传递而不使用变量时,它工作正常,但我需要使用变量值来加载树。