[Biopython] parsing newick trees in memory

Frank Kauff fkauff at biologie.uni-kl.de
Sun Oct 10 10:15:45 UTC 2010


If you don't want to use StringIO, then Nexus.Trees should 
be able to handle this:

>>> from Bio.Nexus import Trees
>>> tree='((a,b),c)'
>>> tobj=Trees.Tree(tree)
>>> tobj
<Bio.Nexus.Trees.Tree instance at 0xb7709bac>
>>> dir(tobj)
['_Tree__values_are_support', '__doc__', '__init__', 
'__module__', '__str__', '_add_nodedata', '_add_subtree', 
'_get_id', '_get_values', '_parse', '_walk', 'add', 
'all_ids', 'branchlength2support', 'chain', 'collapse', 
'collapse_genera', 'common_ancestor', 
'convert_absolute_support', 'count_terminals', 
'dataclass', 'display', 'distance', 'get_taxa', 
'get_terminals', 'has_support', 'id', 'is_bifurcating', 
'is_compatible', 'is_identical', 'is_internal', 
'is_monophyletic', 'is_parent_of', 'is_preterminal', 
'is_terminal', 'kill', 'link', 'max_support', 
'merge_with_support', 'name', 'node', 'prune', 
'randomize', 'root', 'root_with_outgroup', 'rooted', 
'search_taxon', 'set_subtree', 'split', 
'sum_branchlength', 'to_string', 'trace', 'unlink', 
'unroot', 'weight']
>>> 

On Sun, 10 Oct 2010 08:09:42 +0200
  Michael Thon <mike.thon at gmail.com> wrote:
> I have a String containing a tree in newick format and I 
>want to turn it into biopython objects.  The 
>Bio.Phylo.read() function seems to only take file names 
>or file handles as parameters.  Is there any way to do 
>this without actually saving the string to a file first?
> Thanks
> Mike
> _______________________________________________
> Biopython mailing list  -  Biopython at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biopython




More information about the Biopython mailing list