comparison variant_effect_predictor/Bio/EnsEMBL/Funcgen/Set.pm @ 0:1f6dce3d34e0

Uploaded
author mahtabm
date Thu, 11 Apr 2013 02:01:53 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1f6dce3d34e0
1
2 #
3 # Ensembl module for Bio::EnsEMBL::Funcgen::Set
4 #
5
6 =head1 LICENSE
7
8 Copyright (c) 1999-2011 The European Bioinformatics Institute and
9 Genome Research Limited. All rights reserved.
10
11 This software is distributed under a modified Apache license.
12 For license details, please see
13
14 http://www.ensembl.org/info/about/code_licence.html
15
16 =head1 CONTACT
17
18 Please email comments or questions to the public Ensembl
19 developers list at <ensembl-dev@ebi.ac.uk>.
20
21 Questions may also be sent to the Ensembl help desk at
22 <helpdesk@ensembl.org>.
23
24
25 =head1 NAME
26
27 Bio::EnsEMBL::Funcgen::Set - A module to represent a base Set object.
28
29
30 =head1 SYNOPSIS
31
32 use Bio::EnsEMBL::Funcgen::Set;
33
34 @INC = qw (Bio::EnsEMBL::Funcgen::Set)
35
36 sub new {
37 my $caller = shift;
38
39 my $class = ref($caller) || $caller;
40
41 my $self = $class->SUPER::new(@_);
42
43
44 }
45
46 =head1 DESCRIPTION
47
48 A base Set object which provides access common methods available across all Funcgen Set classes.
49
50
51 =cut
52
53 use strict;
54 use warnings;
55
56 package Bio::EnsEMBL::Funcgen::Set;
57
58 use Bio::EnsEMBL::Utils::Argument qw( rearrange );
59 use Bio::EnsEMBL::Utils::Exception qw( throw warning deprecate);
60 use Bio::EnsEMBL::Funcgen::Storable;
61
62 use vars qw(@ISA);
63 @ISA = qw(Bio::EnsEMBL::Funcgen::Storable);
64
65
66 =head2 new
67
68 Example : my $self = $class->SUPER::new(@_);
69 Description: Constructor for Set objects.
70 Returntype : Bio::EnsEMBL::Funcgen::Set
71 Exceptions : None
72 Caller : General
73 Status : At risk
74
75 =cut
76
77 sub new {
78 my $caller = shift;
79
80 my $class = ref($caller) || $caller;
81
82 my $self = $class->SUPER::new(@_);
83
84 #TYPE was never parsed here?
85 #Only in inheritants that used it i.e. FeatureSet
86
87 my ($name, $anal, $ftype, $ctype, $set_type, $fclass, $type)
88 = rearrange(['NAME', 'ANALYSIS', 'FEATURE_TYPE', 'CELL_TYPE', 'SET_TYPE', 'FEATURE_CLASS', 'TYPE'], @_);
89
90 throw('Need to specify a name') if ! defined $name;
91
92 $self->set_type($set_type);
93 $self->feature_class($fclass);
94 $self->feature_class($type) if $type;#Remove this when fully implemented
95 $self->{'name'} = $name;
96 $self->cell_type($ctype) if $ctype;
97 $self->feature_type($ftype) if $ftype;
98
99 if(defined $anal){
100 $self->analysis($anal);
101 }elsif($self->set_type ne 'input'){
102 #Could move this to child Sets and just set analysis here
103 #As with ftype
104 throw('Must pass a valid -analysis parameter for a '.ref($self));
105 }
106
107 return $self;
108 }
109
110
111
112
113
114
115 =head2 name
116
117 Example : my $set->name('SET1');
118 Description: Getter/Setter for the name of this Set.
119 Returntype : string
120 Exceptions : None
121 Caller : General
122 Status : At Risk
123
124 =cut
125
126 sub name {
127 my $self = shift;
128
129 return $self->{'name'};
130 }
131
132 =head2 cell_type
133
134 Example : my $dset_ctype_name = $dset->cell_type->name();
135 Description: Getter for the cell_type for this DataSet.
136 Returntype : Bio::EnsEMBL::Funcgen::CellType
137 Exceptions : throws if arg not valid
138 Caller : General
139 Status : At Risk
140
141 =cut
142
143 sub cell_type {
144 my ($self, $ctype) = @_;
145
146 if(defined $ctype){
147
148 if(! (ref($ctype) eq 'Bio::EnsEMBL::Funcgen::CellType'
149 && $ctype->dbID())){
150 throw('Must pass a valid stored Bio::EnsEMBL::Funcgen::CellType');
151 }
152 $self->{'cell_type'} = $ctype;
153 }
154
155 return $self->{'cell_type'};
156 }
157
158 =head2 feature_type
159
160 Example : my $dset_ftype_name = $dset->feature_type->name();
161 Description: Getter for the feature_type for this DataSet.
162 Returntype : Bio::EnsEMBL::Funcgen::FeatureType
163 Exceptions : Throws if arg not valid
164 Caller : General
165 Status : At Risk
166
167 =cut
168
169 sub feature_type {
170 my ($self, $ftype) = @_;
171
172 if(defined $ftype){
173
174 if(! (ref($ftype) eq 'Bio::EnsEMBL::Funcgen::FeatureType'
175 && $ftype->dbID())){
176 throw('Must pass a valid stored Bio::EnsEMBL::Funcgen::FeatureType');
177 }
178 $self->{'feature_type'} = $ftype;
179 }
180
181
182 return $self->{'feature_type'};
183 }
184
185
186 =head2 feature_class
187
188 Arg[0] : string - feature class e.g. result, annotated, regulatory or external.
189 Example : my $fclass = $dset->feature_class;
190 Description: Getter for the feature_type for this Set.
191 Returntype : string
192 Exceptions : None
193 Caller : General
194 Status : At Risk
195
196 =cut
197
198 #Supercededs type method in FeatureSet
199
200 sub feature_class {
201 my ($self, $fclass) = @_;
202
203 if(defined $fclass){
204
205 #Leave this an implement in inheritants
206 #if(! grep /^${fclass}$/, ('annotated', 'result', 'external', 'regulatory')){
207 # throw("You have no supplied a valid feature class:\t$fclass");
208 #}
209
210 $self->{'feature_class'} = $fclass;
211 }
212
213 return $self->{'feature_class'};
214 }
215
216
217
218 =head2 analysis
219
220 Example : my $anal_name = $set->analysis->logic_name();
221 Description: Getter for the analysis attribute for this Set.
222 Returntype : Bio::EnsEMBL::Analysis
223 Exceptions : None
224 Caller : General
225 Status : At Risk
226
227 =cut
228
229 sub analysis {
230 my $self = shift;
231
232 if(@_){
233 throw('Must pass a valid stored Analysis') if (! (ref($_[0]) eq 'Bio::EnsEMBL::Analysis'
234 && $_[0]->dbID()));
235 $self->{'analysis'} = shift;
236 }
237
238
239 return $self->{'analysis'};
240 }
241
242 =head2 display_label
243
244 Example : print $set->display_label();
245 Description: Getter for the display_label attribute for this Set.
246 This is more appropriate for teh predicted_features of the set.
247 Use the individual display_labels for each raw result set.
248 Returntype : str
249 Exceptions : None
250 Caller : General
251 Status : At Risk
252
253 =cut
254
255 sub display_label {
256 my $self = shift;
257
258
259 #Add display label in table?
260 #Can we aborc ResultSet method into this?
261
262 if(! $self->{'display_label'}){
263
264 #if($self->product_FeatureSet->feature_type->class() eq 'Regulatory Feature'){
265 # $self->{'display_label'} = 'Regulatory Features';
266 #}
267 #else{
268
269 #This only works for annotated/regulatory_feature sets and result sets
270 #Move to other Set classes?
271
272 $self->{'display_label'} = $self->feature_type->name()." -";
273 $self->{'display_label'} .= " ".($self->cell_type->display_label() ||
274 $self->cell_type->description() ||
275 $self->cell_type()->name());
276
277
278 if($self->set_type eq 'result'){
279 $self->{'display_label'} .= " signal";
280 }
281 else{
282 $self->{'display_label'} .= " enriched sites";
283 }
284 }
285
286 return $self->{'display_label'};
287 }
288
289
290
291 =head2 set_type
292
293 Example : my $set_type = $set->set_type;
294 Description: Getter for the Set type for this Set.
295 Returntype : string e.g. result, feature, data, input
296 Exceptions : None
297 Caller : General
298 Status : At Risk
299
300 =cut
301
302 sub set_type {
303 my ($self, $set_type) = @_;
304
305 if(defined $set_type){
306 $self->{'_set_type'} = $set_type;
307 }
308 elsif(! defined $self->{'_set_type'}){
309 my @namespace = split/\:\:/, ref($self);
310 ($self->{'_set_type'} = lc($namespace[$#namespace])) =~ s/set//;
311
312 }
313
314 return $self->{'_set_type'};
315 }
316
317 =head2 type
318
319 Example : my $type = $set->type;
320 Description: Getter for the type for this Set.
321 e.g. annotated, external, regulatory for FeatureSets
322 or
323 array, sequencing for InputSets
324 Currently not applicable to DataSets or ResultSets
325 Exceptions : None
326 Returntype : string
327 Exceptions : None
328 Caller : General
329 Status : At Risk
330
331 =cut
332
333 sub type {
334 my $self = shift;
335
336 deprecate("Please use feature_class instead");
337
338 return $self->feature_class(@_);
339
340 #$self->{'feature_class'} = shift if @_;
341
342 #return $self->{'feature_class'};
343 }
344
345
346
347 1;
348