comparison variant_effect_predictor/Bio/EnsEMBL/Funcgen/ExperimentalSet.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 # Ensembl module for Bio::EnsEMBL::Funcgen::ExperimentalSubset
3 #
4 # You may distribute this module under the same terms as Perl itself
5
6 =head1 NAME
7
8 Bio::EnsEMBL::ExperimentalSet - A module to represent ExperimentalSet object.
9
10
11 =head1 SYNOPSIS
12
13 use Bio::EnsEMBL::Funcgen::ExpeimentalSet;
14
15 my $data_set = Bio::EnsEMBL::Funcgen::ExperimentalSet->new(
16 -DBID => $dbID,
17 -ADAPTOR => $self,
18 -EXPERIMENT => $exp,
19 -FEATURE_TYPE => $ftype,
20 -CELL_TYPE => $ctype,
21 -FORMAT => 'READ_FORMAT',
22 -VENDOR => 'SOLEXA',
23 -NAME => 'ExpSet1',
24 );
25
26
27
28 =head1 DESCRIPTION
29
30 An ExperimentalSet object provides a generic container for any non-array based feature import,
31 allowing tracking of file import via the status table and integration into Data and FeatureSets to
32 provide traceability to the source experiment from a given FeatureSet.
33
34 =head1 AUTHOR
35
36 This module was created by Nathan Johnson.
37
38 This module is part of the Ensembl project: http://www.ensembl.org/
39
40 =head1 CONTACT
41
42 Post comments or questions to the Ensembl development list: ensembl-dev@ebi.ac.uk
43
44 =head1 METHODS
45
46 =cut
47
48 use strict;
49 use warnings;
50
51 package Bio::EnsEMBL::Funcgen::ExperimentalSet;
52
53 use Bio::EnsEMBL::Funcgen::ExperimentalSubset;
54 use Bio::EnsEMBL::Utils::Argument qw( rearrange );
55 use Bio::EnsEMBL::Utils::Exception qw( throw warning deprecate);
56 use Bio::EnsEMBL::Funcgen::Set;
57
58
59 use vars qw(@ISA);
60 @ISA = qw(Bio::EnsEMBL::Funcgen::Set);#change to Set once we have implemented analysis properly
61
62
63 =head2 new
64
65
66
67 Example : my $eset = Bio::EnsEMBL::Funcgen::ExperimentalSet->new(
68 -EXPERIMENT => $exp,
69 -FEATURE_TYPE => $ftype,
70 -CELL_TYPE => $ctype,
71 -FORMAT => 'READ_FORMAT',
72 -VENDOR => 'SOLEXA',
73 -NAME => 'ExpSet1',
74 -ANALYSIS => $anal,
75 );
76
77 Do we want to define subsets likes this or are we more likely to add them one by one?
78
79 Description: Constructor for ExperimentalSet objects.
80 Returntype : Bio::EnsEMBL::Funcgen::ExperimentalSet
81 Exceptions : Throws if no Experiment defined
82 Throws if CellType or FeatureType are not valid or stored
83 Caller : General
84 Status : At risk
85
86 =cut
87
88 sub new {
89 my $caller = shift;
90
91 my $class = ref($caller) || $caller;
92
93 my $self = $class->SUPER::new(@_);
94
95 #do we need to add $fg_ids to this? Currently maintaining one feature_group focus.(combi exps?)
96 my ($exp, $format, $vendor)
97 = rearrange(['EXPERIMENT', 'FORMAT', 'VENDOR'], @_);
98
99 if (! (ref $exp && $exp->isa('Bio::EnsEMBL::Funcgen::Experiment') && $exp->dbID())){
100 throw('Must specify a valid stored Bio::EnsEMBL::Funcgen::Experiment');
101 }
102
103
104 #These are set in Set, just validate here
105 throw ('Must provide a FeatureType') if(! defined $self->feature_type);
106 throw ('Must provide a CellType') if(! defined $self->cell_type);
107
108
109
110 if(! defined $self->analysis){
111 #default analysis hack for v47
112 #Set directly to avoid dbID boolean check
113 $self->{'analysis'} = Bio::EnsEMBL::Analysis->new(-logic_name => 'external',
114 -id => 0,#??someone needs to rewrite analysis
115 );
116 }
117
118 $self->format($format) if defined $format;
119 $self->vendor($vendor) if defined $vendor;
120 $self->{'experiment'} = $exp;
121 $self->{'subsets'} = {};
122
123 return $self;
124 }
125
126
127 =head2 add_new_subset
128
129 Arg [1] : string - sub set name e.g. the file name (not path as we're restricted to 30 chars)
130 Example : $expset->add_new_subset($ss_name, $exp_subset);
131 Description: Adds experimental_subset
132 Returntype : none
133 Exceptions : Throws if set is already present
134 Throws if ExperimentalSubset is not valid or stored
135 Caller : General
136 Status : At Risk
137
138 =cut
139
140 sub add_new_subset {
141 my ($self, $ss_name, $exp_sset) = @_;
142
143 if($self->get_subset_by_name($ss_name)){
144 throw("Subset $ss_name is already present in this ExperimentalSet, maybe you need to alter the filename?");
145 }
146
147 if(defined $exp_sset){
148
149 if(!(ref($exp_sset) && $exp_sset->isa('Bio::EnsEMBL::Funcgen::ExperimentalSubset') && $exp_sset->dbID())){
150 throw('ExperimentalSubsets must be valid and stored');
151 }
152 }
153 else{
154
155 $exp_sset = Bio::EnsEMBL::Funcgen::ExperimentalSubset->new(
156 -name => $ss_name,
157 -experimental_set => $self,
158 );
159 }
160
161 $self->{'subsets'}{$ss_name} = $exp_sset;
162
163 return $self->{'subsets'}{$ss_name};
164 }
165
166
167 =head2 get_Experiment
168
169 Example : my $exp = $exp_set->get_Experiment();
170 Description: Getter for the Experiment of this DataSet.
171 Returntype : Bio::EnsEMBL::Fuuncgen::Experiment
172 Exceptions : None
173 Caller : General
174 Status : At Risk
175
176 =cut
177
178 sub get_Experiment{
179 my $self = shift;
180
181 return $self->{'experiment'};
182 }
183
184
185 =head2 get_subsets
186
187 Example : my @subsets = @{$exp_set->get_subsets()};
188 Description: Getter for the subsets for this ExperimentalSet.
189 Returntype : Arrayref
190 Exceptions : None
191 Caller : General
192 Status : At Risk
193
194 =cut
195
196 sub get_subsets{
197 my ($self) = shift;
198
199 return [ values %{$self->{'subsets'}} ];
200 }
201
202 =head2 get_subset_by_name
203
204 Example : my $subsets = $exp_set->get_subset_by_name('subset1');
205 Description: Getter for the subset of a given name for this ExperimentalSet.
206 Returntype : Bio::EnsEMBL::Funcgen::ExpeirmentalSubset
207 Exceptions : None
208 Caller : General
209 Status : At Risk
210
211 =cut
212
213 sub get_subset_by_name{
214 my ($self, $name) = @_;
215
216 return (exists $self->{'subsets'}{$name}) ? $self->{'subsets'}{$name} : undef;
217 }
218
219 =head2 get_subset_names
220
221 Example : my @subset_names = @{$exp_set->get_subset_names()};
222 Description: Getter for the subset names for this ExperimentalSet.
223 Returntype : Arrayref
224 Exceptions : None
225 Caller : General
226 Status : At Risk
227
228 =cut
229
230 sub get_subset_names{
231 my ($self) = shift;
232
233 return [ keys %{$self->{'subsets'}} ];
234 }
235
236
237
238
239 =head2 vendor
240
241 Arg[1] : string - vendor
242 Example : my $eset->vendor('SOLEXA');
243 Description: Getter/Setter for the vendor attribute of this DataSet.
244 Returntype : string
245 Exceptions : None
246 Caller : General
247 Status : At Risk
248
249 =cut
250
251 sub vendor {
252 my $self = shift;
253
254 $self->{'vendor'} = shift if @_;
255
256 return $self->{'vendor'};
257 }
258
259
260 =head2 format
261
262 Arg[1] : string - format i.e. product type/format
263 Example : my $eset->format('DATASET1');
264 Description: Getter/Setter for the format attribute of this ExperimentalSet.
265 Returntype : string
266 Exceptions : None
267 Caller : General
268 Status : At Risk
269
270 =cut
271
272 sub format {
273 my $self = shift;
274
275 $self->{'format'} = shift if @_;
276
277 return $self->{'format'};
278 }
279
280 1;
281