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