[BioPython] Creating and traversing an ultrametric tree
Frank Kauff
fkauff at biologie.uni-kl.de
Tue Oct 7 08:02:12 UTC 2008
Peter wrote:
> On Wed, Sep 24, 2008 at 7:32 PM, aditya shukla
> <adityashukla1983 at gmail.com> wrote:
>
>> Hello Peter ,
>>
>> Thanks for the reply ,
>> I have attached a file with of the kind of data that i wanna parse.
>> I tried using Thomas Mailund's Newick tree parser but this dosen't
>> seem to work , so is there any other module that can help?
>>
>
> Your file looks like this (in case anyone on the mailing list recognises it),
>
> /T_0_size=105((-bin-ulockmgr_server:0.99[&&NHX:C=0.195.0],
> (((-bin-hostname:0.00[&&NHX:C=200.0.0],
> (-bin-dnsdomainname:0.00[&&NHX:C=200.0.0],
> ...):0.99):0.99):0.99):0.99);
>
> [with a large chunk removed, and new lines inserted]
>
> I'm guessing this is some kind of computer system profile - nothing to
> do with bioinformatics.
>
> I'm not 100% sure this is Newick format - it might be worth trying to
> parse everything after the "/T_0_size=105" text which looks out of
> place to me.
>
> If it is a valid Newick format tree file, then it is using named
> internal nodes which is something Biopython can't currently parse (see
> Bug 2543, http://bugzilla.open-bio.org/show_bug.cgi?id=2543 ). So I
> don't think you can use the Bio.Nexus module in Biopython to read this
> tree.
>
>
Nexus.Trees has been extended to deal with internal node names, or
"special comments" in the format [& blablalba]. Such comments comments
can appear directly after the taxon label, after the closing
parentheses, or between branchlength / support values attached to a node
or a taxon labels, such as
(a,(b,(c,d)[&hi there]))
(a,(b[&hi there],c))
(a,(b:0.123[&hi there],c[&heyho]:0.3))
(a,(b,c)0.4[&comment]:0.95)
The comments are stored without change in the corresponding node object
and can be accessed like
>>> t=Trees.Tree('(a,(b:0.123[&hi there],c[&heyho]:0.3))')
>>> print t.node(3).data.comment
[&hi there]
>>> print t.node(4).data.comment
[&heyho]
>>>
The comments are not parsed in any way - internal labels vary greatly in
syntax, and are used to store all kinds of information. But at least
they are now parsed and stored, and users can deal with them in any way
they like.
Frank
> The only other python package I can suggest you try is NetworkX,
> https://networkx.lanl.gov/wiki
>
> Good luck,
>
> Peter
> _______________________________________________
> BioPython mailing list - BioPython at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biopython
>
>
More information about the Biopython
mailing list