Stubborn trees

Sometimes you may have a Newick tree formatted a little differently and these can cause problems for the newick parser in Biopython. One way around this (if you keep getting errors) is to try this version of the code:

from Bio import Phylo
#grabs the Phylo module from Biopython
tree = Phylo.read(“beta.tree”, “newick”)
#Tells Phylo you are inputting a newick formatted tree called beta.tree
for node in tree.find_clades():
if node.name:
print node.name
#Goes through your tree and grabs the leaves and nodes. Then prints them to the screen.

But this will grab all your nodes and leaf labels which you may not want.

If you want to give this a try, here is the cyano tree (NJ, 1000 bootstraps, missing 3 genera, contains some short sequences)

(Methanocaldococcus:0.16007,(((Halospirulina:0.05138,((((Symploca:0.03482,(Schizothrix:0.04164,Pseudoscillatoria:0.05660):0.00679):0.00354,(((Cyanobacterium:0.06258,Planktothrix:0.05087):0.00761,((((Tychonema:0.01276,Microcoleus:0.01201):0.02417,((Trichodesmium:0.01739,Blennothrix:0.01437):0.00372,Hydrocoleum:0.01772):0.02319):0.00456,(Planktothricoides:0.05004,(Phormidium:0.00535,Oscillatoria:0.00686):0.03486):0.00421):0.00221,((Lyngbya:0.02509,(Spirulina:0.00263,Arthrospira:0.00120):0.02285):0.01199,Geitlerinema:0.04700):0.00368):0.00400):0.00279,(((((((((Stigonema:0.02069,Petalonema:0.02533):0.00586,(((((((Nodularia:0.01650,Cyanospira:0.01472):0.00313,Umezakia:0.01856):0.00588,(Cuspidothrix:0.01889,(Dolichospermum:0.00183,Aphanizomenon:0.00239):0.01794):0.01012):0.00271,Coleodesmium:0.02684):0.00255,(((Cylindrospermum:0.01834,(Anabaenopsis:0.01941,Trichormus:0.01361):0.01482):0.00314,(Nostoc:0.01765,Fortiea:0.02549):0.00341):0.00265,(Tolypothrix:0.01648,(Anabaena:0.03779,(Calothrix:0.01184,Camptylonemopsis:0.01092):0.00607):0.00448):0.00366):0.00210):0.00206,((Sphaerospermopsis:0.01636,(Raphidiopsis:0.00642,Cylindrospermopsis:0.00195):0.01510):0.00686,Wollea:0.02971):0.01174):0.00309,Gloeotrichia:0.05151):0.00598):0.00382,Scytonematopsis:0.04358):0.00237,(((((Nostochopsis:0.01131,Westiellopsis:0.01449):0.00467,Hapalosiphon:0.01109):0.01533,(Fischerella:0.00100,Mastigocladus:0.00112):0.03509):0.00671,Chlorogloeopsis:0.03465):0.00827,Rivularia:0.04105):0.00423):0.00273,(Scytonema:0.04022,(((Symphyonemopsis:0.00594,Iphinoe:0.00828):0.01135,Brasilonema:0.02585):0.00692,(Symphyonema:0.02297,Mastigocladopsis:0.02057):0.00659):0.00519):0.00700):0.00782,(Chroococcus:0.04429,(Starria:0.02482,Crinalium:0.01249):0.03150):0.00464):0.00243,((Trichocoleus:0.03409,Chroogloeocystis:0.02911):0.00677,(Loriellopsis:0.04153,Plectonema:0.04873):0.00476):0.00367):0.00399,Chamaesiphon:0.04433):0.00380,(((Cyanidium:0.08038,Bacillaria:0.07249):0.04484,((Planktolyngbya:0.03992,Plectolyngbya:0.05294):0.00827,(Limnothrix:0.01441,Pseudanabaena:0.01781):0.04301):0.01043):0.00510,(Gloeobacter:0.05948,((((Prochlorothrix:0.04608,Pseudophormidium:0.04688):0.00474,Halomicronema:0.04376):0.00453,(Jaaginema:0.05394,(Prochlorococcus:0.02060,(Cyanobium:0.00757,Cyanodictyon:0.00457):0.01087):0.04088):0.00615):0.00497,((Acaryochloris:0.04296,((Synechococcus:0.00726,Thermosynechococcus:0.00628):0.03442,Aphanocapsa:0.02764):0.00808):0.00522,Arthronema:0.04630):0.00339):0.00278):0.00281):0.00301):0.00294):0.00218):0.00356,(((((Snowella:0.02682,Woronichinia:0.02288):0.00922,(Synechocystis:0.00990,Merismopedia:0.01150):0.01744):0.01292,((Radiocystis:0.04019,Microcystis:0.04337):0.00469,Gloeothece:0.03275):0.00517):0.00447,(Aphanothece:0.02864,(Crocosphaera:0.01125,Gloeocapsa:0.00974):0.02606):0.00659):0.00268,(Chondrocystis:0.03157,Limnococcus:0.03924):0.00998):0.00298):0.00290,((Prochloron:0.04172,Leptolyngbya:0.03457):0.00402,(Hyella:0.03345,((Myxosarcina:0.01442,(Stanieria:0.01289,Dermocarpa:0.00706):0.01125):0.00224,(Dermocarpella:0.01853,((Chroococcidiopsis:0.00862,Pleurocapsa:0.01067):0.01094,Xenococcus:0.01604):0.00374):0.00267):0.02112):0.00851):0.00254):0.00500):0.00572,(Cyanothece:0.01761,Dactylococcopsis:0.02352):0.03164):0.00914,(Rubidibacter:0.03909,Halothece:0.04409):0.00889):0.16007);

Advertisements
This entry was posted in Uncategorized and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s