00001 =head1 LICENSE
00002
00003 Copyright [2009-2016] EMBL-European Bioinformatics Institute
00004
00005 Licensed under the Apache License, Version 2.0 (the "License");
00006 you may not use this file except in compliance with the License.
00007 You may obtain a copy of the License at
00008
00009 http:
00010
00011 Unless required by applicable law or agreed to in writing, software
00012 distributed under the License is distributed on an "AS IS" BASIS,
00013 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 See the License for the specific language governing permissions and
00015 limitations under the License.
00016
00017 =head1 CONTACT
00018
00019 Please email comments or questions to the public Ensembl
00020 developers list at <dev@ensembl.org>.
00021
00022 Questions may also be sent to the Ensembl help desk at
00023 <helpdesk@ensembl.org>.
00024
00025 =head1 NAME
00026
00027 Bio::EnsEMBL::MetaData::MetaDataDumper::TT2MetaDataDumper
00028
00029 =head1 SYNOPSIS
00030
00031 =head1 DESCRIPTION
00032
00033 Implementation to dump metadata details to a TemplateToolKit file.
00034 See Bio::EnsEMBL::MetaData::MetaDataDumper for method details.
00035
00036 =head1 SEE ALSO
00037 Bio::EnsEMBL::MetaData::MetaDataDumper
00038
00039 =head1 AUTHOR
00040
00041 Dan Staines
00042
00043 =cut
00044
00045 package Bio::EnsEMBL::MetaData::MetaDataDumper::TT2MetaDataDumper;
00046 use base qw( Bio::EnsEMBL::MetaData::MetaDataDumper );
00047 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
00048 use Carp;
00049 use XML::Simple;
00050 use strict;
00051 use warnings;
00052
00053 sub new {
00054 my ($proto, @args) = @_;
00055 my $self = $proto->SUPER::new(@args);
00056 $self->{file} ||= 'species.tt2';
00057 $self->{division} ||= 'Ensembl';
00058 $self->{div_links} = {
00059 EnsemblBacteria => "http://bacteria.ensembl.org/",
00060 EnsemblFungi => "http://fungi.ensembl.org/",
00061 EnsemblMetazoa => "http://metazoa.ensembl.org/",
00062 EnsemblProtists => "http://protists.ensembl.org/",
00063 EnsemblPlants => "http://plants.ensembl.org/",
00064 Ensembl => "http://www.ensembl.org/",};
00065 $self->{div_names} = {EnsemblBacteria => "Bacteria",
00066 EnsemblFungi => "Fungi",
00067 EnsemblMetazoa => "Metazoa",
00068 EnsemblProtists => "Protists",
00069 EnsemblPlants => "Plants",
00070 Ensembl => "Ensembl",};
00071
00072 return $self;
00073 }
00074
00075 sub do_dump {
00076 my ($self, $metadata, $outfile) = @_;
00077 my $eg_version = $metadata->{genome}->[0]->{dbname};
00078 $eg_version =~ s/[a-z]+_([0-9]+)_[0-9]+_[0-9]+/$1/;
00079 my $td = '<td>';
00080 my $tdx = '</td>';
00081 my $tr = '<tr>';
00082 my $trx = '</tr>';
00083 open(my $tt2_file, '>', $outfile) ||
00084 croak "Could not write to " . $outfile;
00085 print $tt2_file <<"ENDHEAD";
00086 <style type="text/css" title="currentStyle">
00087 \@import "/static/css/grid.css";
00088 </style>
00089
00090 <script type="text/javascript" charset="utf-8" src="/static/js/jquery.dataTables.min.js"></script>
00091
00092 <script type="text/javascript">
00093 $(document).ready( function () {
00094 $('#species_list').dataTable({
00095 "sPaginationType": "full_numbers",
00096 "iDisplayLength": 25,
00097 "aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]]
00098 });
00099 } );
00100 </script>
00101 <div id="static">
00102 <h2>Ensembl Genomes Release $eg_version</h2>
00103 <p>Ensembl Genomes species metadata are also available via FTP: <a href="ftp://ftp.ensemblgenomes.org/pub/current/species.txt">Tabular text</a> | <a href="ftp://ftp.ensemblgenomes.org/pub/current/species_metadata.json">JSON</a> | <a href="ftp://ftp.ensemblgenomes.org/pub/current/species_metadata.xml">XML</a></p>
00104 <table cellpadding="0" cellspacing="0" border="1px dotted #eeeeee"
00105 class="display" id="species_list">
00106 <thead>
00107 <tr>
00108 <th>Species</th><th>Division</th><th>Taxonomy ID</th><th>Assembly</th><th>Genebuild</th><th>Variation</th><th>Pan compara</th><th>Genome alignments</th><th>Other alignments</th>
00109 </tr>
00110 </thead>
00111 <tbody>
00112 ENDHEAD
00113
00114 for my $md (@{$metadata->{genome}}) {
00115 my $div_link = $self->{div_links}->{$md->{division}};
00116 my $div_name = $self->{div_names}->{$md->{division}};
00117 if (!defined $div_link) {
00118 croak "No division defined for $md->{name}";
00119 }
00120 $div_link .= $md->{species};
00121 print $tt2_file join("",
00122 ($tr,
00123 $td,
00124 "<a href='${div_link}'>",
00125 $md->{name},
00126 '</a>',
00127 $tdx,
00128 $td,
00129 "<a href='",
00130 $div_link,
00131 "'>",
00132 $div_name,
00133 '</a>',
00134 $td,
00135 "<a href='http://www.uniprot.org/taxonomy/" .
00136 $md->{taxonomy_id} .
00137 "'>" . $md->{taxonomy_id} . "</a>",
00138 $tdx,
00139 $td,
00140 $md->{assembly_name},
00141 $tdx,
00142 $td,
00143 $md->{genebuild},
00144 $tdx,
00145 $td,
00146 $self->yesno($self->count_variation($md)),
00147 $tdx,
00148 $td,
00149 $self->yesno($md->{pan_species}),
00150 $tdx,
00151 $td,
00152 $self->yesno($self->count_dna_compara($md)),
00153 $tdx,
00154 $td,
00155 $self->yesno($self->count_alignments($md)),
00156 $tdx,
00157 $trx,
00158 "\n"));
00159 } ## end for my $md (@{$metadata...})
00160 print $tt2_file <<'ENDFOOT';
00161 </tbody>
00162 <tfoot>
00163 <tr>
00164 <th>Species</th><th>Division</th><th>Taxonomy ID</th><th>Assembly</th><th>Genebuild</th><th>Variation</th><th>Pan compara</th><th>Genome alignments</th><th>Other alignments</th>
00165 </tr>
00166 </tfoot>
00167 </table>
00168 </div>
00169 ENDFOOT
00170 close $tt2_file;
00171 return;
00172 } ## end sub do_dump
00173
00174 1;
00175
00176 __END__
00177
00178 =pod
00179
00180 =head1 NAME
00181
00182 Bio::EnsEMBL::MetaData::MetaDataDumper::XMLMetaDataDumper
00183
00184 =head1 SYNOPSIS
00185
00186 =head1 DESCRIPTION
00187
00188 implementation to dump metadata details to an XML file
00189
00190 =head1 SUBROUTINES/METHODS
00191
00192 =head2 new
00193
00194 =head2 dump_metadata
00195 Description : Dump metadata to the file supplied by the constructor
00196 Argument : Hash of details
00197
00198 =head1 AUTHOR
00199
00200 dstaines
00201
00202 =head1 MAINTAINER
00203
00204 $Author$
00205
00206 =head1 VERSION
00207
00208 $Revision$
00209
00210 =cut