[Bioperl-l] fail to obtain node-to-node distance from a newick file

Gregory Jordan greg at ebi.ac.uk
Sat Sep 10 11:39:52 EDT 2011


Hi Ross,

Which version of BioPerl are you using?

With the refactored tree code (available from the tree_api_refresh branch on
the BioPerl github repo:
https://github.com/bioperl/bioperl-live/blob/topic/tree_api_refresh/Bio/Tree/NodeFunctionsI.pm#L406)
the following script works for me. Do those values look sensible to you? The
code on the new branch is a bit experimental, so I wouldn't be surprised if
all the edge cases for calculations like this aren't covered.

--greg

use Bio::TreeIO;

my $treeio = new Bio::TreeIO(-file   => 'temp.nh', -format => "newick");
my $tree = $treeio->next_tree;
my $mt = $tree->find("Mycobacterium_tuberculosis_H37Rv");
my $ms = $tree->find("Mycobacterium_smegmatis_str._MC2_155");
my $ma = $tree->find("Mycobacterium_abscessus");
my $distance = $mt->distance($ma);
print "MT - MA: ".$mt->distance($ma)."\n";
print "MT - MS: ".$mt->distance($ms)."\n";
print "MS - MA: ".$ms->distance($ma)."\n";
# MT - MA: 0.24326
# MT - MS: 0.18573
# MS - MA: 0.20729

--greg

On Sat, Sep 10, 2011 at 7:39 AM, Ross KK Leung <ross at cuhk.edu.hk> wrote:

> I use the following code to derive the distance between two nodes but an
> error "MSG: could not find the lca of supplied nodes; can't find distance
> either"
>
>
>
> What's the problem?
>
>
>
> use Bio::TreeIO;
>
>
>
> ($treefh) = @ARGV;
>
>
>
> my $treeio = new Bio::TreeIO(-file   => $treefh, -format => "newick");
>
> my $tree = $treeio->next_tree;
>
>
>
> $keyword="Mycobacterium_tuberculosis_H37Rv";
>
> my $Tnodes = $tree->find_node(-id => $keyword);
>
> $keyword="Mycobacterium_smegmatis_str._MC2_155";
>
> my $Mnodes = $tree->find_node(-id => $keyword);
>
> $keyword="Mycobacterium_abscessus";
>
> my $Anodes = $tree->find_node(-id => $keyword);
>
>
>
> my @root = $tree->get_root_node;
>
> #my $distances = $tree->distance(-nodes => [$node[0],$root]);
>
>
>
> my $distances = $tree->distance(-nodes => [$Tnode,$Mnodes]);
>
> print "Dist:$distances\n";
>
>
>
>
>
> #### the following is the infile
>
>
> (((Mycobacterium_tuberculosis_SUMu006:4.1E-4,(Mycobacterium_tuberculosis_SUM
>
> u002:8.9E-4,Mycobacterium_tuberculosis_SUMu005:1.7E-4)31:1.4E-4)30:1.4E-4,(M
>
> ycobacterium_tuberculosis_SUMu007:4.3E-4,Mycobacterium_tuberculosis_SUMu009:
>
> 1.2E-4)22:1.4E-4)8:1.4E-4,(Mycobacterium_tuberculosis_SUMu004:3.7E-4,Mycobac
>
> terium_tuberculosis_SUMu008:2.0E-4)19:1.0E-4,(Mycobacterium_tuberculosis_SUM
>
> u003:1.4E-4,(((((Mycobacterium_tuberculosis_EAS054:0.00165,(Mycobacterium_tu
>
> berculosis_94_M4241A:0.0011,((Mycobacterium_tuberculosis_T17:0.00257,Mycobac
>
> terium_tuberculosis_KZN_605:0.00259)8:1.9E-4,(Mycobacterium_tuberculosis_'98
>
> -R604_INH-RIF-EM':9.9E-4,(Mycobacterium_tuberculosis_C:0.00293,Mycobacterium
>
> _tuberculosis_str._Haarlem:0.00271)28:1.4E-4)1:1.3E-4)0:1.6E-4)0:1.7E-4)0:1.
>
> 6E-4,(Mycobacterium_tuberculosis_02_1987:0.00186,(Mycobacterium_tuberculosis
>
> _T85:0.00229,Mycobacterium_tuberculosis_210:0.00175)41:1.4E-4)22:1.1E-4)0:1.
>
> 4E-4,(((Mycobacterium_kansasii_ATCC_12478:0.03353,(Mycobacterium_marinum_M:8
>
> .4E-4,Mycobacterium_ulcerans_Agy99:0.00621)100:0.03843)100:0.01058,((Mycobac
>
> terium_leprae_Br4923:1.7E-4,Mycobacterium_leprae_TN:1.6E-4)100:0.07379,(((My
>
> cobacterium_abscessus:0.09172,((Nocardia_farcinica_IFM_10152:0.09312,(Rhodoc
>
> occus_equi_103S:0.04972,((Rhodococcus_erythropolis_PR4:0.00223,Rhodococcus_e
>
> rythropolis_SK121:0.00169)100:0.05311,(Rhodococcus_jostii_RHA1:0.00657,Rhodo
>
> coccus_opacus_B4:0.00665)100:0.03198)100:0.02608)100:0.03679)100:0.0322,(((D
>
> ietzia_cinnamea_P4:0.17703,(Corynebacterium_amycolatum_SK46:0.16548,((Coryne
>
> bacterium_kroppenstedtii_DSM_44385:0.19137,(Corynebacterium_variabile_DSM_44
>
> 702:0.14307,(Corynebacterium_urealyticum_DSM_7109:0.11864,(Corynebacterium_r
>
> esistens_DSM_45100:0.08617,(Corynebacterium_jeikeium_ATCC_43734:0.00292,Cory
>
> nebacterium_jeikeium_K411:0.00277)100:0.08012)100:0.02749)100:0.03867)100:0.
>
> 05776)100:0.02728,((Corynebacterium_glucuronolyticum_ATCC_51866:0.00103,Cory
>
> nebacterium_glucuronolyticum_ATCC_51867:0.00137)100:0.2108,(((Corynebacteriu
>
> m_efficiens_YS-314:0.04795,Corynebacterium_glutamicum_R:0.05369)100:0.07449,
>
> ((Corynebacterium_matruchotii_ATCC_14266:0.00162,Corynebacterium_matruchotii
>
> _ATCC_33806:0.00183)100:0.13467,(Corynebacterium_diphtheriae_NCTC_13129:0.07
>
> 465,((Corynebacterium_pseudotuberculosis_C231:1.6E-4,Corynebacterium_pseudot
>
> uberculosis_I19:1.1E-4)55:1.8E-4,(Corynebacterium_pseudotuberculosis_1002:4.
>
> 2E-4,Corynebacterium_pseudotuberculosis_FRC41:1.2E-4)100:1.3E-4)100:0.0698)1
>
> 00:0.03816)100:0.03537)100:0.01906,((Corynebacterium_ammoniagenes_DSM_20306:
>
> 0.10393,(((Corynebacterium_accolens_ATCC_49725:0.00229,Corynebacterium_accol
>
> ens_ATCC_49726:0.00293)100:0.03941,(Corynebacterium_pseudogenitalium_ATCC_33
>
> 035:0.00268,Corynebacterium_tuberculostearicum_SK141:0.00306)100:0.02483)100
>
> :0.04295,(Corynebacterium_aurimucosum_ATCC_700975:0.05398,Corynebacterium_st
>
> riatum_ATCC_6940:0.05404)100:0.02088)100:0.03132)100:0.05481,(Corynebacteriu
>
> m_genitalium_ATCC_33030:0.09551,Corynebacterium_lipophiloflavum_DSM_44291:0.
>
> 09316)100:0.0783)100:0.03398)100:0.02921)100:0.04667)100:0.02447)100:0.11754
>
> )100:0.06305,(((Pseudonocardia_sp._P1:0.18877,(Saccharopolyspora_erythraea_N
>
> RRL_2338:0.1213,(Actinosynnema_mirum_DSM_43827:0.11851,(Saccharomonospora_vi
>
> ridis_DSM_43017:0.0927,(Amycolatopsis_mediterranei_U32:0.04231,Streptomyces_
>
> sp._AA4:0.04144)100:0.05565)100:0.05467)55:0.01703)100:0.03241)100:0.02581,(
>
> Nakamurella_multipartita_DSM_44233:0.23119,(Geodermatophilus_obscurus_DSM_43
>
> 160:0.21546,((Stackebrandtia_nassauensis_DSM_44728:0.21272,((Salinispora_are
>
> nicola_CNS-205:0.01818,Salinispora_tropica_CNB-440:0.02452)100:0.03265,(Micr
>
> omonospora_sp._ATCC_39149:0.0329,(Micromonospora_aurantiaca_ATCC_27029:0.001
>
> 16,Micromonospora_sp._L5:7.7E-4)100:0.03199)100:0.01352)100:0.11098)100:0.09
>
> 308,((((((Propionibacterium_freudenreichii_subsp._shermanii_CIRM-BIA1:0.2696
>
> 8,(Propionibacterium_acnes_J139:0.00475,(Propionibacterium_acnes_KPA171202:6
>
> .9E-4,(Propionibacterium_acnes_SK187:9.6E-4,(Propionibacterium_acnes_J165:6.
>
> 2E-4,Propionibacterium_acnes_SK137:8.8E-4)100:6.3E-4)100:0.00181)100:0.00315
>
> )100:0.24712)45:0.13659,(Kribbella_flavida_DSM_17836:0.17436,(Nocardioidacea
>
> e_bacterium_Broad-1:0.13638,Nocardioides_sp._JS614:0.08869)100:0.11094)73:0.
>
> 02696)43:0.0456,((Kytococcus_sedentarius_DSM_20547:0.25655,(Dermacoccus_sp._
>
> Ellin185:0.19062,(Intrasporangium_calvum_DSM_43043:0.13866,Janibacter_sp._HT
>
> CC2649:0.1412)100:0.04228)58:0.02864)100:0.06896,(Kineococcus_radiotolerans_
>
> SRS30216:0.21207,((((Propionibacterium_acidifaciens_F0233:1.06116,Rubrobacte
>
> r_xylanophilus_DSM_9941:0.5414)87:0.41816,(((Tropheryma_whipplei_TW08/27:0.0
>
> 0122,Tropheryma_whipplei_str._Twist:9.8E-4)100:0.6263,(Microbacterium_testac
>
> eum_StLB037:0.17489,(Leifsonia_xyli_subsp._xyli_str._CTCB07:0.12936,(marine_
>
> actinobacterium_PHSC20C1:0.15679,(Clavibacter_michiganensis_subsp._michigane
>
> nsis_NCPPB_382:0.00662,Clavibacter_michiganensis_subsp._sepedonicus:0.00756)
>
> 100:0.1194)100:0.03032)100:0.03729)100:0.05755)100:0.10753,((Kocuria_rhizoph
>
> ila_DC2201:0.15484,(Rothia_dentocariosa_M567:0.0599,(Rothia_mucilaginosa_ATC
>
> C_25296:0.00472,Rothia_mucilaginosa_DY-18:0.00351)100:0.05376)100:0.16477)10
>
> 0:0.06018,((Micrococcus_luteus_NCTC_2665:0.0060,Micrococcus_luteus_SK58:0.00
>
> 536)100:0.2105,(Arthrobacter_arilaitensis_Re117:0.19987,(Renibacterium_salmo
>
> ninarum_ATCC_33209:0.11862,(Arthrobacter_aurescens_TC1:0.0397,(Arthrobacter_
>
> sp._FB24:0.03191,(Arthrobacter_chlorophenolicus_A6:0.02327,Arthrobacter_phen
>
> anthrenivorans_Sphe3:0.0208)100:0.01937)100:0.01749)100:0.05605)100:0.05138)
>
> 54:0.02994)100:0.02418)100:0.06667)66:0.02055)2:0.00737,(Brevibacterium_line
>
> ns_BL2:0.16126,Brevibacterium_mcbrellneri_ATCC_49030:0.16657)100:0.16995)18:
>
> 0.03558,(Brachybacterium_faecium_DSM_4810:0.31488,(((Actinomyces_sp._oral_ta
>
> xon_848_str._F0332:0.18095,Arcanobacterium_haemolyticum_DSM_20595:0.23121)10
>
> 0:0.1195,((Actinomyces_urogenitalis_DSM_15434:0.07685,(Actinomyces_sp._oral_
>
> taxon_171_str._F0337:0.01337,(Actinomyces_oris_K20:0.00655,Actinomyces_visco
>
> sus_C505:0.00531)100:0.00537)100:0.07249)100:0.1364,(((Mobiluncus_mulieris_2
>
> 8-1:0.00136,(Mobiluncus_mulieris_ATCC_35243:8.3E-4,(Mobiluncus_mulieris_ATCC
>
> _35239:8.2E-4,Mobiluncus_mulieris_FB024-16:0.00149)77:5.2E-4)68:4.7E-4)100:0
>
> .11036,(Mobiluncus_curtisii_ATCC_51333:0.00379,(Mobiluncus_curtisii_ATCC_430
>
> 63:0.00217,Mobiluncus_curtisii_subsp._holmesii_ATCC_35242:0.00188)100:0.0018
>
> 7)100:0.10314)100:0.23714,(Actinomyces_coleocanis_DSM_15436:0.23053,(Actinom
>
> yces_sp._oral_taxon_178_str._F0338:0.07648,(Actinomyces_sp._oral_taxon_180_s
>
> tr._F0310:0.034,(Actinomyces_odontolyticus_ATCC_17982:0.00322,Actinomyces_od
>
> ontolyticus_F0309:0.00348)100:0.02875)100:0.05144)100:0.13371)100:0.05044)10
>
> 0:0.03821)98:0.03296)99:0.07932,(Beutenbergia_cavernae_DSM_12333:0.17071,(Ce
>
> llulomonas_flavigena_DSM_20109:0.11998,(Xylanimonas_cellulosilytica_DSM_1589
>
> 4:0.13952,(Sanguibacter_keddieii_DSM_10542:0.0926,Jonesia_denitrificans_DSM_
>
> 20603:0.19099)100:0.037)100:0.02528)100:0.03933)100:0.03437)90:0.02763)87:0.
>
> 02582)25:0.02892)16:0.01907)26:0.05274)57:0.03588,(Catenulispora_acidiphila_
>
> DSM_44928:0.19325,((Streptomyces_bingchenggensis_BCW-1:0.02661,(Streptomyces
>
> _hygroscopicus_ATCC_53653:0.02627,Streptomyces_violaceusniger_Tu_4113:0.0226
>
> 6)100:0.0122)100:0.02739,(((Streptomyces_avermitilis_MA-4680:0.02562,((Strep
>
> tomyces_viridochromogenes_DSM_40736:0.02687,((Streptomyces_ghanaensis_ATCC_1
>
> 4672:0.0209,Streptomyces_griseoflavus_Tu4000:0.02075)100:0.01066,(Streptomyc
>
> es_sp._e14:0.03193,(Streptomyces_coelicolor_A3_2_:5.2E-4,Streptomyces_livida
>
> ns_TK24:6.7E-4)100:0.02763)21:0.00492)22:0.00461)100:0.00897,(Streptomyces_s
>
> viceus_ATCC_29083:0.02794,Streptomyces_scabiei_87.22:0.03155)79:0.00685)98:0
>
> .00896)100:0.02063,(Streptomyces_albus_J1074:0.04846,(Streptomyces_sp._SPB74
>
> :0.01027,(Streptomyces_sp._SPB78:0.0027,(Streptomyces_sp._SA3_actF:0.00376,S
>
> treptomyces_sp._SA3_actG:2.4E-4)100:6.7E-4)100:0.00617)100:0.05981)100:0.015
>
> 63)100:0.00959,((Streptomyces_sp._C:0.01998,Streptomyces_sp._Mg1:0.02056)100
>
> :0.0383,(Streptomyces_pristinaespiralis_ATCC_25486:0.03823,(Streptomyces_sp.
>
> _ACTE:0.02415,((Streptomyces_griseus_subsp._griseus_NBRC_13350:4.1E-4,Strept
>
> omyces_sp._ACT-1:5.2E-4)100:0.00769,(Streptomyces_roseosporus_NRRL_11379:2.2
>
> E-4,Streptomyces_roseosporus_NRRL_15998:0.00209)100:0.00782)100:0.017)100:0.
>
> 02297)60:0.00742)100:0.00985)100:0.0215)100:0.11349)100:0.05)46:0.02214,(Aci
>
> dothermus_cellulolyticus_11B:0.25166,((Nocardiopsis_dassonvillei_subsp._dass
>
> onvillei_DSM_43111:0.11961,Thermobifida_fusca_YX:0.09198)100:0.09418,(Thermo
>
> monospora_curvata_DSM_43183:0.12535,(Streptosporangium_roseum_DSM_43021:0.09
>
> 754,Thermobispora_bispora_DSM_43833:0.08434)100:0.06253)100:0.0273)100:0.045
>
> 43)74:0.02856)40:0.02885,(Frankia_symbiont_of_Datisca_glomerata:0.09569,(Fra
>
> nkia_sp._EuI1c:0.10847,((Frankia_alni_ACN14a:0.0351,Frankia_sp._CcI3:0.03651
>
> )100:0.04249,(Frankia_sp._EAN1pec:0.03101,Frankia_sp._EUN1f:0.0394)100:0.046
>
> 88)100:0.02188)100:0.03014)100:0.16741)88:0.0315)65:0.02571)88:0.05354)88:0.
>
> 03348)88:0.06784,(Segniliparus_rotundus_DSM_44985:0.04795,Segniliparus_rugos
>
> us_ATCC_BAA-974:0.03891)100:0.23144)81:0.0205)88:0.02214,(Tsukamurella_pauro
>
> metabola_DSM_20162:0.13958,(Gordonia_bronchialis_DSM_43247:0.08238,Gordonia_
>
> neofelifaecis_NRRL_B-59395:0.10412)100:0.06124)100:0.03199)84:0.01596)88:0.0
>
> 6919)88:0.04069,(Mycobacterium_smegmatis_str._MC2_155:0.05174,((Mycobacteriu
>
> m_sp._JLS:0.00135,(Mycobacterium_sp._KMS:1.4E-4,Mycobacterium_sp._MCS:2.3E-4
>
> )100:0.00177)100:0.04943,(Mycobacterium_vanbaalenii_PYR-1:0.02631,(Mycobacte
>
> rium_gilvum_PYR-GCK:0.0011,Mycobacterium_sp._Spyr1:9.2E-4)100:0.03388)100:0.
>
> 03536)100:0.01213)100:0.02314)88:0.04937,(Mycobacterium_parascrofulaceum_ATC
>
> C_BAA-614:0.02796,(Mycobacterium_intracellulare_ATCC_13950:0.02159,(Mycobact
>
> erium_avium_subsp._paratuberculosis_K-10:0.0020,(Mycobacterium_avium_104:0.0
>
> 032,Mycobacterium_avium_subsp._avium_ATCC_25291:0.00216)91:6.3E-4)100:0.0194
>
> 3)100:0.01235)100:0.0158)88:0.01054)62:0.0066)88:0.04218,(Mycobacterium_tube
>
> rculosis_T46:7.6E-4,(Mycobacterium_tuberculosis_CPHL_A:5.8E-4,(Mycobacterium
>
> _tuberculosis_K85:8.0E-4,(Mycobacterium_bovis_AF2122/97:1.4E-4,(Mycobacteriu
>
> m_bovis_BCG_str._Pasteur_1173P2:1.4E-4,Mycobacterium_bovis_BCG_str._Tokyo_17
>
> 2:1.4E-4)100:1.3E-4)100:1.8E-4)38:1.1E-4)33:1.4E-4)0:1.4E-4)1:1.5E-4)0:1.5E-
>
> 4,(Mycobacterium_tuberculosis_CDC1551:2.2E-4,(Mycobacterium_tuberculosis_T92
>
> :0.00262,Mycobacterium_tuberculosis_GM_1503:0.00427)3:1.3E-4)0:1.4E-4)13:1.4
>
> E-4,(((Mycobacterium_tuberculosis_SUMu012:8.5E-4,(Mycobacterium_tuberculosis
>
> _H37Ra_WGS_:0.00109,(Mycobacterium_tuberculosis_H37Ra:1.4E-4,Mycobacterium_t
>
> uberculosis_H37Rv:1.4E-4)58:1.4E-4)41:1.4E-4)72:1.4E-4,(Mycobacterium_tuberc
>
> ulosis_SUMu001:2.9E-4,(Mycobacterium_tuberculosis_SUMu010:1.1E-4,Mycobacteri
>
> um_tuberculosis_SUMu011:8.7E-4)58:1.4E-4)65:1.6E-4)61:0.00102,(Mycobacterium
>
> _tuberculosis_F11:1.1E-4,((Mycobacterium_tuberculosis_KZN_4207:1.4E-4,Mycoba
>
> cterium_tuberculosis_KZN_R506:1.4E-4)58:1.4E-4,(Mycobacterium_tuberculosis_K
>
> ZN_1435:1.4E-4,Mycobacterium_tuberculosis_KZN_V2475:1.4E-4)74:1.4E-4)78:1.1E
> -4)36:1.4E-4)3:1.4E-4)46:1.4E-4)4:1.4E-4)88;
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>


More information about the Bioperl-l mailing list