Hello everyone, With my python script (below) I'm trying to read my Newick files and print out only the species name. Example, I want to type: python script.py file.nk and the output I want is species 1, species2, species 3., but somehow Tree don't want to accept my input file and I get this error message:
Traceback (most recent call last): File "ete_test.py", line 9, in <module>
t = Tree("contents") File "/usr/local/lib/python2.7/dist-packages/ete3/coretype/tree.py", line 211, in __init__
quoted_names=quoted_node_names) File "/usr/local/lib/python2.7/dist-packages/ete3/parser/newick.py", line 249, in read_newick
raise NewickError('Unexisting tree file or Malformed newick tree structure.') ete3.parser.newick.NewickError: Unexisting tree file or Malformed newick tree structure. You may want to check other newick loading flags like 'format' or 'quoted_node_names'.
I don't understand since I have my file in correct format. I will be really grateful for all your help.
from ete3 import Tree
import sys
contents = []
with open(sys.argv[1], 'r') as f:
contents = f.read()
print contents
t = Tree("contents")
for leaf in t:
print leaf.name
Thank you so much for your help.