[Phylobase-devl] readNexus crashes R

François Michonneau francois.michonneau at gmail.com
Wed Oct 27 15:54:18 CEST 2010


I just committed a patch that should fix R crashes due to malformed
NEXUS files. Can you guys please check that it works for you?

  Thanks,
  -- François

On Tue, 2010-10-26 at 22:26 -0500, Mark Holder wrote:
> > 
> >  Unfortunately NCL is absolutely rife with throw/catch stuff, all of
> > which will have to be escaped with macros -- argh.
> 
> I think the most efficient way will be to catch them in C++. In other words call a function that uses the general structure:
> ////////////////////////////////////////////////////
> int nclwrapper(arguments here) 
> {
> 	std::string errormessage;
> 
> try 	{
> 	<all of the phylobase C++ interactions with NCL go here>
> 	return 0;
> 	}
> catch (NxsException &x)
> 	{
> 	errormessage = x.msg;
> 	}
> catch (...)
> 	{
> 	errormessage = "An unknown error occurred";
> 	
> 	}
> ... CODE to pass the errormessage to R here...
> 	return 1;
> }
> 
> ////////////////////////////////////////////////////
> 
> where returning 1 means an exception was caught.  NCL certainly does use exceptions to report virtually all messages, so I think a high level catch is the only practical solution.
> 
> all the best,
> Mark
> 
> 
> 
> >  cheers
> >   Ben
> > 
> > 
> > On 10-10-25 06:19 PM, Peter Cowan wrote:
> >> I too won't have time for at least a week.  The Rcpp article in the R
> >> journal has an example of how to catch c++ exceptions.  It's been on
> >> my list to add this to phylobase, and I'll do so if Francois doesn't
> >> get there first.
> >> 
> >> Peter
> >> 
> >> 
> >> On Oct 25, 2010, at 2:52 PM, François Michonneau wrote:
> >> 
> >>> 
> >>> Hi,
> >>> 
> >>> I'll look into it, but I won't have much time before the end of
> >>> the week.
> >>> 
> >>> Cheers, -- François
> >>> 
> >>> On Mon, 2010-10-25 at 16:39 -0500, Mark Holder wrote:
> >>>> Hi, The file is not a valid NEXUS file. 
> >>>> 
> >>>> The C++ code in phylobase (an adaptation of the nexus class
> >>>> library) is probably throwing an exception.   I base that guess
> >>>> on the fact that when I run the file on the NEXUSnormalizer
> >>>> program ( a testing program for NCL) I get an error message. The
> >>>> source of the error in the nexus file is the fact that the names
> >>>> in the TRANSLATE command of the TREES block do not match the
> >>>> TAXLABELS in the TAXA block.
> >>>> 
> >>>> Errors in an input file should not cause a crash in R, so there
> >>>> is probably so hole in the phylobase wrapping of NCL exceptions.
> >>>> 
> >>>> 
> >>>> I'm not sure when I'll be able to look at that code, so if
> >>>> someone has the time and energy, then go for it (I'll certainly
> >>>> try to answer any NCL questions that come up).
> >>>> 
> >>>> 
> >>>> cheers, Mark
> >>>> 
> >>>> 
> >>>> 
> >>>> 
> >>>> 
> >>>> On Oct 25, 2010, at 4:24 PM, Peter Cowan wrote:
> >>>> 
> >>>>>> #NEXUS [written Sat Oct 23 12:11:18 PDT 2010 by Mesquite
> >>>>>> version 2.6 (build 486) at Macintosh-101.local/10.0.1.6]
> >>>>>> 
> >>>>>> BEGIN TAXA; TITLE Taxa; DIMENSIONS NTAX=32; TAXLABELS 
> >>>>>> S1FS3_S3FS1_&_S2LS4 Desulfodehalobacter_spongiphilus_strain_ 
> >>>>>> Desulfobacterium_indolicum_strain_DSM_33 
> >>>>>> Desulfobacter_postgatei_strain_DSM_2034_
> >>>>>> Geobacter_sulfurreducens_#U13928 S2HS1_&_S3HS1
> >>>>>> Geobacter_chapelleii_strain_172_#NR_0259 F2HS1b 
> >>>>>> Shewanella_putrefaciens_strain_Hac334_#D
> >>>>>> Shewanella_aquimarina_#AY485225 
> >>>>>> Pseudomonas_meridiana_strain_CMS_38T_AJ5 F2FS1_&_F3FS2
> >>>>>> F2HS1_&_F2HS3 Pseudomonas_stutzeri_strain_LS401_#U2641
> >>>>>> F2FS2_&_F3HS2 Marinobacter_hydrocarbonoclasticus_strai
> >>>>>> S3FS4_S3FS5_&_S3FS6 Marinobacter_guineae_strain_LMG_24048_#A
> >>>>>> Marinobacter_lipolyticus_strain_SM S1HS1
> >>>>>> Desulfopila_aestuarii_#AB110542 S3FS2 
> >>>>>> S1HS2_S1HS3_S1HS4_S1HS5_S3HS4_&_F2HA2a F3FS1 
> >>>>>> Desulfovibrio_putealis_#AY574979
> >>>>>> Desulfovibrio_desulfuricans_subsp._desul S2LS1
> >>>>>> Desulfovibrio_bizertensis_strain_MB3_#DQ S1FS1 
> >>>>>> Desulfovibrio_marinisediminis_#AB353727
> >>>>>> S2LS3_S3LS1_S3FS3_&_F2HA2b Acidobacterium_capsulatum_#D26171 
> >>>>>> ;
> >>>>>> 
> >>>>>> END;
> >>>>>> 
> >>>>>> 
> >>>>>> BEGIN TREES; Title Imported_trees; LINK Taxa = Taxa; 
> >>>>>> TRANSLATE 1 S1FS3_S3FS1_&_S2LS4, 2 D_s_strain_, 3
> >>>>>> D_i_strain_DSM_3, 4 D_p_strain_DSM_2_, 5 G_s_#, 6
> >>>>>> S2HS1_&_S3HS1, 7 G_c_strain_1_#NR_0, 8 F2HS1b, 9
> >>>>>> S_p_strain_H_#D, 10 S_a_#, 11 P_m_strain_C_3_A, 12
> >>>>>> F2FS1_&_F3FS2, 13 F2HS1_&_F2HS3, 14 P_s_strain_L_#, 15
> >>>>>> F2FS2_&_F3HS2, 16 M_h_s, 17 S3FS4_S3FS5_&_S3FS6, 18
> >>>>>> M_g_s_L_2_#A, 19 M_l_s_S, 20 S1HS1, 21 D_a_#A, 22 S3FS2, 23
> >>>>>> S1HS2_S1HS3_S1HS4_S1HS5_S3HS4_&_F2HA2a, 24 F3FS1, 25 D_p_#, 
> >>>>>> 26 D_d_s._d, 27 S2LS1, 28 D_b_s_M_#D, 29 S1FS1, 30 D_m_#A, 31
> >>>>>> S2LS3_S3LS1_S3FS3_&_F2HA2b, 32 A_c_#; TREE Imported_tree_0 = 
> >>>>>> (((1:0.014294865658239897,2:0.016346131753724284)100:0.04531876862101268,(3:0.07787046050007705,(4:0.1575116382471088,((((5:0.04822215084893891,(6:0.0271216303442505,7:0.02007948214228989)100:0.03528659400373911)99:0.05981681725589428,(((8:1.12919178858362E-6,9:1.12919178858362E-6)100:0.057530109591399765,10:0.037691124354788864)100:0.08304244998885398,((11:0.030702696010829537,((12:8.544451267088965E-4,13:1.12919178858362E-6)100:0.020184245020285173,(14:1.12919178858362E-6,15:0.0034181003601162514)85:0.012235337246177081)93:0.01895791066948832)100:0.047681348350900744,(16:0.020642180955472003,(17:0.0033048657512852178,(18:0.005988936129628456,(19:0.005010797883775309,20:0.01691780810184798)67:0.007663605184147101)74:0.006198749083268308)74:0.014460306032529943)100:0.06150881986749245)96:0.03607879771546074)100:0.1898411550405616)61:0.05839829698184673,((21:0.03207541431435525,22:0.03529636469585623)86:0.014049212961742451,23:0.015891647611896632)100:0.12157794121374672
> > )43
> >>>> 
> >>>>>> 
> > :
> >>>>> 0!
> >>>>>> .025419418511636843,((24:0.008361788925720447,25:8.737200748323158E-4)100:0.12954900469798472,(26:0.12890159096837994,((27:1.12919178858362E-6,28:0.004140667057671182)100:0.07459471196756032,(29:1.12919178858362E-6,(30:1.12919178858362E-6,31:0.0033956963116614446)89:0.002536358334238893)100:0.14144374970927193)77:0.030026874274203138)83:0.03329468873634148)98:0.09177164340960056)45:0.034517167840112765)51:0.04130953485123759)27:0.02140636921130952)100:0.21688189318012785,32:0.21688189318012785)100:0.23;
> >>>>>> 
> >>>>>> 
> >>>>>> 
> > END;
> >>>>>> 
> >>>>>> 
> >>>>>> Begin MESQUITE; MESQUITESCRIPTVERSION 2; TITLE AUTO; tell
> >>>>>> ProjectCoordinator; getEmployee
> >>>>>> #mesquite.minimal.ManageTaxa.ManageTaxa; tell It; setID 0
> >>>>>> 4448951287512167596; endTell; getWindow; tell It; suppress; 
> >>>>>> setResourcesState true false 100; setPopoutState 400; 
> >>>>>> setExplanationSize 0; setAnnotationSize 0; setFontIncAnnot
> >>>>>> 0; setFontIncExp 0; setSize 700 464; setLocation 8 8; setFont
> >>>>>> SanSerif; setFontSize 10; getToolPalette; tell It; endTell; 
> >>>>>> desuppress; endTell; endTell; end;
> >>>> 
> >>>> _______________________________________________ Phylobase-devl
> >>>> mailing list Phylobase-devl at lists.r-forge.r-project.org 
> >>>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/phylobase-devl
> >> 
> >>>> 
> >> _______________________________________________ Phylobase-devl
> >> mailing list Phylobase-devl at lists.r-forge.r-project.org 
> >> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/phylobase-devl
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.10 (GNU/Linux)
> > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> > 
> > iEYEARECAAYFAkzHjJIACgkQc5UpGjwzenP2mQCdFt3iRuiijonUwBJZ8gW/EX4D
> > Mp8AnAwH0zhc294cxFzHhT1uAoqB/skf
> > =t31O
> > -----END PGP SIGNATURE-----
> > _______________________________________________
> > Phylobase-devl mailing list
> > Phylobase-devl at lists.r-forge.r-project.org
> > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/phylobase-devl
> 
> _______________________________________________
> Phylobase-devl mailing list
> Phylobase-devl at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/phylobase-devl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.r-forge.r-project.org/pipermail/phylobase-devl/attachments/20101027/efe255ed/attachment.pgp>


More information about the Phylobase-devl mailing list