Source code: org/biomage/DesignElement/MismatchInformation.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:45 AM *
43 * *
44 ***************************************************************************
45 */
46
47 /**
48 * org.biomage.DesignElement
49 *
50 */
51 package org.biomage.DesignElement;
52
53 /**
54 * Import list for MismatchInformation
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.Common.Extendable;
63
64 /**
65 * Describes how a reporter varies from its ReporterCharacteristics
66 * sequence(s) or how a Feature varies from its Reporter sequence.
67 *
68 */
69 public
70 class MismatchInformation
71 extends Extendable
72 implements Serializable
73 {
74 /**
75 * Offset into the sequence that the mismatch occurs.
76 *
77 */
78 int startCoord;
79
80 /**
81 * The sequence that replaces the specified sequence starting at
82 * start_coord.
83 *
84 */
85 String newSequence;
86
87 /**
88 * Length of the original sequence that is replaced. A deletion is
89 * specified when the length of the newSequence is less than the
90 * replacedLength.
91 *
92 */
93 int replacedLength;
94
95 /**
96 * Default constructor.
97 *
98 */
99 public
100 MismatchInformation()
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 MismatchInformation(Attributes atts)
116 {
117 super(atts);
118
119 {
120 int nIndex = atts.getIndex("", "startCoord");
121 if (nIndex != -1)
122 {
123 startCoord = Integer.parseInt(atts.getValue(nIndex));
124 }
125 }
126
127 {
128 int nIndex = atts.getIndex("", "newSequence");
129 if (nIndex != -1)
130 {
131 newSequence = atts.getValue(nIndex);
132 }
133 }
134
135 {
136 int nIndex = atts.getIndex("", "replacedLength");
137 if (nIndex != -1)
138 {
139 replacedLength = Integer.parseInt(atts.getValue(nIndex));
140 }
141 }
142
143 }
144
145 /**
146 * writeMAGEML
147 * <p>
148 * This method is responsible for assembling the attribute and
149 * association data into XML. It creates the object tag and then calls
150 * the writeAttributes and writeAssociation methods.
151 * <p>
152 *
153 */
154 public
155 void
156 writeMAGEML(Writer out)
157 throws IOException
158 {
159 out.write("<MismatchInformation");
160 writeAttributes(out);
161 out.write(">");
162 writeAssociations(out);
163 out.write("</MismatchInformation>");
164 }
165
166 /**
167 * writeAttributes
168 * <p>
169 * This method is responsible for assembling the attribute data into
170 * XML. It calls the super method to write out all attributes of this
171 * class and it's ancestors.
172 * <p>
173 *
174 */
175 public
176 void
177 writeAttributes(Writer out)
178 throws IOException
179 {
180 super.writeAttributes(out);
181 out.write(" startCoord=\"" + startCoord + "\"");
182 if ( newSequence != null ) {
183 out.write(" newSequence=\"" + newSequence + "\"");
184 }
185 out.write(" replacedLength=\"" + replacedLength + "\"");
186 }
187
188 /**
189 * writeAssociations
190 * <p>
191 * This method is responsible for assembling the association data
192 * into XML. It calls the super method to write out all associations of
193 * this class's ancestors.
194 * <p>
195 *
196 */
197 public
198 void
199 writeAssociations(Writer out)
200 throws IOException
201 {
202 super.writeAssociations(out);
203 }
204
205 /**
206 * Set method for startCoord
207 * <p>
208 * @param value to set
209 * <p>
210 *
211 */
212 public
213 void
214 setStartCoord(
215 int startCoord
216 )
217 {
218 this.startCoord = startCoord;
219 }
220
221 /**
222 * Get method for startCoord
223 * <p>
224 * @return value of the attribute
225 * <p>
226 *
227 */
228 public
229 int
230 getStartCoord()
231 {
232 return startCoord;
233 }
234
235 /**
236 * Set method for newSequence
237 * <p>
238 * @param value to set
239 * <p>
240 *
241 */
242 public
243 void
244 setNewSequence(
245 String newSequence
246 )
247 {
248 this.newSequence = newSequence;
249 }
250
251 /**
252 * Get method for newSequence
253 * <p>
254 * @return value of the attribute
255 * <p>
256 *
257 */
258 public
259 String
260 getNewSequence()
261 {
262 return newSequence;
263 }
264
265 /**
266 * Set method for replacedLength
267 * <p>
268 * @param value to set
269 * <p>
270 *
271 */
272 public
273 void
274 setReplacedLength(
275 int replacedLength
276 )
277 {
278 this.replacedLength = replacedLength;
279 }
280
281 /**
282 * Get method for replacedLength
283 * <p>
284 * @return value of the attribute
285 * <p>
286 *
287 */
288 public
289 int
290 getReplacedLength()
291 {
292 return replacedLength;
293 }
294
295 }