separate Amplification and AmplificationResult.java #4541
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / molecular / Amplification.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.cdm.model.molecular;
10
11 import javax.persistence.Entity;
12 import javax.persistence.FetchType;
13 import javax.persistence.JoinColumn;
14 import javax.persistence.ManyToOne;
15 import javax.validation.constraints.Size;
16 import javax.xml.bind.annotation.XmlAccessType;
17 import javax.xml.bind.annotation.XmlAccessorType;
18 import javax.xml.bind.annotation.XmlElement;
19 import javax.xml.bind.annotation.XmlIDREF;
20 import javax.xml.bind.annotation.XmlRootElement;
21 import javax.xml.bind.annotation.XmlSchemaType;
22 import javax.xml.bind.annotation.XmlType;
23
24 import org.apache.log4j.Logger;
25 import org.hibernate.annotations.Cascade;
26 import org.hibernate.annotations.CascadeType;
27 import org.hibernate.envers.Audited;
28 import org.hibernate.search.annotations.Analyze;
29 import org.hibernate.search.annotations.Field;
30 import org.hibernate.search.annotations.IndexedEmbedded;
31 import org.hibernate.search.annotations.NumericField;
32
33 import eu.etaxonomy.cdm.model.agent.Institution;
34 import eu.etaxonomy.cdm.model.common.DefinedTerm;
35 import eu.etaxonomy.cdm.model.common.EventBase;
36 import eu.etaxonomy.cdm.model.common.TermType;
37 import eu.etaxonomy.cdm.model.occurrence.MaterialOrMethodEvent;
38
39 /**
40 * The physical process of amplification (also called PCR) extracts and replicates parts of the DNA of
41 * a given {@link #getDnaSample() DNA Sample} . The part of the DNA being replicated is defined by the
42 * {@link #getDnaMarker() marker} (also called locus) - implemented in CDM as a {@link DefinedTerm}
43 * of term type {@link TermType#DnaMarker}.
44 * <BR>To execute the replication {@link Primer primers} (short DNA fractions) are
45 * used. They may work in both directions of the DNA part therefore we do have a
46 * {@link #getForwardPrimer() forward primer} and a {@link #getReversePrimer() reverse primer}.
47 * Most (or all?) amplifications require a {@link #getPurification() purification process}. Additionally
48 * some use {@link #getCloning()} for replication.
49 * <H3>Quality control</H3>
50 * <BR>For quality control the resulting product (PCR) is tested using a chromatographic method called
51 * electrophoresis. The parameters (voltage, ladder used, running time, and gel concentration) used
52 * for this electrophoresis as well as the resulting
53 * {@link #getGelPhoto() photo} can also be stored in the amplification instance.
54 * <BR>The resulting PCR will later be used in a {@link SingleRead DNA sequence reading process}.
55 * The PCR itself is not persistent and therefore will not be stored in the CDM.
56 * This may change in future: http://dev.e-taxonomy.eu/trac/ticket/3717.
57 * <BR>
58 *
59 * @author a.mueller
60 * @created 2013-07-05
61 *
62 */
63 @XmlAccessorType(XmlAccessType.FIELD)
64 @XmlType(name = "Amplification", propOrder = {
65 "dnaMarker",
66 "forwardPrimer",
67 "reversePrimer",
68 "purification",
69 "institution",
70 "ladderUsed",
71 "electrophoresisVoltage",
72 "gelRunningTime",
73 "gelConcentration",
74 })
75 @XmlRootElement(name = "Amplification")
76 @Entity
77 @Audited
78 public class Amplification extends EventBase implements Cloneable{
79 private static final long serialVersionUID = -6382383300974316261L;
80
81 private static final Logger logger = Logger.getLogger(Amplification.class);
82
83 /** @see #getDnaMarker()*/
84 @XmlElement(name = "DnaMarker")
85 @XmlIDREF
86 @XmlSchemaType(name = "IDREF")
87 //TODO why is this eager?
88 @ManyToOne(fetch=FetchType.EAGER)
89 private DefinedTerm dnaMarker;
90
91 /** @see #getForwardPrimer() */
92 @XmlElement(name = "ForwardPrimer")
93 @XmlIDREF
94 @XmlSchemaType(name = "IDREF")
95 @ManyToOne(fetch=FetchType.LAZY)
96 @Cascade({CascadeType.SAVE_UPDATE})
97 private Primer forwardPrimer;
98
99 /** @see #getReversePrimer()*/
100 @XmlElement(name = "ReversePrimer")
101 @XmlIDREF
102 @XmlSchemaType(name = "IDREF")
103 @ManyToOne(fetch=FetchType.LAZY)
104 @Cascade({CascadeType.SAVE_UPDATE})
105 private Primer reversePrimer;
106
107
108 @XmlElement(name = "Purification")
109 @XmlIDREF
110 @XmlSchemaType(name = "IDREF")
111 @ManyToOne(fetch=FetchType.LAZY)
112 @Cascade({CascadeType.SAVE_UPDATE})
113 private MaterialOrMethodEvent purification;
114
115 @XmlElement(name = "Institution")
116 @XmlIDREF
117 @XmlSchemaType(name = "IDREF")
118 @ManyToOne(fetch = FetchType.LAZY)
119 @IndexedEmbedded
120 @Cascade(CascadeType.SAVE_UPDATE)
121 @JoinColumn(name="institution_id")
122 private Institution institution;
123
124 /** @see #getLadderUsed() */
125 @XmlElement(name = "ladderUsed")
126 @Field
127 @Size(max=255)
128 private String ladderUsed;
129
130 /** @see #getElectrophoresisVoltage()*/
131 @XmlElement(name = "electrophoresisVoltage")
132 @Field(analyze = Analyze.NO)
133 @NumericField
134 private Double electrophoresisVoltage;
135
136 /** @see #getGelRunningTime() */
137 @XmlElement(name = "gelRunningTime")
138 @Field(analyze = Analyze.NO)
139 @NumericField
140 private Double gelRunningTime;
141
142 /** @see #getGelConcentration() */
143 @XmlElement(name = "gelConcentration")
144 @Field(analyze = Analyze.NO)
145 @NumericField
146 private Double gelConcentration;
147
148
149 // ********************* FACTORY METHODS ************************/
150
151 public static Amplification NewInstance(){
152 return new Amplification();
153 }
154
155
156 // ******************* CONSTRUCTOR *******************************/
157
158 protected Amplification(){}
159
160
161 //********************* GETTER / SETTER ************/
162
163
164 /**
165 * The {@link TermType#DnaMarker DNA marker} used for this amplification.
166 * The DNA marker also defines the part (locality) of the DNA/RNA examined.
167 * It may also be called <i>locus</i>
168 */
169 public DefinedTerm getDnaMarker() {
170 return dnaMarker;
171 }
172 /** @see #getDnaMarker()*/
173 public void setDnaMarker(DefinedTerm marker) {
174 this.dnaMarker = marker;
175 }
176
177 /**
178 * The primer used for forward amplification.
179 * @see #getReversePrimer()
180 */
181 public Primer getForwardPrimer() {
182 return forwardPrimer;
183 }
184 /**
185 * @see #getForwardPrimer()
186 * @see #getReversePrimer()
187 */
188 public void setForwardPrimer(Primer forwardPrimer) {
189 this.forwardPrimer = forwardPrimer;
190 }
191
192 /**
193 * The primer used for reverse amplification.
194 * @see #getForwardPrimer()
195 */
196 public Primer getReversePrimer() {
197 return reversePrimer;
198 }
199 /**
200 * @see #getReversePrimer()
201 * @see #getForwardPrimer()
202 */
203 public void setReversePrimer(Primer reversePrimer) {
204 this.reversePrimer = reversePrimer;
205 }
206
207
208 /**
209 * The material and/or method used for purification.
210 */
211 public MaterialOrMethodEvent getPurification() {
212 return purification;
213 }
214 /**
215 * @see #getPurification()
216 */
217 public void setPurification(MaterialOrMethodEvent purification) {
218 this.purification = purification;
219 }
220
221 /**
222 * The institution in which the amplification event took place.
223 * Usually the {@link Amplification#getActor()} should be a person
224 * or team that works for this institution at the given time
225 * @return the institution
226 */
227 // #4498
228 public Institution getInstitution() {
229 return institution;
230 }
231 /**
232 * @see #getInstitution()
233 */
234 public void setInstitution(Institution institution) {
235 this.institution = institution;
236 }
237
238 /**
239 * The voltage used for running the electrophoresis quality check.
240 * Base unit is voltage [V].
241 * @see #getGelRunningTime()
242 * @see #getGelPhoto()
243 * @see #getLadderUsed()
244 * @see #getGelConcentration()
245
246 */
247 public Double getElectrophoresisVoltage() {
248 return electrophoresisVoltage;
249 }
250 /**
251 * @see #getElectrophoresisVoltage()
252 */
253 public void setElectrophoresisVoltage(Double electrophoresisVoltage) {
254 this.electrophoresisVoltage = electrophoresisVoltage;
255 }
256
257 /**
258 * The time for running the electrophoresis quality check.
259 * Base unit is minutes [min].
260 */
261 public Double getGelRunningTime() {
262 return gelRunningTime;
263 }
264 /**
265 * @see #getGelRunningTime()
266 */
267 public void setGelRunningTime(Double gelRunningTime) {
268 this.gelRunningTime = gelRunningTime;
269 }
270
271
272 /**
273 * The gel concentration used for the electrophoresis.
274 * Base unit is [%]
275 * @see #getElectrophoresisVoltage()
276 * @see #getGelRunningTime()
277 * @see #getGelPhoto()
278 * @see #getLadderUsed()
279 */
280 public Double getGelConcentration() {
281 return gelConcentration;
282 }
283 /**
284 * @see #getGelConcentration()
285 */
286 public void setGelConcentration(Double gelConcentration) {
287 this.gelConcentration = gelConcentration;
288 }
289
290 /**
291 * Material and method used for testing quality of this amplification.
292 * @see #getElectrophoresisVoltage()
293 * @see #getGelPhoto()
294 * @see #getGelConcentration()
295 * @see #getGelRunningTime()
296 */
297 public String getLadderUsed() {
298 return ladderUsed;
299 }
300 /**
301 * @see #getLadderUsed()
302 */
303 public void setLadderUsed(String ladderUsed) {
304 this.ladderUsed = ladderUsed;
305 }
306
307
308 // ********************** CLONE ***********************************/
309 /**
310 * Clones <i>this</i> amplification. This is a shortcut that enables to create
311 * a new instance that differs only slightly from <i>this</i> amplification by
312 * modifying only some of the attributes.<BR><BR>
313 *
314 *
315 * @see EventBase#clone()
316 * @see java.lang.Object#clone()
317 */
318 @Override
319 public Object clone() {
320 try{
321 Amplification result = (Amplification)super.clone();
322
323 //don't change marker, forwardPrimer, reversePrimer,
324 //purifiaction, ladderUsed, electrophoresisVoltage,
325 //gelRunningTime, gelConcentration
326 return result;
327 }catch (CloneNotSupportedException e) {
328 logger.warn("Object does not implement cloneable");
329 e.printStackTrace();
330 return null;
331 }
332 }
333
334
335 }