[Biopython-dev] [Bug 3134] to_networkx returns weird stuff

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Mon Aug 30 16:23:20 EDT 2010


http://bugzilla.open-bio.org/show_bug.cgi?id=3134





------- Comment #2 from john at nurfuerspam.de  2010-08-30 16:23 EST -------
thanx for the quick response!

the problem is that the standard way using pylab produces ugly squares instead
of arrow head in the final layout. but more importantly, I want to perform
complex graph operations on the tree using networkx and use Bio.Phylo really
just as a means of parsing ;-)

I think that when providing a function like to_networkx, it should behave in a
manner the user of networkx expects. Why not just use a unique hashable
identifier like integers as standard string representation for ALL nodes, and
use graphviz'/networkx' label attribute for any name label the node might have?
Using the string representation of labeled leafs as identifiers in networkx is
also dangerous, since they will be used as identifiers in graphviz and underly
a number of restrictions (no whitespace etc.)

I'd propose the following: in Clade, __repr__() should return the name of the
node, if it has one, or a unique identifier like id() (the memory adress) with
an additional "..." around them to make it a valid graphviz identifier..

def __repr__(self):
  if self.name != None:
    return self.name
  else:
    return "\""+str(id(self))+"\""


your workaround by manually relabeling the clades also assigns the identifiers
to the leafs, but there of course I want the species/gene label ;-)

cheers,
john


-- 
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.


More information about the Biopython-dev mailing list