SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to construct phylogenetic tree using SNPs tianyub836 Bioinformatics 10 05-21-2013 07:27 AM
Why is ML/NJ phylogeny different from SNP tree? Salmon Bioinformatics 2 01-21-2013 10:38 PM
How can I parse these reads yksikaksi Bioinformatics 5 04-26-2012 11:24 AM
phylogenetic tree renesh Bioinformatics 7 03-20-2012 09:24 AM
CREST/perl module Tree::Interval flipwell Bioinformatics 2 08-15-2011 05:48 PM

Reply
 
Thread Tools
Old 05-24-2012, 04:42 AM   #1
sphil
Senior Member
 
Location: Stuttgart, Germany

Join Date: Apr 2010
Posts: 192
Default Parse Labels from newick tree

Hey there,

I am searching for script which extract the node labels from a given newick String. Is there any tool available at the internet, or maybe someone of you guys can help me...


Best,

Phil
sphil is offline   Reply With Quote
Old 05-24-2012, 06:14 AM   #2
maubp
Peter (Biopython etc)
 
Location: Dundee, Scotland, UK

Join Date: Jul 2009
Posts: 1,543
Default

There are several options available - which programing language are you happiest with? If Python, then Biopython includes a Newick parser.

Also it would help if you could clarify exactly what you want to get out - just a list of the node labels, throwing away the tree structure?
maubp is offline   Reply With Quote
Old 05-24-2012, 07:19 AM   #3
sphil
Senior Member
 
Location: Stuttgart, Germany

Join Date: Apr 2010
Posts: 192
Default

I just want to have the labels. Tree structure can be thrown away... Python is fine...
sphil is offline   Reply With Quote
Old 05-24-2012, 07:24 AM   #4
maubp
Peter (Biopython etc)
 
Location: Dundee, Scotland, UK

Join Date: Jul 2009
Posts: 1,543
Default

If there are internal node labels, do you want the terminal (leaf) names only?

e.g. Using Biopython

Code:
from Bio import Phylo
tree = Phylo.read("int_node_labels.nwk", "newick")
for leaf in tree.get_terminals(): print leaf.name

Last edited by maubp; 05-24-2012 at 07:27 AM. Reason: Adding script
maubp is offline   Reply With Quote
Old 05-24-2012, 08:22 AM   #5
sphil
Senior Member
 
Location: Stuttgart, Germany

Join Date: Apr 2010
Posts: 192
Default

Internal as well would be great...
sphil is offline   Reply With Quote
Old 05-24-2012, 08:40 AM   #6
maubp
Peter (Biopython etc)
 
Location: Dundee, Scotland, UK

Join Date: Jul 2009
Posts: 1,543
Default

Quote:
Originally Posted by sphil View Post
Internal as well would be great...
For just the internal nodes,
Code:
from Bio import Phylo
tree = Phylo.read("int_node_labels.nwk", "newick")
for node in tree.get_nonterminals(): print node.name
For everything try:
Code:
from Bio import Phylo
tree = Phylo.read("int_node_labels.nwk", "newick")
for node in tree.find_clades():
    #Don't print anything if there is no name
    if node.name:
        print node.name
maubp is offline   Reply With Quote
Old 05-24-2012, 11:19 AM   #7
sphil
Senior Member
 
Location: Stuttgart, Germany

Join Date: Apr 2010
Posts: 192
Default

thanks alot!
sphil is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 10:29 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO