Source code: org/biomage/ArrayDesign/FeatureGroup.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:02 AM *
43 * *
44 ***************************************************************************
45 */
46
47 /**
48 * org.biomage.ArrayDesign
49 *
50 */
51 package org.biomage.ArrayDesign;
52
53 /**
54 * Import list for FeatureGroup
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.HasDistanceUnit;
63 import org.biomage.Interface.HasFeatures;
64 import org.biomage.Interface.HasTechnologyType;
65 import org.biomage.Interface.HasFeatureShape;
66 import org.biomage.Description.OntologyEntry;
67 import org.biomage.DesignElement.Feature;
68 import org.biomage.Measurement.DistanceUnit;
69
70 /**
71 * A collection of like features.
72 *
73 */
74 public
75 class FeatureGroup
76 extends DesignElementGroup
77 implements Serializable,
78 HasDistanceUnit,
79 HasFeatures,
80 HasTechnologyType,
81 HasFeatureShape
82 {
83 /**
84 * The width of the feature.
85 *
86 */
87 float featureWidth;
88
89 /**
90 * The length of the feature.
91 *
92 */
93 float featureLength;
94
95 /**
96 * The height of the feature.
97 *
98 */
99 float featureHeight;
100
101 /**
102 * The unit for the feature measures.
103 *
104 */
105 private DistanceUnit distanceUnit;
106
107
108 /**
109 * The features that belong to this group.
110 *
111 */
112 private Features_list features = new Features_list();
113
114 /**
115 * The technology type of this design. By specifying a technology
116 * type, higher level analysis can use appropriate algorithms to
117 * compare the results from multiple arrays. The technology type may
118 * be spotted cDNA or in situ photolithography.
119 *
120 */
121 private OntologyEntry technologyType;
122
123
124 /**
125 * The expected shape of the feature on the array: circular, oval,
126 * square, etc.
127 *
128 */
129 private OntologyEntry featureShape;
130
131
132 /**
133 * Default constructor.
134 *
135 */
136 public
137 FeatureGroup()
138 {
139 super();
140 }
141
142 /**
143 * Attribute constructor.
144 *
145 * Looks up the attributes in the parameter and casts them from strings
146 * appropriately
147 * @param atts: the attribute list.
148 *
149 */
150 // TODO Work in progress (attribute constructor).
151 public
152 FeatureGroup(Attributes atts)
153 {
154 super(atts);
155
156 {
157 int nIndex = atts.getIndex("", "featureWidth");
158 if (nIndex != -1)
159 {
160 featureWidth = Float.parseFloat(atts.getValue(nIndex));
161 }
162 }
163
164 {
165 int nIndex = atts.getIndex("", "featureLength");
166 if (nIndex != -1)
167 {
168 featureLength = Float.parseFloat(atts.getValue(nIndex));
169 }
170 }
171
172 {
173 int nIndex = atts.getIndex("", "featureHeight");
174 if (nIndex != -1)
175 {
176 featureHeight = Float.parseFloat(atts.getValue(nIndex));
177 }
178 }
179
180 }
181
182 /**
183 * writeMAGEML
184 * <p>
185 * This method is responsible for assembling the attribute and
186 * association data into XML. It creates the object tag and then calls
187 * the writeAttributes and writeAssociation methods.
188 * <p>
189 *
190 */
191 public
192 void
193 writeMAGEML(Writer out)
194 throws IOException
195 {
196 out.write("<FeatureGroup");
197 writeAttributes(out);
198 out.write(">");
199 writeAssociations(out);
200 out.write("</FeatureGroup>");
201 }
202
203 /**
204 * writeAttributes
205 * <p>
206 * This method is responsible for assembling the attribute data into
207 * XML. It calls the super method to write out all attributes of this
208 * class and it's ancestors.
209 * <p>
210 *
211 */
212 public
213 void
214 writeAttributes(Writer out)
215 throws IOException
216 {
217 super.writeAttributes(out);
218 out.write(" featureWidth=\"" + featureWidth + "\"");
219 out.write(" featureLength=\"" + featureLength + "\"");
220 out.write(" featureHeight=\"" + featureHeight + "\"");
221 }
222
223 /**
224 * writeAssociations
225 * <p>
226 * This method is responsible for assembling the association data
227 * into XML. It calls the super method to write out all associations of
228 * this class's ancestors.
229 * <p>
230 *
231 */
232 public
233 void
234 writeAssociations(Writer out)
235 throws IOException
236 {
237 super.writeAssociations(out);
238 if ( technologyType != null ){
239 out.write("<TechnologyType_assn>");
240 technologyType.writeMAGEML(out);
241 out.write("</TechnologyType_assn>");
242 }
243 if ( featureShape != null ){
244 out.write("<FeatureShape_assn>");
245 featureShape.writeMAGEML(out);
246 out.write("</FeatureShape_assn>");
247 }
248 if ( distanceUnit != null ){
249 out.write("<DistanceUnit_assn>");
250 distanceUnit.writeMAGEML(out);
251 out.write("</DistanceUnit_assn>");
252 }
253 if ( features.size() > 0 ){
254 out.write("<Features_assnlist>");
255 for ( int i = 0; i < features.size(); i++) {
256 ((Feature)features.elementAt(i)).writeMAGEML(out);
257 }
258 out.write("</Features_assnlist>");
259 }
260 }
261
262 /**
263 * Set method for featureWidth
264 * <p>
265 * @param value to set
266 * <p>
267 *
268 */
269 public
270 void
271 setFeatureWidth(
272 float featureWidth
273 )
274 {
275 this.featureWidth = featureWidth;
276 }
277
278 /**
279 * Get method for featureWidth
280 * <p>
281 * @return value of the attribute
282 * <p>
283 *
284 */
285 public
286 float
287 getFeatureWidth()
288 {
289 return featureWidth;
290 }
291
292 /**
293 * Set method for featureLength
294 * <p>
295 * @param value to set
296 * <p>
297 *
298 */
299 public
300 void
301 setFeatureLength(
302 float featureLength
303 )
304 {
305 this.featureLength = featureLength;
306 }
307
308 /**
309 * Get method for featureLength
310 * <p>
311 * @return value of the attribute
312 * <p>
313 *
314 */
315 public
316 float
317 getFeatureLength()
318 {
319 return featureLength;
320 }
321
322 /**
323 * Set method for featureHeight
324 * <p>
325 * @param value to set
326 * <p>
327 *
328 */
329 public
330 void
331 setFeatureHeight(
332 float featureHeight
333 )
334 {
335 this.featureHeight = featureHeight;
336 }
337
338 /**
339 * Get method for featureHeight
340 * <p>
341 * @return value of the attribute
342 * <p>
343 *
344 */
345 public
346 float
347 getFeatureHeight()
348 {
349 return featureHeight;
350 }
351
352 /**
353 * Set method for distanceUnit
354 * <p>
355 * @param value to set
356 * <p>
357 *
358 */
359 public
360 void
361 setDistanceUnit(
362 DistanceUnit distanceUnit
363 )
364 {
365 this.distanceUnit = distanceUnit;
366 }
367
368 /**
369 * Get method for distanceUnit
370 * <p>
371 * @return value of the attribute
372 * <p>
373 *
374 */
375 public
376 DistanceUnit
377 getDistanceUnit()
378 {
379 return distanceUnit;
380 }
381
382 /**
383 * Set method for features
384 * <p>
385 * @param value to set
386 * <p>
387 *
388 */
389 public
390 void
391 setFeatures(
392 Features_list features
393 )
394 {
395 ((List)this.features).addAll((List)features);
396 }
397
398 /**
399 * Get method for features
400 * <p>
401 * @return value of the attribute
402 * <p>
403 *
404 */
405 public
406 Features_list
407 getFeatures()
408 {
409 return features;
410 }
411
412 /**
413 * Method to add Feature to Features_list
414 *
415 */
416 public
417 void
418 addToFeatures(
419 Feature feature
420 )
421 {
422 this.features.add(feature);
423 }
424
425 /**
426 * Method to add Feature at position to Features_list
427 *
428 */
429 public
430 void
431 addToFeatures(
432 int position,
433 Feature feature
434 )
435 {
436 this.features.add(position, feature);
437 }
438
439 /**
440 * Method to get Feature from Features_list
441 *
442 */
443 public
444 Feature
445 getFromFeatures(
446 int position
447 )
448 {
449 return (Feature) this.features.get(position);
450 }
451
452 /**
453 * Method to remove by position from Features_list
454 *
455 */
456 public
457 void
458 removeElementAtFromFeatures(
459 int position
460 )
461 {
462 this.features.removeElementAt(position);
463 }
464
465 /**
466 * Method to remove first Feature from Features_list
467 *
468 */
469 public
470 void
471 removeFromFeatures(
472 Feature feature
473 )
474 {
475 this.features.remove(feature);
476 }
477
478 /**
479 * Set method for technologyType
480 * <p>
481 * @param value to set
482 * <p>
483 *
484 */
485 public
486 void
487 setTechnologyType(
488 OntologyEntry technologyType
489 )
490 {
491 this.technologyType = technologyType;
492 }
493
494 /**
495 * Get method for technologyType
496 * <p>
497 * @return value of the attribute
498 * <p>
499 *
500 */
501 public
502 OntologyEntry
503 getTechnologyType()
504 {
505 return technologyType;
506 }
507
508 /**
509 * Set method for featureShape
510 * <p>
511 * @param value to set
512 * <p>
513 *
514 */
515 public
516 void
517 setFeatureShape(
518 OntologyEntry featureShape
519 )
520 {
521 this.featureShape = featureShape;
522 }
523
524 /**
525 * Get method for featureShape
526 * <p>
527 * @return value of the attribute
528 * <p>
529 *
530 */
531 public
532 OntologyEntry
533 getFeatureShape()
534 {
535 return featureShape;
536 }
537
538 }