ropensci / RNeXML

Implementing semantically rich NeXML I/O in R
https://docs.ropensci.org/RNeXML
Other
13 stars 9 forks source link

add show and summary methods for nexml class #50

Closed cboettig closed 10 years ago

cboettig commented 10 years ago

Done, see nexml_methods.R. Suggestions for improvement welcome.

Example:

f <- system.file("examples", "comp_analysis.xml", package="RNeXML")
read.nexml(f)
A nexml object representing:
     1 phylogenetic trees 
     4 meta elements 
     2 character matrices 
     10 taxonomic units 
 Taxa:   taxon_1, taxon_2, taxon_3, taxon_4, taxon_5, taxon_6 ... 

 NeXML generated by Bio::Phylo::Project v.0.56 using schema version: 0.9 
 size: 296.2 Kb 

Literally showing all the data would probably just be messy in any format, users wanting to see the nexml can look at the file (or cat(write.nexml(nexml)) to see in the R console).

rvosa commented 10 years ago

Would it be possible to indicate how many trees per tree block?

cboettig commented 10 years ago

Summary now prints number of trees by block:

A nexml object representing:
     2 phylogenetic tree blocks, where: 
     block 1 contains 2 phylogenetic trees
     block 2 contains 2 phylogenetic trees 
     2 meta elements 
     0 character matrices 
     92 taxonomic units 
 Taxa:   Struthioniformes, Tinamiformes, Craciformes, Galliformes, Anseriformes, Turniciformes ... 

 NeXML generated by RNeXML using schema version: 0.9 
 size: 1.1 Mb

With only one block it will still show the same layout as above, just saying 1 phylogenetic tree, block 1 contains... @rvosa this was a great suggestion, particularly since we provide different functions to handle different ways of converting the trees blocks into phylo objects, e.g. preserving always the block structure: get_trees_list(), or automatically collapsing length 1 lists with get_trees (so that a single tree in a single block is a "phylo" and not a 'list of multiPhylo. These functions are the same if there are multiple blocks with multiple trees.) We also have get_flat_trees which combines all blocks into a single multiPhylo list. So it's great that the user can now see the internal NeXML structure nicely summarized to help choose the appropriate format.

I'm definitely open to suggestions for tweaking this summary display further.