[Biopython] problems with Phylo.draw

Eric Talevich eric.talevich at gmail.com
Fri May 9 00:03:22 UTC 2014


Hi Vince,

There was a little bit of shuffling during the past year to make plotting
more flexible, so it's possible something changed to cause this error. The
current call signature is:

draw(tree, label_func=<type 'str'>, do_show=True, show_confidence=True,
axes=None, branch_labels=None, *args, **kwargs)

You're calling it as:

Phylo.draw(tree, ext)

What is "ext"? (Apparently a string.) It should be a function that
generates labels. If it's just a string, depending on what you mean for it
to do, you could replace it with a function that returns a string:

def make_ext(node): return "asdf"
Phylo.draw(tree, make_ext)

Or:

Phylo.draw(tree, lambda node: "asdf")

(The commented-out call "Phylo.draw(tree)" ought to work fine.)

Best,
Eric

On Thu, May 8, 2014 at 3:24 PM, Vincent Davis <vincent at vincentdavis.net>wrote:

> I am working with some code that used to work (6 months ago) , I am not
> sure what has changed other than upgrading to the current Biopython and
> iPython versions.
> I am using anaconda python 2.7
> Development build of Biopython
> Development built of iPython
>
> You can download the file from Dropbox
> here<
> https://dl.dropboxusercontent.com/u/1340248/homolog__1274p.clustalwF-gb.phylip_phyml_tree.txt
> >
>
> t =
> 'old/phylo_tools/temp/homolog__1274p.clustalwF-gb.phylip_phyml_tree.txt'
> tree = Phylo.read(t, 'newick')
> Phylo.draw(tree, ext)
> #Phylo.draw_ascii(tree)
>
>
>
>
> Populating the interactive namespace from numpy and matplotlib
>
>
> ---------------------------------------------------------------------------TypeError
>                                 Traceback (most recent call
> last)<ipython-input-30-aa4094a6cf41> in <module>()      4 t =
> 'old/phylo_tools/temp/homolog__1274p.clustalwF-gb.phylip_phyml_tree.txt'
>      5 tree = Phylo.read(t, 'newick')----> 6 Phylo.draw(tree, ext)
>  7 # Phylo.draw_ascii(tree)
> /home/vincent/.local/lib/python2.7/site-packages/Bio/Phylo/_utils.pyc
> in draw(tree, label_func, do_show, show_confidence, axes,
> branch_labels, *args, **kwargs)    459
> draw_clade(child, x_here, color, lw)    460 --> 461
> draw_clade(tree.root, 0, 'k', plt.rcParams['lines.linewidth'])    462
>    463     # If line collections were used to create clade lines, here
> they are added
> /home/vincent/.local/lib/python2.7/site-packages/Bio/Phylo/_utils.pyc
> in draw_clade(clade, x_start, color, lw)    440
> y_here=y_here, x_start=x_start, x_here=x_here, color=color, lw=lw)
> 441         # Add node/taxon labels--> 442         label =
> label_func(clade)    443         if label not in (None,
> clade.__class__.__name__):    444             axes.text(x_here,
> y_here, ' %s' % label, verticalalignment='center')
> TypeError: 'str' object is not callable
>
>
>  Vincent Davis
> _______________________________________________
> Biopython mailing list  -  Biopython at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biopython
>



More information about the Biopython mailing list