| 1 | package Bio::Phylo::Unparsers::Cdao; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use base 'Bio::Phylo::Unparsers::Abstract'; | ||
| 5 | use Bio::Phylo::Util::Exceptions 'throw'; | ||
| 6 | use Bio::Phylo::Util::CONSTANT qw':objecttypes looks_like_object'; | ||
| 7 | use File::Temp 'tempfile'; | ||
| 8 | |||
| 9 | =head1 NAME | ||
| 10 | |||
| 11 | Bio::Phylo::Unparsers::Cdao - Serializer used by Bio::Phylo::IO, no serviceable parts inside | ||
| 12 | |||
| 13 | =head1 DESCRIPTION | ||
| 14 | |||
| 15 | This module generates an RDF representation of a Bio::Phylo::Project object, | ||
| 16 | using terms from the CDAO ontology: L<http://www.evolutionaryontology.org/cdao>. | ||
| 17 | |||
| 18 | The module depends on the xsltproc utility being present in the PATH of your | ||
| 19 | system: L<http://xmlsoft.org/XSLT/xsltproc2.html>. If your xsltproc is in a | ||
| 20 | different location, you can optionally specify it with the -xsltproc => (path) | ||
| 21 | argument to the unparse() call. | ||
| 22 | |||
| 23 | Unless an additional -xslt => (file|url) argument is passed to the unparse() | ||
| 24 | call, xsltproc will try to download the stylesheet that transforms NeXML to | ||
| 25 | RDF from this location: L<http://nexml.org/nexml/xslt/nexml2cdao.xsl>. This | ||
| 26 | means that, if you don't give the -xslt argument, your computer must be | ||
| 27 | connected to the internet. | ||
| 28 | |||
| 29 | =cut | ||
| 30 | |||
| 31 | sub _to_string { | ||
| 32 | my $self = shift; | ||
| 33 | my $project = $self->{'PHYLO'}; | ||
| 34 | if ( looks_like_object $project, _PROJECT_ ) { | ||
| 35 | my $stylesheet = $self->{'XSLT'} || $ENV{'NEXML_ROOT'} ? $ENV{'NEXML_ROOT'} . '/xslt/nexml2cdao.xsl' : 'http://nexml.org/nexml/xslt/nexml2cdao.xsl'; | ||
| 36 | my $xsltproc = $self->{'XSLTPROC'} || 'xsltproc'; | ||
| 37 | my ( $fh, $file ) = tempfile(); | ||
| 38 | print $fh $project->to_xml; | ||
| 39 | my $result = `$xsltproc $stylesheet $file`; | ||
| 40 | if ( $? ) { | ||
| 41 | throw 'System' => "Error running xsltproc - exited with $?"; | ||
| 42 | } | ||
| 43 | else { | ||
| 44 | return $result; | ||
| 45 | } | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | # podinherit_insert_token | ||
| 50 | |||
| 51 | =head1 SEE ALSO | ||
| 52 | |||
| 53 | There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo> | ||
| 54 | for any user or developer questions and discussions. | ||
| 55 | |||
| 56 | =over | ||
| 57 | |||
| 58 | =item L<Bio::Phylo::IO> | ||
| 59 | |||
| 60 | The cdao unparser is called by the L<Bio::Phylo::IO> object. | ||
| 61 | Look there to learn how to create phylip formatted files. | ||
| 62 | |||
| 63 | =item L<Bio::Phylo::Manual> | ||
| 64 | |||
| 65 | Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com>. | ||
| 66 | |||
| 67 | =back | ||
| 68 | |||
| 69 | =head1 CITATION | ||
| 70 | |||
| 71 | If you use Bio::Phylo in published research, please cite it: | ||
| 72 | |||
| 73 | B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen> | ||
| 74 | and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl. | ||
| 75 | I<BMC Bioinformatics> B<12>:63. | ||
| 76 | L<http://dx.doi.org/10.1186/1471-2105-12-63> | ||
| 77 | |||
| 78 | |||
| 79 | |||
| 80 | =cut | ||
| 81 | |||
| 82 | 1; |