DataReleaseInfo.pm
Go to the documentation of this file.
00001 
00002 =head1 LICENSE
00003 
00004 Copyright [1999-2016] EMBL-European Bioinformatics Institute
00005 
00006 Licensed under the Apache License, Version 2.0 (the "License");
00007 you may not use this file except in compliance with the License.
00008 You may obtain a copy of the License at
00009 
00010      http://www.apache.org/licenses/LICENSE-2.0
00011 
00012 Unless required by applicable law or agreed to in writing, software
00013 distributed under the License is distributed on an "AS IS" BASIS,
00014 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 See the License for the specific language governing permissions and
00016 limitations under the License.
00017 
00018 =head1 CONTACT
00019 
00020   Please email comments or questions to the public Ensembl
00021   developers list at <dev@ensembl.org>.
00022 
00023   Questions may also be sent to the Ensembl help desk at
00024   <helpdesk@ensembl.org>.
00025 
00026 =head1 NAME
00027 
00028 Bio::EnsEMBL::MetaData::DataReleaseInfo
00029 
00030 =head1 SYNOPSIS
00031 
00032       my $release_info =
00033         Bio::EnsEMBL::MetaData::GenomeDataReleaseInfo->new(
00034                                    -ENSEMBL_VERSION=>83,
00035                                    -EG_VERSION=>30,
00036                                    -DATE=>'2015-12-07');
00037 
00038 =head1 DESCRIPTION
00039 
00040 Object encapsulating information about a particular release of Ensembl or Ensembl Genomes
00041 
00042 =head1 SEE ALSO
00043 
00044 Bio::EnsEMBL::MetaData::BaseInfo
00045 Bio::EnsEMBL::MetaData::DBSQLDataReleaseInfoAdaptor
00046 
00047 =head1 AUTHOR
00048 
00049 Dan Staines
00050 
00051 =cut
00052 
00053 package Bio::EnsEMBL::MetaData::DataReleaseInfo;
00054 use base qw/Bio::EnsEMBL::MetaData::BaseInfo/;
00055 use Bio::EnsEMBL::MetaData::DatabaseInfo;
00056 use strict;
00057 use warnings;
00058 
00059 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
00060 use POSIX 'strftime';
00061 use Bio::EnsEMBL::ApiVersion;
00062 
00063 =head1 CONSTRUCTOR
00064 =head2 new
00065   Arg [-ENSEMBL_VERSION]  : 
00066        int - Ensembl version (by default current version from API)
00067   Arg [-EG_VERSION]    : 
00068        int - optional Ensembl Genomes version
00069   Arg [-RELEASE_DATE] : 
00070        string - date of the release as YYYY-MM-DD
00071 
00072   Example    : $info = Bio::EnsEMBL::MetaData::DataReleaseInfo->new(...);
00073   Description: Creates a new release info object
00074   Returntype : Bio::EnsEMBL::MetaData::DataReleaseInfo
00075   Exceptions : none
00076   Caller     : general
00077   Status     : Stable
00078 
00079 =cut
00080 sub new {
00081     my ( $class, @args ) = @_;
00082     my $self = $class->SUPER::new(@args);
00083     ( $self->{ensembl_version}, $self->{ensembl_genomes_version}, $self->{release_date} ) =
00084       rearrange( [ 'ENSEMBL_VERSION', 'ENSEMBL_GENOMES_VERSION', 'RELEASE_DATE' ], @args );
00085     $self->{ensembl_version} ||= software_version();
00086     $self->{release_date} ||= strftime '%Y-%m-%d', localtime;
00087     return $self;
00088 }
00089 
00090 =head1 ATTRIBUTE METHODS
00091 =head2 ensembl_version
00092   Arg        : (optional) version to set
00093   Description: Gets/sets name Ensembl version
00094   Returntype : string
00095   Exceptions : none
00096   Caller     : general
00097   Status     : Stable
00098 =cut
00099 
00100 sub ensembl_version {
00101     my ( $self, $arg ) = @_;
00102     $self->{ensembl_version} = $arg if ( defined $arg );
00103     return $self->{ensembl_version};
00104 }
00105 
00106 =head2 ensembl_genomes_version
00107   Arg        : (optional) version to set
00108   Description: Gets/sets name Ensembl version
00109   Returntype : string
00110   Exceptions : none
00111   Caller     : general
00112   Status     : Stable
00113 =cut
00114 
00115 sub ensembl_genomes_version {
00116     my ( $self, $arg ) = @_;
00117     $self->{ensembl_genomes_version} = $arg if ( defined $arg );
00118     return $self->{ensembl_genomes_version};
00119 }
00120 =head2 is_current
00121   Arg        : (optional) Integer to set if current
00122   Description: Gets/sets if release is current
00123   Returntype : Integer (1 if current)
00124   Exceptions : none
00125   Caller     : general
00126   Status     : Stable
00127 =cut
00128 sub is_current {
00129     my ( $self, $arg ) = @_;
00130     $self->{is_current} = $arg if ( defined $arg );
00131     return $self->{is_current};
00132 }
00133 
00134 =head2 databases
00135   Arg        : (optional) Arrayref of DatabaseInfo objects
00136   Description: Databases associated with this release
00137   Returntype : None
00138   Exceptions : none
00139   Caller     : general
00140   Status     : Stable
00141 =cut
00142 sub databases {
00143   my ($self, $databases) = @_;
00144   if(defined $databases) {
00145     $self->{databases} = $databases;
00146   }
00147   $self->_load_child( 'databases', '_fetch_databases' );
00148   return $self->{databases};
00149 }
00150 
00151 =head2 release_date
00152   Arg        : (optional) version to set
00153   Description: Gets/sets name Ensembl version
00154   Returntype : string
00155   Exceptions : none
00156   Caller     : general
00157   Status     : Stable
00158 =cut
00159 
00160 sub release_date {
00161     my ( $self, $arg ) = @_;
00162     $self->{release_date} = $arg if ( defined $arg );
00163     return $self->{release_date};
00164 }
00165 
00166 =head1 UTILITY METHODS
00167 =head2 add_database
00168   Arg        : String - Name of database
00169   Arg        : String - Name of Ensembl division
00170   Description: Associate a database with this release
00171   Returntype : None
00172   Exceptions : none
00173   Caller     : general
00174   Status     : Stable
00175 =cut
00176 
00177 sub add_database {
00178   my ( $self, $dbname, $division ) = @_;
00179   push @{$self->{databases}}, Bio::EnsEMBL::MetaData::DatabaseInfo->new(-DBNAME=>$dbname, -DIVISION=>$division, -SUBJECT => $self);
00180   return;
00181 }
00182 
00183 =head2 to_hash
00184   Description: Render as plain hash suitable for export as JSON/XML
00185   Returntype : Hashref
00186   Exceptions : none
00187   Caller     : general
00188   Status     : Stable
00189 =cut
00190 
00191 sub to_hash {
00192     my ($in) = @_;
00193     return { ensembl_version => $in->ensembl_version(),
00194              ensembl_genomes_version      => $in->ensembl_genomes_version(),
00195              release_date            => $in->release_date(), };
00196 }
00197 
00198 =head2 to_hash
00199   Description: Render as string for display
00200   Returntype : String
00201   Exceptions : none
00202   Caller     : general
00203   Status     : Stable
00204 =cut
00205 
00206 sub to_string {
00207     my ($self) = @_;
00208     return
00209       join( '/',
00210             $self->ensembl_version(), ($self->ensembl_genomes_version()||'-'), ( $self->release_date() ) );
00211 }
00212 
00213 1;