00001
00002 =head1 LICENSE
00003
00004 Copyright [1999-2014] 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:
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::GenomeComparaInfo
00029
00030 =head1 SYNOPSIS
00031
00032 my $compara_info =
00033 Bio::EnsEMBL::MetaData::GenomeComparaInfo->new(
00034 -DBNAME => $compara->dbc()->dbname(),
00035 -DIVISION => $division,
00036 -METHOD => $method,
00037 -SET_NAME => $set_name,
00038 -GENOMES => [$genome1, $genome2],
00039 -RELEASE => $release);
00040
00041 =head1 DESCRIPTION
00042
00043 Object encapsulating information about a particular compara analysis and the genomes it involves
00044
00045 =head1 SEE ALSO
00046
00047 Bio::EnsEMBL::MetaData::BaseInfo
00048 Bio::EnsEMBL::MetaData::GenomeInfo
00049 Bio::EnsEMBL::MetaData::DBSQL::GenomeComparaInfoAdaptor
00050
00051 =head1 Author
00052
00053 Dan Staines
00054
00055 =cut
00056
00057 package Bio::EnsEMBL::MetaData::GenomeComparaInfo;
00058 use base qw/Bio::EnsEMBL::MetaData::BaseInfo/;
00059 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
00060 use strict;
00061 use warnings;
00062
00063 =head1 CONSTRUCTOR
00064 =head2 new
00065 Arg [-DIVISION] :
00066 string - Compara division e.g. plants, pan_homology
00067 Arg [-METHOD] :
00068 string - compara method e.g. PROTEIN_TREES, LASTZ_NET
00069 Arg [-DBNAME] :
00070 string - name of the compara database in which the analysis can be found
00071 Arg [-SET_NAME] :
00072 string - optional name for the analysis
00073 Arg [-GENOMES] :
00074 arrayref - list of genomes involved in analysis
00075
00076 Example : $info = Bio::EnsEMBL::MetaData::GenomeComparaInfo->new(...);
00077 Description: Creates a new info object
00078 Returntype : Bio::EnsEMBL::MetaData::GenomeComparaInfo
00079 Exceptions : none
00080 Caller : general
00081 Status : Stable
00082
00083 =cut
00084
00085 sub new {
00086 my ( $class, @args ) = @_;
00087 my $self = $class->SUPER::new(@args);
00088 ( $self->{division}, $self->{method}, $self->{dbname},
00089 $self->{set_name}, $self->{genomes}, $self->{release} )
00090 = rearrange(
00091 [ 'DIVISION', 'METHOD', 'DBNAME', 'SET_NAME', 'GENOMES', 'DATA_RELEASE'
00092 ],
00093 @args );
00094 return $self;
00095 }
00096
00097 =head1 ATTRIBUTE METHODS
00098 =head2 dbname
00099 Arg : (optional) dbname to set
00100 Description: Gets/sets name of compara database
00101 Returntype : string
00102 Exceptions : none
00103 Caller : general
00104 Status : Stable
00105 =cut
00106
00107 sub dbname {
00108 my ( $self, $arg ) = @_;
00109 $self->{dbname} = $arg if ( defined $arg );
00110 return $self->{dbname};
00111 }
00112
00113 =head2 method
00114 Arg : (optional) method to set
00115 Description: Gets/sets name of compara method
00116 Returntype : string
00117 Exceptions : none
00118 Caller : general
00119 Status : Stable
00120 =cut
00121
00122 sub method {
00123 my ( $self, $arg ) = @_;
00124 $self->{method} = $arg if ( defined $arg );
00125 return $self->{method};
00126 }
00127
00128 =head2 set_name
00129 Arg : (optional) species set name to set
00130 Description: Gets/sets name of species set used in compara analysis
00131 Returntype : string
00132 Exceptions : none
00133 Caller : general
00134 Status : Stable
00135 =cut
00136
00137 sub set_name {
00138 my ( $self, $arg ) = @_;
00139 $self->{set_name} = $arg if ( defined $arg );
00140 return $self->{set_name};
00141 }
00142
00143 =head2 division
00144 Arg : (optional) division to set
00145 Description: Gets/sets Ensembl compara division
00146 Returntype : string
00147 Exceptions : none
00148 Caller : general
00149 Status : Stable
00150 =cut
00151
00152 sub division {
00153 my ( $self, $arg ) = @_;
00154 $self->{division} = $arg if ( defined $arg );
00155 return $self->{division};
00156 }
00157
00158 =head2 genomes
00159 Arg : (optional) genomes to set
00160 Description: Gets/sets arrayref of genomes
00161 Returntype : arrayref
00162 Exceptions : none
00163 Caller : general
00164 Status : Stable
00165 =cut
00166
00167 sub genomes {
00168 my ( $self, $arg ) = @_;
00169 $self->{genomes} = $arg if ( defined $arg );
00170 $self->_load_child("genomes","_fetch_compara_genomes");
00171 return $self->{genomes};
00172 }
00173
00174 =head1 UTILITY METHODS
00175 =head2 is_pan_compara
00176 Arg : (optional) 1/0 to set
00177 Description: Boolean-style method, returns 1 if analysis is part of the pan compara, 0 if not
00178 Returntype : 1 or 0
00179 Exceptions : none
00180 Caller : general
00181 Status : Stable
00182 =cut
00183
00184 sub is_pan_compara {
00185 my ($self) = @_;
00186 return $self->{division} eq 'EnsemblPan' ? 1 : 0;
00187 }
00188
00189 =head2 is_peptide_compara
00190 Arg : (optional) 1/0 to set
00191 Description: Boolean-style method, returns 1 if analysis is part of a peptide compara, 0 if not
00192 Returntype : 1 or 0
00193 Exceptions : none
00194 Caller : general
00195 Status : Stable
00196 =cut
00197
00198 sub is_peptide_compara {
00199 my ($self) = @_;
00200 return ( $self->{division} ne 'EnsemblPan' &&
00201 $self->{method} eq 'PROTEIN_TREES' ) ? 1 : 0;
00202 }
00203
00204 =head2 is_dna_compara
00205 Arg : (optional) 1/0 to set
00206 Description: Boolean-style method, returns 1 if analysis is part of a DNA compara, 0 if not
00207 Returntype : 1 or 0
00208 Exceptions : none
00209 Caller : general
00210 Status : Stable
00211 =cut
00212
00213 sub is_dna_compara {
00214 my ($self) = @_;
00215 return ( $self->{method} eq 'TRANSLATED_BLAT_NET' ||
00216 $self->{method} eq 'LASTZ_NET' ||
00217 $self->{method} eq 'TBLAT' ||
00218 $self->{method} eq 'ATAC' ||
00219 $self->{method} eq 'BLASTZ_NET' ) ? 1 : 0;
00220 }
00221
00222 =head2 is_synteny
00223 Arg : (optional) 1/0 to set
00224 Description: Boolean-style method, returns 1 if analysis is part of a synteny compara, 0 if not
00225 Returntype : 1 or 0
00226 Exceptions : none
00227 Caller : general
00228 Status : Stable
00229 =cut
00230
00231 sub is_synteny {
00232 my ($self) = @_;
00233 return ( $self->{method} eq 'SYNTENY' ) ? 1 : 0;
00234 }
00235
00236 =head2 to_hash
00237 Description: Render compara as plain hash suitable for export as JSON/XML
00238 Returntype : Hashref
00239 Exceptions : none
00240 Caller : general
00241 Status : Stable
00242 =cut
00243
00244 sub to_hash {
00245 my ($in) = @_;
00246 my $out = { method => $in->{method},
00247 division => $in->{division},
00248 dbname => $in->{dbname},
00249 set_name => $in->{set_name},
00250 is_pan_compara => $in->is_pan_compara(),
00251 is_peptide_compara => $in->is_peptide_compara(),
00252 is_dna_compara => $in->is_dna_compara(), };
00253 $out->{genomes} = [];
00254 for my $genome ( @{ $in->genomes() } ) {
00255 push @{ $out->{genomes} }, $genome->species();
00256 }
00257 return $out;
00258 }
00259
00260 =head2 to_string
00261 Description: Render as plain string
00262 Returntype : string
00263 Exceptions : none
00264 Caller : general
00265 Status : Stable
00266 =cut
00267 sub to_string {
00268 my ($self) = @_;
00269 return
00270 join( '/', $self->division(), $self->method(), ($self->set_name()||'-') );
00271 }
00272
00273 1;