Source code: org/biomage/BioSequence/SequencePosition.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:36 AM *
43 * *
44 ***************************************************************************
45 */
46
47 /**
48 * org.biomage.BioSequence
49 *
50 */
51 package org.biomage.BioSequence;
52
53 /**
54 * Import list for SequencePosition
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 * Designates the position of the Feature in its BioSequence.
66 *
67 */
68 public
69 class SequencePosition
70 extends Extendable
71 implements Serializable
72 {
73 /**
74 * The location of the base, for nucleotides, that the SeqFeature
75 * starts.
76 *
77 */
78 int start;
79
80 /**
81 * The location of the base, for nucleotides, that the SeqFeature
82 * ends.
83 *
84 */
85 int end;
86
87 /**
88 * Default constructor.
89 *
90 */
91 public
92 SequencePosition()
93 {
94 super();
95 }
96
97 /**
98 * Attribute constructor.
99 *
100 * Looks up the attributes in the parameter and casts them from strings
101 * appropriately
102 * @param atts: the attribute list.
103 *
104 */
105 // TODO Work in progress (attribute constructor).
106 public
107 SequencePosition(Attributes atts)
108 {
109 super(atts);
110
111 {
112 int nIndex = atts.getIndex("", "start");
113 if (nIndex != -1)
114 {
115 start = Integer.parseInt(atts.getValue(nIndex));
116 }
117 }
118
119 {
120 int nIndex = atts.getIndex("", "end");
121 if (nIndex != -1)
122 {
123 end = Integer.parseInt(atts.getValue(nIndex));
124 }
125 }
126
127 }
128
129 /**
130 * writeMAGEML
131 * <p>
132 * This method is responsible for assembling the attribute and
133 * association data into XML. It creates the object tag and then calls
134 * the writeAttributes and writeAssociation methods.
135 * <p>
136 *
137 */
138 public
139 void
140 writeMAGEML(Writer out)
141 throws IOException
142 {
143 out.write("<SequencePosition");
144 writeAttributes(out);
145 out.write(">");
146 writeAssociations(out);
147 out.write("</SequencePosition>");
148 }
149
150 /**
151 * writeAttributes
152 * <p>
153 * This method is responsible for assembling the attribute data into
154 * XML. It calls the super method to write out all attributes of this
155 * class and it's ancestors.
156 * <p>
157 *
158 */
159 public
160 void
161 writeAttributes(Writer out)
162 throws IOException
163 {
164 super.writeAttributes(out);
165 out.write(" start=\"" + start + "\"");
166 out.write(" end=\"" + end + "\"");
167 }
168
169 /**
170 * writeAssociations
171 * <p>
172 * This method is responsible for assembling the association data
173 * into XML. It calls the super method to write out all associations of
174 * this class's ancestors.
175 * <p>
176 *
177 */
178 public
179 void
180 writeAssociations(Writer out)
181 throws IOException
182 {
183 super.writeAssociations(out);
184 }
185
186 /**
187 * Set method for start
188 * <p>
189 * @param value to set
190 * <p>
191 *
192 */
193 public
194 void
195 setStart(
196 int start
197 )
198 {
199 this.start = start;
200 }
201
202 /**
203 * Get method for start
204 * <p>
205 * @return value of the attribute
206 * <p>
207 *
208 */
209 public
210 int
211 getStart()
212 {
213 return start;
214 }
215
216 /**
217 * Set method for end
218 * <p>
219 * @param value to set
220 * <p>
221 *
222 */
223 public
224 void
225 setEnd(
226 int end
227 )
228 {
229 this.end = end;
230 }
231
232 /**
233 * Get method for end
234 * <p>
235 * @return value of the attribute
236 * <p>
237 *
238 */
239 public
240 int
241 getEnd()
242 {
243 return end;
244 }
245
246 }