I trying to build a tree with BioPython, Phylo module.
What I ve done so far is this image:
each name has a four digit number followed by - and a number: this number refer to the number of times that sequence is represented. That means 1578 - 22, that node should represent 22sequences.
the file with the sequences aligned: file
the file with the distance to build a tree: file
So now I known how to change each size of the node. Each node has a different size, this is easy doing an array of the different values:
fh = open(MEDIA_ROOT + "groupsnp.txt")
list_size = {}
for line in fh:
if > in line:
labels = line.split( > )
label = labels[-1]
label = label.split()
num = line.split( - )
size = num[-1]
size = size.split()
for lab in label:
for number in size:
list_size[lab] = int(number)
a = array(list_size.values())
But the array is arbitrary, I would like to put the correct node size into the right node, I tried this:
for elem in list_size.keys():
if labels == elem:
Phylo.draw_graphviz(tree_xml, prog="neato", node_size=a)
but nothing appears when I use the if statement.
Anyway of doing this?
I would really appreciate!
Thanks everybody