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