Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/biomage/Array/ArrayGroup.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:05 AM                                  *
43   *                                                                         *
44   ***************************************************************************
45   */
46  
47  /**
48   *  org.biomage.Array
49   *  
50   */
51  package org.biomage.Array;
52  
53  /**
54   *  Import list for ArrayGroup
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.HasArrays;
63  import org.biomage.Interface.HasFiducials;
64  import org.biomage.Interface.HasDistanceUnit;
65  import org.biomage.Interface.HasSubstrateType;
66  import org.biomage.Common.Identifiable;
67  import org.biomage.Description.OntologyEntry;
68  import org.biomage.Measurement.DistanceUnit;
69  
70  /**
71   *  An array package is a physical platform that contains one or more 
72   *  arrays that are separately addressable (e.g. several arrays that can be 
73   *  hybridized on a single microscope slide) or a virtual grouping together 
74   *  of arrays.
75   *  
76   *  The array package that has been manufactured has information about where 
77   *  certain artifacts about the array are located for scanning and feature 
78   *  extraction purposes.
79   *  
80   */
81  public
82  class ArrayGroup
83      extends Identifiable
84      implements Serializable,
85          HasArrays,
86          HasFiducials,
87          HasDistanceUnit,
88          HasSubstrateType
89  {
90      /**
91       *  Identifier for the ArrayGroup.
92       *  
93       */
94       String barcode;
95  
96      /**
97       *  If there exist more than one array on a slide or a chip, then the 
98       *  spacing between the arrays is useful so that scanning / feature 
99       *  extraction software can crop images representing 1 unique bioassay.
100      *  
101      */
102      float arraySpacingX;
103 
104     /**
105      *  If there exist more than one array on a slide or a chip, then the 
106      *  spacing between the arrays is useful so that scanning / feature 
107      *  extraction software can crop images representing 1 unique bioassay.
108      *  
109      */
110      float arraySpacingY;
111 
112     /**
113      *  This attribute defines the number of arrays on a chip or a slide.
114      *  
115      */
116      int numArrays;
117 
118     /**
119      *  For a human to determine where the top left side of the array is, 
120      *  such as a barcode or frosted side of the glass, etc.
121      *  
122      */
123      String orientationMark;
124 
125     /**
126      *  Inner class for the enumeration values that the attribute 
127      *  orientationMarkPosition can assume.
128      *  
129      */
130     public
131     class
132     OrientationMarkPosition
133     {
134         int value = -1;
135         private HashMap nameToValue = new HashMap(4);
136 
137         final public int TOP = 0;
138         final public int BOTTOM = 1;
139         final public int LEFT = 2;
140         final public int RIGHT = 3;
141 
142         OrientationMarkPosition(){
143             nameToValue.put("TOP",new Integer(0));
144             nameToValue.put("BOTTOM",new Integer(1));
145             nameToValue.put("LEFT",new Integer(2));
146             nameToValue.put("RIGHT",new Integer(3));
147         }
148 
149         public int setValueByName(String name) {
150                 value = ((Integer)nameToValue.get(name)).intValue();
151                 return value;
152         }
153     }
154 
155     /**
156      *  One of top, bottom, left or right.
157      *  
158      */
159      OrientationMarkPosition orientationMarkPosition = new OrientationMarkPosition();
160 
161     /**
162      *  The width of the platform
163      *  
164      */
165      float width;
166 
167     /**
168      *  The length of the platform.
169      *  
170      */
171      float length;
172 
173     /**
174      *  Association between an ArrayGroup and its Arrays, typically the 
175      *  ArrayGroup will represent a slide and the Arrays will be the 
176      *  manufactured so that they may be hybridized separately on that 
177      *  slide.
178      *  
179      */
180     private Arrays_list arrays = new Arrays_list();
181 
182     /**
183      *  Association to the marks on the Array for alignment for the 
184      *  scanner.
185      *  
186      */
187     private Fiducials_list fiducials = new Fiducials_list();
188 
189     /**
190      *  The unit of the measurement attributes.
191      *  
192      */
193     private DistanceUnit distanceUnit;
194 
195 
196     /**
197      *  Commonly, arrays will be spotted on 1x3 glass microscope slides 
198      *  but there is nothing that says this must be the case.  This 
199      *  association is for scanners to inform them on the possible different 
200      *  formats of slides that can contain arrays.
201      *  
202      */
203     private OntologyEntry substrateType;
204 
205 
206     /**
207      *  Default constructor.
208      *  
209      */
210     public
211     ArrayGroup()
212     {
213         super();
214     }
215 
216     /**
217      *  Attribute constructor.
218      *  
219      *  Looks up the attributes in the parameter and casts them from strings 
220      *  appropriately
221      *  @param atts: the attribute list.
222      *  
223      */
224     // TODO Work in progress (attribute constructor).
225     public
226     ArrayGroup(Attributes atts)
227     {
228         super(atts);
229 
230         {
231             int nIndex = atts.getIndex("", "barcode");
232             if (nIndex != -1)
233             {
234                 barcode = atts.getValue(nIndex);
235             }
236         }
237 
238         {
239             int nIndex = atts.getIndex("", "arraySpacingX");
240             if (nIndex != -1)
241             {
242                 arraySpacingX = Float.parseFloat(atts.getValue(nIndex));
243             }
244         }
245 
246         {
247             int nIndex = atts.getIndex("", "arraySpacingY");
248             if (nIndex != -1)
249             {
250                 arraySpacingY = Float.parseFloat(atts.getValue(nIndex));
251             }
252         }
253 
254         {
255             int nIndex = atts.getIndex("", "numArrays");
256             if (nIndex != -1)
257             {
258                 numArrays = Integer.parseInt(atts.getValue(nIndex));
259             }
260         }
261 
262         {
263             int nIndex = atts.getIndex("", "orientationMark");
264             if (nIndex != -1)
265             {
266                 orientationMark = atts.getValue(nIndex);
267             }
268         }
269 
270         {
271             int nIndex = atts.getIndex("", "orientationMarkPosition");
272             if (nIndex != -1)
273             {
274                 orientationMarkPosition.setValueByName(atts.getValue(nIndex).toUpperCase());
275             }
276         }
277 
278         {
279             int nIndex = atts.getIndex("", "width");
280             if (nIndex != -1)
281             {
282                 width = Float.parseFloat(atts.getValue(nIndex));
283             }
284         }
285 
286         {
287             int nIndex = atts.getIndex("", "length");
288             if (nIndex != -1)
289             {
290                 length = Float.parseFloat(atts.getValue(nIndex));
291             }
292         }
293 
294     }
295 
296     /**
297      *  writeMAGEML
298      *  <p>
299      *  This method is responsible for assembling the attribute and 
300      *  association data into XML. It creates the object tag and then calls 
301      *  the writeAttributes and writeAssociation methods.
302      *  <p>
303      *  
304      */
305     public
306     void
307     writeMAGEML(Writer out)
308     throws IOException
309     {
310         out.write("<ArrayGroup");
311         writeAttributes(out);
312         out.write(">");
313         writeAssociations(out);
314         out.write("</ArrayGroup>");
315     }
316 
317     /**
318      *  writeAttributes
319      *  <p>
320      *  This method is responsible for assembling the attribute data into 
321      *  XML. It calls the super method to write out all attributes of this 
322      *  class and it's ancestors.
323      *  <p>
324      *  
325      */
326     public
327     void
328     writeAttributes(Writer out)
329     throws IOException
330     {
331         super.writeAttributes(out);
332         if ( barcode != null ) {
333             out.write(" barcode=\"" + barcode + "\"");
334         }
335         out.write(" arraySpacingX=\"" + arraySpacingX + "\"");
336         out.write(" arraySpacingY=\"" + arraySpacingY + "\"");
337         out.write(" numArrays=\"" + numArrays + "\"");
338         if ( orientationMark != null ) {
339             out.write(" orientationMark=\"" + orientationMark + "\"");
340         }
341         out.write(" orientationMarkPosition=\"" + orientationMarkPosition + "\"");
342         out.write(" width=\"" + width + "\"");
343         out.write(" length=\"" + length + "\"");
344     }
345 
346     /**
347      *  writeAssociations
348      *  <p>
349      *  This method is responsible for assembling the association data 
350      *  into XML. It calls the super method to write out all associations of 
351      *  this class's ancestors.
352      *  <p>
353      *  
354      */
355     public
356     void
357     writeAssociations(Writer out)
358     throws IOException
359     {
360         super.writeAssociations(out);
361         if ( fiducials.size() > 0 ){
362             out.write("<Fiducials_assnlist>");
363             for ( int i = 0; i < fiducials.size(); i++) {
364                 ((Fiducial)fiducials.elementAt(i)).writeMAGEML(out);
365             }
366             out.write("</Fiducials_assnlist>");
367         }
368         if ( arrays.size() > 0 ){
369             out.write("<Arrays_assnreflist>");
370             for ( int i = 0; i < arrays.size(); i++) {
371                 out.write("<Array_ref identifier=\"" + ((Array)arrays.elementAt(i)).getIdentifier() + "\"/>");
372             }
373             out.write("</Arrays_assnreflist>");
374         }
375         if ( substrateType != null ){
376             out.write("<SubstrateType_assn>");
377             substrateType.writeMAGEML(out);
378             out.write("</SubstrateType_assn>");
379         }
380         if ( distanceUnit != null ){
381             out.write("<DistanceUnit_assn>");
382             distanceUnit.writeMAGEML(out);
383             out.write("</DistanceUnit_assn>");
384         }
385     }
386 
387     /**
388      *  Set method for barcode
389      *  <p>
390      *  @param value to set
391      *  <p>
392      *  
393      */
394     public
395     void
396     setBarcode(
397         String barcode
398     )
399     {
400         this.barcode = barcode;
401     }
402 
403     /**
404      *  Get method for barcode
405      *  <p>
406      *  @return value of the attribute
407      *  <p>
408      *  
409      */
410     public
411     String
412     getBarcode()
413     {
414         return barcode;
415     }
416 
417     /**
418      *  Set method for arraySpacingX
419      *  <p>
420      *  @param value to set
421      *  <p>
422      *  
423      */
424     public
425     void
426     setArraySpacingX(
427         float arraySpacingX
428     )
429     {
430         this.arraySpacingX = arraySpacingX;
431     }
432 
433     /**
434      *  Get method for arraySpacingX
435      *  <p>
436      *  @return value of the attribute
437      *  <p>
438      *  
439      */
440     public
441     float
442     getArraySpacingX()
443     {
444         return arraySpacingX;
445     }
446 
447     /**
448      *  Set method for arraySpacingY
449      *  <p>
450      *  @param value to set
451      *  <p>
452      *  
453      */
454     public
455     void
456     setArraySpacingY(
457         float arraySpacingY
458     )
459     {
460         this.arraySpacingY = arraySpacingY;
461     }
462 
463     /**
464      *  Get method for arraySpacingY
465      *  <p>
466      *  @return value of the attribute
467      *  <p>
468      *  
469      */
470     public
471     float
472     getArraySpacingY()
473     {
474         return arraySpacingY;
475     }
476 
477     /**
478      *  Set method for numArrays
479      *  <p>
480      *  @param value to set
481      *  <p>
482      *  
483      */
484     public
485     void
486     setNumArrays(
487         int numArrays
488     )
489     {
490         this.numArrays = numArrays;
491     }
492 
493     /**
494      *  Get method for numArrays
495      *  <p>
496      *  @return value of the attribute
497      *  <p>
498      *  
499      */
500     public
501     int
502     getNumArrays()
503     {
504         return numArrays;
505     }
506 
507     /**
508      *  Set method for orientationMark
509      *  <p>
510      *  @param value to set
511      *  <p>
512      *  
513      */
514     public
515     void
516     setOrientationMark(
517         String orientationMark
518     )
519     {
520         this.orientationMark = orientationMark;
521     }
522 
523     /**
524      *  Get method for orientationMark
525      *  <p>
526      *  @return value of the attribute
527      *  <p>
528      *  
529      */
530     public
531     String
532     getOrientationMark()
533     {
534         return orientationMark;
535     }
536 
537     /**
538      *  Set method for orientationMarkPosition
539      *  <p>
540      *  @param value to set
541      *  <p>
542      *  
543      */
544     public
545     void
546     setOrientationMarkPosition(
547         OrientationMarkPosition orientationMarkPosition
548     )
549     {
550         this.orientationMarkPosition = orientationMarkPosition;
551     }
552 
553     /**
554      *  Get method for orientationMarkPosition
555      *  <p>
556      *  @return value of the attribute
557      *  <p>
558      *  
559      */
560     public
561     OrientationMarkPosition
562     getOrientationMarkPosition()
563     {
564         return orientationMarkPosition;
565     }
566 
567     /**
568      *  Set method for width
569      *  <p>
570      *  @param value to set
571      *  <p>
572      *  
573      */
574     public
575     void
576     setWidth(
577         float width
578     )
579     {
580         this.width = width;
581     }
582 
583     /**
584      *  Get method for width
585      *  <p>
586      *  @return value of the attribute
587      *  <p>
588      *  
589      */
590     public
591     float
592     getWidth()
593     {
594         return width;
595     }
596 
597     /**
598      *  Set method for length
599      *  <p>
600      *  @param value to set
601      *  <p>
602      *  
603      */
604     public
605     void
606     setLength(
607         float length
608     )
609     {
610         this.length = length;
611     }
612 
613     /**
614      *  Get method for length
615      *  <p>
616      *  @return value of the attribute
617      *  <p>
618      *  
619      */
620     public
621     float
622     getLength()
623     {
624         return length;
625     }
626 
627     /**
628      *  Set method for arrays
629      *  <p>
630      *  @param value to set
631      *  <p>
632      *  
633      */
634     public
635     void
636     setArrays(
637         Arrays_list arrays
638     )
639     {
640         ((List)this.arrays).addAll((List)arrays);
641     }
642 
643     /**
644      *  Get method for arrays
645      *  <p>
646      *  @return value of the attribute
647      *  <p>
648      *  
649      */
650     public
651     Arrays_list
652     getArrays()
653     {
654         return arrays;
655     }
656 
657     /**
658      *  Method to add Array to Arrays_list
659      *  
660      */
661     public
662     void
663     addToArrays(
664         Array array
665     )
666     {
667         this.arrays.add(array);
668     }
669 
670     /**
671      *  Method to add Array at position to Arrays_list
672      *  
673      */
674     public
675     void
676     addToArrays(
677         int position,
678         Array array
679     )
680     {
681         this.arrays.add(position, array);
682     }
683 
684     /**
685      *  Method to get Array from Arrays_list
686      *  
687      */
688     public
689     Array
690     getFromArrays(
691         int position
692     )
693     {
694         return (Array) this.arrays.get(position);
695     }
696 
697     /**
698      *  Method to remove by position from Arrays_list
699      *  
700      */
701     public
702     void
703     removeElementAtFromArrays(
704         int position
705     )
706     {
707         this.arrays.removeElementAt(position);
708     }
709 
710     /**
711      *  Method to remove first Array from Arrays_list
712      *  
713      */
714     public
715     void
716     removeFromArrays(
717         Array array
718     )
719     {
720         this.arrays.remove(array);
721     }
722 
723     /**
724      *  Set method for fiducials
725      *  <p>
726      *  @param value to set
727      *  <p>
728      *  
729      */
730     public
731     void
732     setFiducials(
733         Fiducials_list fiducials
734     )
735     {
736         ((List)this.fiducials).addAll((List)fiducials);
737     }
738 
739     /**
740      *  Get method for fiducials
741      *  <p>
742      *  @return value of the attribute
743      *  <p>
744      *  
745      */
746     public
747     Fiducials_list
748     getFiducials()
749     {
750         return fiducials;
751     }
752 
753     /**
754      *  Method to add Fiducial to Fiducials_list
755      *  
756      */
757     public
758     void
759     addToFiducials(
760         Fiducial fiducial
761     )
762     {
763         this.fiducials.add(fiducial);
764     }
765 
766     /**
767      *  Method to add Fiducial at position to Fiducials_list
768      *  
769      */
770     public
771     void
772     addToFiducials(
773         int position,
774         Fiducial fiducial
775     )
776     {
777         this.fiducials.add(position, fiducial);
778     }
779 
780     /**
781      *  Method to get Fiducial from Fiducials_list
782      *  
783      */
784     public
785     Fiducial
786     getFromFiducials(
787         int position
788     )
789     {
790         return (Fiducial) this.fiducials.get(position);
791     }
792 
793     /**
794      *  Method to remove by position from Fiducials_list
795      *  
796      */
797     public
798     void
799     removeElementAtFromFiducials(
800         int position
801     )
802     {
803         this.fiducials.removeElementAt(position);
804     }
805 
806     /**
807      *  Method to remove first Fiducial from Fiducials_list
808      *  
809      */
810     public
811     void
812     removeFromFiducials(
813         Fiducial fiducial
814     )
815     {
816         this.fiducials.remove(fiducial);
817     }
818 
819     /**
820      *  Set method for distanceUnit
821      *  <p>
822      *  @param value to set
823      *  <p>
824      *  
825      */
826     public
827     void
828     setDistanceUnit(
829         DistanceUnit distanceUnit
830     )
831     {
832         this.distanceUnit = distanceUnit;
833     }
834 
835     /**
836      *  Get method for distanceUnit
837      *  <p>
838      *  @return value of the attribute
839      *  <p>
840      *  
841      */
842     public
843     DistanceUnit
844     getDistanceUnit()
845     {
846         return distanceUnit;
847     }
848 
849     /**
850      *  Set method for substrateType
851      *  <p>
852      *  @param value to set
853      *  <p>
854      *  
855      */
856     public
857     void
858     setSubstrateType(
859         OntologyEntry substrateType
860     )
861     {
862         this.substrateType = substrateType;
863     }
864 
865     /**
866      *  Get method for substrateType
867      *  <p>
868      *  @return value of the attribute
869      *  <p>
870      *  
871      */
872     public
873     OntologyEntry
874     getSubstrateType()
875     {
876         return substrateType;
877     }
878 
879 }