comparison variant_effect_predictor/Bio/EnsEMBL/Funcgen/ExperimentalChip.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::ExperimentalChip
3 #
4
5 =head1 LICENSE
6
7 Copyright (c) 1999-2011 The European Bioinformatics Institute and
8 Genome Research Limited. All rights reserved.
9
10 This software is distributed under a modified Apache license.
11 For license details, please see
12
13 http://www.ensembl.org/info/about/code_licence.html
14
15 =head1 CONTACT
16
17 Please email comments or questions to the public Ensembl
18 developers list at <ensembl-dev@ebi.ac.uk>.
19
20 Questions may also be sent to the Ensembl help desk at
21 <helpdesk@ensembl.org>.
22
23
24 =head1 NAME
25
26 Bio::EnsEMBL::Funcgen::ExperimentalChip - A module to represent a physical unique experimental chip.
27
28 =head1 SYNOPSIS
29
30 use Bio::EnsEMBL::Funcgen::ExperimentalChip;
31
32 my $ec = Bio::EnsEMBL::Funcgen::ExperimentalChip->new(
33 -dbID => $ec_id,
34 -unique_id => $c_uid,
35 -experiment_id => $exp_id,
36 -array_chip_id => $ac_id,
37 -feature_type => $ftpye,
38 -cell_type => $ctype,
39 -chip_set_id => 1,
40 );
41
42
43 =head1 DESCRIPTION
44
45 An ExperimentalChip object represent a physical array chip/slide used in an experiment. The data
46 (currently the unique_id, experiment_id, array_chip_id, and description) are stored
47 in the experimental_chip table.
48
49 =cut
50
51 use strict;
52 use warnings;
53
54
55 package Bio::EnsEMBL::Funcgen::ExperimentalChip;
56
57
58 use Bio::EnsEMBL::Utils::Argument qw( rearrange );
59 use Bio::EnsEMBL::Utils::Exception qw( throw warning );
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 Arg [-unique_id] : int - the unique id of this individual experimental chip
69 Arg [-experiment_id] : int - the experiment dbID
70 Arg [-array_chip_id] : int - the dbID or the array_chip
71 Arg [-feature_type ] : Bio::EnsEMBL::Funcgen::FeatureType
72 Arg [-cell_type ] : Bio::EnsEMBL::Funcgen::CellType
73 Arg [-biological_replicate ] : string - the name to define the biological replicate set
74 Arg [-technical_replicate ] : string - the name to define the technical replicate set
75
76
77 Example : my $array = Bio::EnsEMBL::Funcgen::ExperimentalChip->new(
78 -dbID => $ec_id,
79 -unique_id => $c_uid,
80 -experiment_id => $exp_id,
81 -array_chip_id => $ac_id,
82 -feature_type => $ftype,
83 -cell_type => $ftype,
84 -biological_replicate => 'BIOREP1',
85 -technical_replicate => 'techrep_1',
86 );
87 Description: Creates a new Bio::EnsEMBL::Funcgen::ExperimentalChip object.
88 Returntype : Bio::EnsEMBL::Funcgen::ExperimentalChip
89 Exceptions : None ? should throw if mandaotry params not set
90 Caller : General
91 Status : Medium Risk
92
93 =cut
94
95 sub new {
96 my $caller = shift;
97
98 my $class = ref($caller) || $caller;
99
100 my $self = $class->SUPER::new(@_);
101
102 #can we lc these?
103 my ($c_uid, $exp_dbid, $ac_id, $ftype, $ctype, $brep, $trep)
104 = rearrange( ['UNIQUE_ID', 'EXPERIMENT_ID', 'ARRAY_CHIP_ID', 'FEATURE_TYPE', 'CELL_TYPE', 'BIOLOGICAL_REPLICATE', 'TECHNICAL_REPLICATE'], @_ );
105
106
107 $self->unique_id($c_uid) if defined $c_uid;
108 $self->experiment_id($exp_dbid) if defined $exp_dbid;
109 $self->array_chip_id($ac_id) if defined $ac_id;
110 $self->feature_type($ftype) if defined $ftype;
111 $self->cell_type($ctype) if defined $ctype;
112 $self->biological_replicate($brep) if defined $brep;
113 $self->technical_replicate($trep) if defined $trep;
114 return $self;
115 }
116
117 =head2 get_Experiment
118
119 Args : None
120 Example : my $exp = $exp_chip->get_Experiment();
121 Description: Returns the Experiment which this ExperimentalChip belongs to.
122 Returntype : Bio::EnsEMBL::Funcgen::Experiment
123 Exceptions : None
124 Caller : General
125 Status : At Risk
126
127 =cut
128
129 sub get_Experiment {
130 my $self = shift;
131
132 if (! $self->{'experiment'}){
133
134 if ($self->dbID() && $self->adaptor() ) {
135 $self->{'experiment'} = $self->adaptor->db->get_ExperimentAdaptor->fetch_by_dbID($self->experiment_id);
136 } else {
137 warning('Need database connection to retrieve Experiment');
138 }
139 }
140
141
142 return $self->{'experiment'};
143 }
144
145
146
147 =head2 get_Channels
148
149 Args : None
150 Example : my $channels = $exp_chip->get_Channels();
151 Description: Returns all channels on a ExperimentalChip. Needs a database connection.
152 Returntype : Listref of Bio::EnsEMBL::Funcgen::Channel objects
153 Exceptions : None
154 Caller : General
155 Status : At Risk
156
157 =cut
158
159 sub get_Channels {
160 my $self = shift;
161
162 if (! $self->{'channels'}){
163
164 if ($self->dbID() && $self->adaptor() ) {
165 foreach my $channel (@{$self->adaptor->db->get_ChannelAdaptor->fetch_all_by_ExperimentalChip($self)}){
166 $self->add_Channel($channel);
167 }
168 } else {
169 warning('Need database connection to retrieve Channels');
170 }
171 }
172
173 return [values %{$self->{'channels'}}];
174 }
175
176
177 =head2 add_Channel
178
179 Args : Bio::EnsEMBL::Funcgen::Channel
180 Example : $exp_chip->add_channel($chan);
181 Description: Sets ad channel object for the ExperimentalChip
182 Returntype : Listref of Bio::EnsEMBL::Funcgen::Channel objects
183 Exceptions : warns if Channel already set
184 Caller : General
185 Status : At Risk
186
187 =cut
188
189 sub add_Channel{
190 my ($self, $chan) = @_;
191
192
193 if(! ($chan && $chan->isa("Bio::EnsEMBL::Funcgen::Channel") && $chan->dbID())){
194 throw("Must provide a valid stored Bio::EnsEMBL::Funcgen::Channel object");
195 }
196
197
198 $self->{'channels'} ||= {};
199
200 if (exists $self->{'channels'}->{$chan->dbID()}){
201 #should this throw?
202 #This currently prevents haveing to check whether a channel has already been added
203 #If we were duplicating then we probably would have a different dbID
204 warn("You cannot add the same Channel to an ExperimentalChip more than once");
205 }else{
206
207
208 ##change this to key on freq?
209
210 $self->{'channels'}{$chan->dbID()} = $chan;
211 }
212
213 return;
214 }
215
216
217
218 =head2 get_channel_ids
219
220 Args : None
221 Example : my @channel_ids = @{$array->get_channel_ids()};
222 Description: Returns all channel ids for an ExperimentalChip. Needs a database connection.
223 Returntype : List of ints
224 Exceptions : None
225 Caller : General
226 Status : Medium Risk
227
228 =cut
229
230 sub get_channel_ids{
231 my $self = shift;
232
233 $self->get_Channels();
234
235 return [keys %{$self->{'channels'}}];
236 }
237
238 =head2 get_Channel_by_dye
239
240 Args : string - dye used in channel
241 Example : my $chan = $echip->get_Channel_by_dye("CY5");
242 Description: Returnsthe channel corresponding to the frequency specified
243 Returntype : Bio::EnsEMBL::Funcgen::Channel
244 Exceptions : None
245 Caller : General
246 Status : At Risk
247
248 =cut
249
250 sub get_Channel_by_dye{
251 my ($self, $dye) = @_;
252
253 my @chans;
254
255 foreach my $chan(@{$self->get_Channels()}){
256 push @chans, $chan if uc($chan->dye()) eq uc($dye);
257 }
258
259 throw("Found more than one Channels with the same dye") if(scalar(@chans) > 1);
260
261
262 return (@chans) ? $chans[0] : undef;
263 }
264
265 =head2 contains_Channel
266
267 Args [1] : Bio::EnsEMBL::Funcgen::Channel
268 Example : if(! $echip->contains_Channel($chan){..add channel ..};
269 Description: Checks whether this Channel has already been added to the ExperimentalChip
270 Returntype : Boolean
271 Exceptions : Throws if arg not a valid stored Bio::EnseMBL::Funcgen::Channel
272 Caller : General
273 Status : At Risk
274
275 =cut
276
277 sub contains_Channel{
278 my ($self, $chan) = @_;
279
280 if(! ($chan && $chan->isa("Bio::EnsEMBL::Funcgen::Channel") && $chan->dbID())){
281 throw("Must provide a valid stored Bio::EnsEMBL::Funcgen::Channel object");
282 }
283
284 $self->get_Channels();
285
286 my $contains = 0;
287
288 $contains = 1 if(exists $self->{'channels'}->{$chan->dbID()});
289
290 return $contains;
291 }
292
293
294
295 =head2 unique_id
296
297 Arg [1] : (optional) int - the unique chip id for this ExperimentalChip
298 Example : my $c_uid = $array->unique_id();
299 Description: Getter, setter unique_id attribute.
300 Returntype : string
301 Exceptions : None
302 Caller : General
303 Status : at Risk
304
305 =cut
306
307 sub unique_id {
308 my $self = shift;
309 $self->{'unique_id'} = shift if @_;
310 return $self->{'unique_id'};
311 }
312
313 =head2 feature_type
314
315 Arg [1] : (optional) Bio::EnsEMBL::Funcgen::FeatureType
316 Example : $ec->feature_type($ftype);
317 Description: Getter/Setter thefeature_type attribute.
318 Returntype : Bio::EnsEMBL::Funcgen::FeatureType
319 Exceptions : Throws if arg is not a Bio::EnsEMBL::FeatureType
320 Caller : General
321 Status : At Risk
322
323 =cut
324
325 sub feature_type {
326 my $self = shift;
327
328 if(@_){
329 throw("Must pass a valid Bio::EnsEMBL::Funcgen::FeatureType object") if (! $_[0]->isa("Bio::EnsEMBL::Funcgen::FeatureType"));
330 $self->{'feature_type'} = shift;
331 }
332
333 return $self->{'feature_type'};
334 }
335
336
337 =head2 cell_type
338
339 Arg [1] : (optional) Bio::EnsEMBL::Funcgen::CellType
340 Example : $ec->cell_type($ctype);
341 Description: Getter/Setter the cell_type attribute.
342 Returntype : Bio::EnsEMBL::Funcgen::CellType
343 Exceptions : Throws if arg is not a Bio::EnsEMBL::CellType
344 Caller : General
345 Status : At Risk
346
347 =cut
348
349 sub cell_type {
350 my $self = shift;
351
352 if(@_){
353 throw("Must pass a valid Bio::EnsEMBL::Funcgen::CellType object") if (! $_[0]->isa("Bio::EnsEMBL::Funcgen::CellType"));
354 $self->{'cell_type'} = shift;
355 }
356
357 return $self->{'cell_type'};
358 }
359
360
361
362 =head2 biological_replicate
363
364 Arg [1] : (optional) string - the name or number of the chip biological replicate set
365 Example : $ec->biological_replicate('SAMPLENAME_BR1');
366 Description: Getter, setter for the biological_replicate attribute.
367 Returntype : string
368 Exceptions : None
369 Caller : General
370 Status : At Risk
371
372 =cut
373
374 sub biological_replicate {
375 my $self = shift;
376 $self->{'biological_replicate'} = shift if @_;
377 return $self->{'biological_replicate'};
378 }
379
380 =head2 technical_replicate
381
382 Arg [1] : (optional) string - the name or number of the chip technical replicate set
383 Example : $ec->technical_replicate('SAMPLENAME_BR1_TR1');
384 Description: Getter, setter for the technical_replicate attribute.
385 Returntype : string
386 Exceptions : None
387 Caller : General
388 Status : At Risk
389
390 =cut
391
392 sub technical_replicate {
393 my $self = shift;
394 $self->{'technical_replicate'} = shift if @_;
395 return $self->{'technical_replicate'};
396 }
397
398
399
400 =head2 experiment_id
401
402 Arg [1] : (optional) int - the experiment dbID
403 Example : my $exp_id = $array->experiment_id();
404 Description: Getter, setter experiment_id attribute
405 Returntype : int
406 Exceptions : None
407 Caller : General
408 Status : Medium Risk
409
410 =cut
411
412 sub experiment_id {
413 my $self = shift;
414 $self->{'experiment_id'} = shift if @_;
415 return $self->{'experiment_id'};
416 }
417
418 =head2 array_chip_id
419
420 Arg [1] : (optional) int - the array_chip dbID
421 Example : my $ac_id = $ec->array_chip_id();
422 Description: Getter, setter array_chip_id attribute
423 Returntype : int
424 Exceptions : None
425 Caller : General
426 Status : Medium Risk
427
428 =cut
429
430 sub array_chip_id {
431 my $self = shift;
432 $self->{'array_chip_id'} = shift if @_;
433 return $self->{'array_chip_id'};
434 }
435
436 =head2 get_ArrayChip
437
438 Example : my $array_chip = $exp_chip->get_ArrayChip();
439 Description: Getter for the array_chip attribute
440 Returntype : Bio::EnsEMBL::Funcgen::ArrayChip
441 Exceptions : None
442 Caller : General
443 Status : At Risk
444
445 =cut
446
447 sub get_ArrayChip {
448 my $self = shift;
449
450 if(! defined $self->{'array_chip'}){
451 $self->{'array_chip'} = $self->adaptor->db->get_ArrayChipAdaptor()->fetch_by_dbID($self->array_chip_id());
452 }
453
454 return $self->{'array_chip'};
455 }
456
457
458
459 1;
460