Source code: org/biomage/BioAssay/PhysicalBioAssay.java
1 /***************************************************************************
2 * *
3 * C O P Y R I G H T N O T I C E *
4 * Copyright (c) 2001 by: *
5 * * The MicroArray Gene Expression Database group (MGED) *
6 * * Rosetta Inpharmatics *
7 * *
8 * All Rights Reserved. *
9 * *
10 * Permission is hereby granted, free of charge, to any person *
11 * obtaining a copy of this software and associated documentation files *
12 * (the "Software"), to deal in the Software without restriction, *
13 * including without limitation the rights to use, copy, modify, merge, *
14 * publish, distribute, sublicense, and/or sell copies of the Software, *
15 * and to permit persons to whom the Software is furnished to do so, *
16 * subject to the following conditions: *
17 * *
18 * The above copyright notice and this permission notice shall be *
19 * included in all copies or substantial portions of the Software. *
20 * *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *
25 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *
26 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *
28 * SOFTWARE. *
29 ***************************************************************************
30 * *
31 * Created by the create_mage_java_classes java program based on the *
32 * information in the xmi file created from the MAGE-OM UML model, *
33 * copyright European Bioinformatics Institute (EBI) for MGED and Rosetta *
34 * Informatics. *
35 * *
36 * The ideas and work are built on the previous work in perl of Jason *
37 * Stewart, Open Informatics, and Robert M. Hubley, Institute for Systems *
38 * Biology *
39 * *
40 * @author Michael Miller, Rosetta Inpharmatics *
41 * @version Revision: 1.0 *
42 * @date Thu, Feb 21, 2002 10:46:11 AM *
43 * *
44 ***************************************************************************
45 */
46
47 /**
48 * org.biomage.BioAssay
49 *
50 */
51 package org.biomage.BioAssay;
52
53 /**
54 * Import list for PhysicalBioAssay
55 *
56 */
57 import java.io.Serializable;
58 import java.util.*;
59 import org.xml.sax.Attributes;
60 import java.io.Writer;
61 import java.io.IOException;
62 import org.biomage.Interface.HasPhysicalBioAssayData;
63 import org.biomage.Interface.HasBioAssayCreation;
64 import org.biomage.Interface.HasBioAssayTreatments;
65
66 /**
67 * A bioAssay created by the bioAssayCreation event (e.g. in gene
68 * expression analysis this event is represented by the hybridization
69 * event).
70 *
71 */
72 public
73 class PhysicalBioAssay
74 extends BioAssay
75 implements Serializable,
76 HasPhysicalBioAssayData,
77 HasBioAssayCreation,
78 HasBioAssayTreatments
79 {
80 /**
81 * The Images associated with this PhysicalBioAssay by
82 * ImageAcquisition.
83 *
84 */
85 private PhysicalBioAssayData_list physicalBioAssayData = new PhysicalBioAssayData_list();
86
87 /**
88 * The association between the BioAssayCreation event (typically
89 * Hybridization) and the PhysicalBioAssay and its annotation of this
90 * event.
91 *
92 */
93 private BioAssayCreation bioAssayCreation;
94
95
96 /**
97 * The set of treatments undergone by this PhysicalBioAssay.
98 *
99 */
100 private BioAssayTreatments_list bioAssayTreatments = new BioAssayTreatments_list();
101
102 /**
103 * Default constructor.
104 *
105 */
106 public
107 PhysicalBioAssay()
108 {
109 super();
110 }
111
112 /**
113 * Attribute constructor.
114 *
115 * Looks up the attributes in the parameter and casts them from strings
116 * appropriately
117 * @param atts: the attribute list.
118 *
119 */
120 // TODO Work in progress (attribute constructor).
121 public
122 PhysicalBioAssay(Attributes atts)
123 {
124 super(atts);
125
126 }
127
128 /**
129 * writeMAGEML
130 * <p>
131 * This method is responsible for assembling the attribute and
132 * association data into XML. It creates the object tag and then calls
133 * the writeAttributes and writeAssociation methods.
134 * <p>
135 *
136 */
137 public
138 void
139 writeMAGEML(Writer out)
140 throws IOException
141 {
142 out.write("<PhysicalBioAssay");
143 writeAttributes(out);
144 out.write(">");
145 writeAssociations(out);
146 out.write("</PhysicalBioAssay>");
147 }
148
149 /**
150 * writeAttributes
151 * <p>
152 * This method is responsible for assembling the attribute data into
153 * XML. It calls the super method to write out all attributes of this
154 * class and it's ancestors.
155 * <p>
156 *
157 */
158 public
159 void
160 writeAttributes(Writer out)
161 throws IOException
162 {
163 super.writeAttributes(out);
164 }
165
166 /**
167 * writeAssociations
168 * <p>
169 * This method is responsible for assembling the association data
170 * into XML. It calls the super method to write out all associations of
171 * this class's ancestors.
172 * <p>
173 *
174 */
175 public
176 void
177 writeAssociations(Writer out)
178 throws IOException
179 {
180 super.writeAssociations(out);
181 if ( physicalBioAssayData.size() > 0 ){
182 out.write("<PhysicalBioAssayData_assnlist>");
183 for ( int i = 0; i < physicalBioAssayData.size(); i++) {
184 ((Image)physicalBioAssayData.elementAt(i)).writeMAGEML(out);
185 }
186 out.write("</PhysicalBioAssayData_assnlist>");
187 }
188 if ( bioAssayCreation != null ){
189 out.write("<BioAssayCreation_assn>");
190 bioAssayCreation.writeMAGEML(out);
191 out.write("</BioAssayCreation_assn>");
192 }
193 if ( bioAssayTreatments.size() > 0 ){
194 out.write("<BioAssayTreatments_assnlist>");
195 for ( int i = 0; i < bioAssayTreatments.size(); i++) {
196 ((BioAssayTreatment)bioAssayTreatments.elementAt(i)).writeMAGEML(out);
197 }
198 out.write("</BioAssayTreatments_assnlist>");
199 }
200 }
201
202 /**
203 * Set method for physicalBioAssayData
204 * <p>
205 * @param value to set
206 * <p>
207 *
208 */
209 public
210 void
211 setPhysicalBioAssayData(
212 PhysicalBioAssayData_list physicalBioAssayData
213 )
214 {
215 ((List)this.physicalBioAssayData).addAll((List)physicalBioAssayData);
216 }
217
218 /**
219 * Get method for physicalBioAssayData
220 * <p>
221 * @return value of the attribute
222 * <p>
223 *
224 */
225 public
226 PhysicalBioAssayData_list
227 getPhysicalBioAssayData()
228 {
229 return physicalBioAssayData;
230 }
231
232 /**
233 * Method to add Image to PhysicalBioAssayData_list
234 *
235 */
236 public
237 void
238 addToPhysicalBioAssayData(
239 Image image
240 )
241 {
242 this.physicalBioAssayData.add(image);
243 }
244
245 /**
246 * Method to add Image at position to PhysicalBioAssayData_list
247 *
248 */
249 public
250 void
251 addToPhysicalBioAssayData(
252 int position,
253 Image image
254 )
255 {
256 this.physicalBioAssayData.add(position, image);
257 }
258
259 /**
260 * Method to get Image from PhysicalBioAssayData_list
261 *
262 */
263 public
264 Image
265 getFromPhysicalBioAssayData(
266 int position
267 )
268 {
269 return (Image) this.physicalBioAssayData.get(position);
270 }
271
272 /**
273 * Method to remove by position from PhysicalBioAssayData_list
274 *
275 */
276 public
277 void
278 removeElementAtFromPhysicalBioAssayData(
279 int position
280 )
281 {
282 this.physicalBioAssayData.removeElementAt(position);
283 }
284
285 /**
286 * Method to remove first Image from PhysicalBioAssayData_list
287 *
288 */
289 public
290 void
291 removeFromPhysicalBioAssayData(
292 Image image
293 )
294 {
295 this.physicalBioAssayData.remove(image);
296 }
297
298 /**
299 * Set method for bioAssayCreation
300 * <p>
301 * @param value to set
302 * <p>
303 *
304 */
305 public
306 void
307 setBioAssayCreation(
308 BioAssayCreation bioAssayCreation
309 )
310 {
311 this.bioAssayCreation = bioAssayCreation;
312 }
313
314 /**
315 * Get method for bioAssayCreation
316 * <p>
317 * @return value of the attribute
318 * <p>
319 *
320 */
321 public
322 BioAssayCreation
323 getBioAssayCreation()
324 {
325 return bioAssayCreation;
326 }
327
328 /**
329 * Set method for bioAssayTreatments
330 * <p>
331 * @param value to set
332 * <p>
333 *
334 */
335 public
336 void
337 setBioAssayTreatments(
338 BioAssayTreatments_list bioAssayTreatments
339 )
340 {
341 ((List)this.bioAssayTreatments).addAll((List)bioAssayTreatments);
342 }
343
344 /**
345 * Get method for bioAssayTreatments
346 * <p>
347 * @return value of the attribute
348 * <p>
349 *
350 */
351 public
352 BioAssayTreatments_list
353 getBioAssayTreatments()
354 {
355 return bioAssayTreatments;
356 }
357
358 /**
359 * Method to add BioAssayTreatment to BioAssayTreatments_list
360 *
361 */
362 public
363 void
364 addToBioAssayTreatments(
365 BioAssayTreatment bioAssayTreatment
366 )
367 {
368 this.bioAssayTreatments.add(bioAssayTreatment);
369 }
370
371 /**
372 * Method to add BioAssayTreatment at position to
373 * BioAssayTreatments_list
374 *
375 */
376 public
377 void
378 addToBioAssayTreatments(
379 int position,
380 BioAssayTreatment bioAssayTreatment
381 )
382 {
383 this.bioAssayTreatments.add(position, bioAssayTreatment);
384 }
385
386 /**
387 * Method to get BioAssayTreatment from BioAssayTreatments_list
388 *
389 */
390 public
391 BioAssayTreatment
392 getFromBioAssayTreatments(
393 int position
394 )
395 {
396 return (BioAssayTreatment) this.bioAssayTreatments.get(position);
397 }
398
399 /**
400 * Method to remove by position from BioAssayTreatments_list
401 *
402 */
403 public
404 void
405 removeElementAtFromBioAssayTreatments(
406 int position
407 )
408 {
409 this.bioAssayTreatments.removeElementAt(position);
410 }
411
412 /**
413 * Method to remove first BioAssayTreatment from
414 * BioAssayTreatments_list
415 *
416 */
417 public
418 void
419 removeFromBioAssayTreatments(
420 BioAssayTreatment bioAssayTreatment
421 )
422 {
423 this.bioAssayTreatments.remove(bioAssayTreatment);
424 }
425
426 }