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

Quick Search    Search Deep

Source code: org/biomage/DesignElement/CompositePosition.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:44 AM                                  *
43   *                                                                         *
44   ***************************************************************************
45   */
46  
47  /**
48   *  org.biomage.DesignElement
49   *  
50   */
51  package org.biomage.DesignElement;
52  
53  /**
54   *  Import list for CompositePosition
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.HasComposite;
63  import org.biomage.Interface.HasMismatchInformation;
64  import org.biomage.BioSequence.SequencePosition;
65  
66  /**
67   *  The location in the compositeSequence target's sequence to which a 
68   *  source compositeSequence maps.  The association to MismatchInformation 
69   *  allows the specification, usually for control purposes, of deviations 
70   *  from the CompositeSequence's BioMaterial.
71   *  
72   */
73  public
74  class CompositePosition
75      extends SequencePosition
76      implements Serializable,
77          HasComposite,
78          HasMismatchInformation
79  {
80      /**
81       *  A source CompositeSequence that is part of a target 
82       *  CompositeSequence
83       *  
84       */
85      private CompositeSequence composite;
86  
87  
88      /**
89       *  Differences in how the contained compositeSequence matches its 
90       *  target compositeSequence's sequence.
91       *  
92       */
93      private MismatchInformation_list mismatchInformation = new MismatchInformation_list();
94  
95      /**
96       *  Default constructor.
97       *  
98       */
99      public
100     CompositePosition()
101     {
102         super();
103     }
104 
105     /**
106      *  Attribute constructor.
107      *  
108      *  Looks up the attributes in the parameter and casts them from strings 
109      *  appropriately
110      *  @param atts: the attribute list.
111      *  
112      */
113     // TODO Work in progress (attribute constructor).
114     public
115     CompositePosition(Attributes atts)
116     {
117         super(atts);
118 
119     }
120 
121     /**
122      *  writeMAGEML
123      *  <p>
124      *  This method is responsible for assembling the attribute and 
125      *  association data into XML. It creates the object tag and then calls 
126      *  the writeAttributes and writeAssociation methods.
127      *  <p>
128      *  
129      */
130     public
131     void
132     writeMAGEML(Writer out)
133     throws IOException
134     {
135         out.write("<CompositePosition");
136         writeAttributes(out);
137         out.write(">");
138         writeAssociations(out);
139         out.write("</CompositePosition>");
140     }
141 
142     /**
143      *  writeAttributes
144      *  <p>
145      *  This method is responsible for assembling the attribute data into 
146      *  XML. It calls the super method to write out all attributes of this 
147      *  class and it's ancestors.
148      *  <p>
149      *  
150      */
151     public
152     void
153     writeAttributes(Writer out)
154     throws IOException
155     {
156         super.writeAttributes(out);
157     }
158 
159     /**
160      *  writeAssociations
161      *  <p>
162      *  This method is responsible for assembling the association data 
163      *  into XML. It calls the super method to write out all associations of 
164      *  this class's ancestors.
165      *  <p>
166      *  
167      */
168     public
169     void
170     writeAssociations(Writer out)
171     throws IOException
172     {
173         super.writeAssociations(out);
174         if ( composite != null ){
175             out.write("<Composite_assnref>");
176             out.write("<CompositeSequence_ref identifier=\"" + composite.getIdentifier() + "\"/>");
177             out.write("</Composite_assnref>");
178         }
179         if ( mismatchInformation.size() > 0 ){
180             out.write("<MismatchInformation_assnlist>");
181             for ( int i = 0; i < mismatchInformation.size(); i++) {
182                 ((MismatchInformation)mismatchInformation.elementAt(i)).writeMAGEML(out);
183             }
184             out.write("</MismatchInformation_assnlist>");
185         }
186     }
187 
188     /**
189      *  Set method for composite
190      *  <p>
191      *  @param value to set
192      *  <p>
193      *  
194      */
195     public
196     void
197     setComposite(
198         CompositeSequence composite
199     )
200     {
201         this.composite = composite;
202     }
203 
204     /**
205      *  Get method for composite
206      *  <p>
207      *  @return value of the attribute
208      *  <p>
209      *  
210      */
211     public
212     CompositeSequence
213     getComposite()
214     {
215         return composite;
216     }
217 
218     /**
219      *  Set method for mismatchInformation
220      *  <p>
221      *  @param value to set
222      *  <p>
223      *  
224      */
225     public
226     void
227     setMismatchInformation(
228         MismatchInformation_list mismatchInformation
229     )
230     {
231         ((List)this.mismatchInformation).addAll((List)mismatchInformation);
232     }
233 
234     /**
235      *  Get method for mismatchInformation
236      *  <p>
237      *  @return value of the attribute
238      *  <p>
239      *  
240      */
241     public
242     MismatchInformation_list
243     getMismatchInformation()
244     {
245         return mismatchInformation;
246     }
247 
248     /**
249      *  Method to add MismatchInformation to MismatchInformation_list
250      *  
251      */
252     public
253     void
254     addToMismatchInformation(
255         MismatchInformation mismatchInformation
256     )
257     {
258         this.mismatchInformation.add(mismatchInformation);
259     }
260 
261     /**
262      *  Method to add MismatchInformation at position to 
263      *  MismatchInformation_list
264      *  
265      */
266     public
267     void
268     addToMismatchInformation(
269         int position,
270         MismatchInformation mismatchInformation
271     )
272     {
273         this.mismatchInformation.add(position, mismatchInformation);
274     }
275 
276     /**
277      *  Method to get MismatchInformation from MismatchInformation_list
278      *  
279      */
280     public
281     MismatchInformation
282     getFromMismatchInformation(
283         int position
284     )
285     {
286         return (MismatchInformation) this.mismatchInformation.get(position);
287     }
288 
289     /**
290      *  Method to remove by position from MismatchInformation_list
291      *  
292      */
293     public
294     void
295     removeElementAtFromMismatchInformation(
296         int position
297     )
298     {
299         this.mismatchInformation.removeElementAt(position);
300     }
301 
302     /**
303      *  Method to remove first MismatchInformation from 
304      *  MismatchInformation_list
305      *  
306      */
307     public
308     void
309     removeFromMismatchInformation(
310         MismatchInformation mismatchInformation
311     )
312     {
313         this.mismatchInformation.remove(mismatchInformation);
314     }
315 
316 }