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