2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.cdm
.model
.molecular
;
11 import javax
.persistence
.Column
;
12 import javax
.persistence
.Entity
;
13 import javax
.persistence
.FetchType
;
14 import javax
.persistence
.JoinColumn
;
15 import javax
.persistence
.ManyToOne
;
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
;
24 import org
.apache
.commons
.lang
.StringUtils
;
25 import org
.apache
.log4j
.Logger
;
26 import org
.hibernate
.annotations
.Cascade
;
27 import org
.hibernate
.annotations
.CascadeType
;
28 import org
.hibernate
.envers
.Audited
;
29 import org
.hibernate
.search
.annotations
.Analyze
;
30 import org
.hibernate
.search
.annotations
.Field
;
31 import org
.hibernate
.search
.annotations
.IndexedEmbedded
;
32 import org
.hibernate
.search
.annotations
.NumericField
;
34 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
35 import eu
.etaxonomy
.cdm
.model
.agent
.Institution
;
36 import eu
.etaxonomy
.cdm
.model
.common
.EventBase
;
37 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
38 import eu
.etaxonomy
.cdm
.model
.occurrence
.MaterialOrMethodEvent
;
39 import eu
.etaxonomy
.cdm
.model
.term
.DefinedTerm
;
40 import eu
.etaxonomy
.cdm
.model
.term
.TermType
;
43 * The physical process of amplification (also called PCR) extracts and replicates parts of the DNA of
44 * a given {@link #getDnaSample() DNA Sample} . The part of the DNA being replicated is defined by the
45 * {@link Amplification#getDnaMarker() marker} (also called locus) - implemented in CDM as a {@link DefinedTerm}
46 * of term type {@link TermType#DnaMarker}.
49 * To execute the replication {@link Primer primers} (short DNA fractions) are
50 * used. They may work in both directions of the DNA part therefore we do have a
51 * {@link #getForwardPrimer() forward primer} and a {@link #getReversePrimer() reverse primer}.
52 * Most (or all?) amplifications require a {@link #getPurification() purification process}. Additionally
53 * some use {@link #getCloning()} for replication.
55 * <H3>Quality control</H3>
57 * For quality control the resulting product (PCR) is tested using a chromatographic method called
58 * electrophoresis. The parameters (voltage, ladder used, running time, and gel concentration) used
59 * for this electrophoresis as well as the resulting
60 * {@link #getGelPhoto() photo} are also relevant for an amplification.
62 * We have 2 classes to store the core data for an amplification: {@link Amplification} and {@link AmplificationResult}.
64 * In {@link Amplification} we store all data that is equal for an amplification event which includes amplification
65 * of many {@link DnaSample dna samples}. Those data which are relevant only for a specific dna sample are
66 * stored in {@link AmplificationResult}. Theoretically this includes data on the resulting PCR. However, as the
67 * PCR itself is not persistent we do not store further information on it in the CDM and do not handle
68 * {@link AmplificationResult} as a {@link DerivedUnit}.
70 * This may change in future: http://dev.e-taxonomy.eu/trac/ticket/3717.
76 * @see AmplificationResult
78 @XmlAccessorType(XmlAccessType
.FIELD
)
79 @XmlType(name
= "Amplification", propOrder
= {
86 "electrophoresisVoltage",
91 @XmlRootElement(name
= "Amplification")
94 public class Amplification
extends EventBase
implements Cloneable
{
95 private static final long serialVersionUID
= -6382383300974316261L;
97 private static final Logger logger
= Logger
.getLogger(Amplification
.class);
99 /** @see #getDnaMarker()*/
100 @XmlElement(name
= "DnaMarker")
102 @XmlSchemaType(name
= "IDREF")
103 //TODO why is this eager?
104 @ManyToOne(fetch
=FetchType
.EAGER
)
105 private DefinedTerm dnaMarker
;
107 /** @see #getForwardPrimer() */
108 @XmlElement(name
= "ForwardPrimer")
110 @XmlSchemaType(name
= "IDREF")
111 @ManyToOne(fetch
=FetchType
.LAZY
)
112 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
113 private Primer forwardPrimer
;
115 /** @see #getReversePrimer()*/
116 @XmlElement(name
= "ReversePrimer")
118 @XmlSchemaType(name
= "IDREF")
119 @ManyToOne(fetch
=FetchType
.LAZY
)
120 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
121 private Primer reversePrimer
;
124 @XmlElement(name
= "Purification")
126 @XmlSchemaType(name
= "IDREF")
127 @ManyToOne(fetch
=FetchType
.LAZY
)
128 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
129 private MaterialOrMethodEvent purification
;
131 @XmlElement(name
= "Institution")
133 @XmlSchemaType(name
= "IDREF")
134 @ManyToOne(fetch
= FetchType
.LAZY
)
136 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
137 @JoinColumn(name
="institution_id")
138 private Institution institution
;
140 /** @see #getLadderUsed() */
141 @XmlElement(name
= "ladderUsed")
144 private String ladderUsed
;
146 /** @see #getElectrophoresisVoltage()*/
147 @XmlElement(name
= "electrophoresisVoltage")
148 @Field(analyze
= Analyze
.NO
)
150 private Double electrophoresisVoltage
;
152 /** @see #getGelRunningTime() */
153 @XmlElement(name
= "gelRunningTime")
154 @Field(analyze
= Analyze
.NO
)
156 private Double gelRunningTime
;
158 /** @see #getGelConcentration() */
159 @XmlElement(name
= "gelConcentration")
160 @Field(analyze
= Analyze
.NO
)
162 private Double gelConcentration
;
164 //automatically created
165 private String labelCache
;
168 // ********************* FACTORY METHODS ************************/
170 public static Amplification
NewInstance(){
171 return new Amplification();
175 // ******************* CONSTRUCTOR *******************************/
177 protected Amplification(){}
180 //********************* GETTER / SETTER ************/
184 * The {@link TermType#DnaMarker DNA marker} used for this amplification.
185 * The DNA marker also defines the part (locality) of the DNA/RNA examined.
186 * It may also be called <i>locus</i>
188 public DefinedTerm
getDnaMarker() {
191 /** @see #getDnaMarker()*/
192 public void setDnaMarker(DefinedTerm marker
) {
193 this.dnaMarker
= marker
;
197 * The primer used for forward amplification.
198 * @see #getReversePrimer()
200 public Primer
getForwardPrimer() {
201 return forwardPrimer
;
204 * @see #getForwardPrimer()
205 * @see #getReversePrimer()
207 public void setForwardPrimer(Primer forwardPrimer
) {
208 this.forwardPrimer
= forwardPrimer
;
212 * The primer used for reverse amplification.
213 * @see #getForwardPrimer()
215 public Primer
getReversePrimer() {
216 return reversePrimer
;
219 * @see #getReversePrimer()
220 * @see #getForwardPrimer()
222 public void setReversePrimer(Primer reversePrimer
) {
223 this.reversePrimer
= reversePrimer
;
228 * The material and/or method used for purification.
230 public MaterialOrMethodEvent
getPurification() {
234 * @see #getPurification()
236 public void setPurification(MaterialOrMethodEvent purification
) {
237 this.purification
= purification
;
241 * The institution in which the amplification event took place.
242 * Usually the {@link Amplification#getActor()} should be a person
243 * or team that works for this institution at the given time
244 * @return the institution
247 public Institution
getInstitution() {
251 * @see #getInstitution()
253 public void setInstitution(Institution institution
) {
254 this.institution
= institution
;
258 * The voltage used for running the electrophoresis quality check.
259 * Base unit is voltage [V].
260 * @see #getGelRunningTime()
261 * @see #getGelPhoto()
262 * @see #getLadderUsed()
263 * @see #getGelConcentration()
266 public Double
getElectrophoresisVoltage() {
267 return electrophoresisVoltage
;
270 * @see #getElectrophoresisVoltage()
272 public void setElectrophoresisVoltage(Double electrophoresisVoltage
) {
273 this.electrophoresisVoltage
= electrophoresisVoltage
;
277 * The time for running the electrophoresis quality check.
278 * Base unit is minutes [min].
280 public Double
getGelRunningTime() {
281 return gelRunningTime
;
284 * @see #getGelRunningTime()
286 public void setGelRunningTime(Double gelRunningTime
) {
287 this.gelRunningTime
= gelRunningTime
;
292 * The gel concentration used for the electrophoresis.
294 * @see #getElectrophoresisVoltage()
295 * @see #getGelRunningTime()
296 * @see #getGelPhoto()
297 * @see #getLadderUsed()
299 public Double
getGelConcentration() {
300 return gelConcentration
;
303 * @see #getGelConcentration()
305 public void setGelConcentration(Double gelConcentration
) {
306 this.gelConcentration
= gelConcentration
;
310 * Material and method used for testing quality of this amplification.
311 * @see #getElectrophoresisVoltage()
312 * @see #getGelPhoto()
313 * @see #getGelConcentration()
314 * @see #getGelRunningTime()
316 public String
getLadderUsed() {
320 * @see #getLadderUsed()
322 public void setLadderUsed(String ladderUsed
) {
323 this.ladderUsed
= ladderUsed
;
329 * Returns the labelCache
332 public String
getLabelCache() {
338 * This method pushes the {@link Amplification#labelCache label cache} update.
339 * The cache is otherwise updated during persist in CacheStrategyUpdater.
341 public void updateCache(){
343 String institutionName
= getInstitution() == null ?
"" :getInstitution().getTitleCache();
344 String staffName
= getActor() == null ?
"" :getActor().getTitleCache();
345 String dnaMarkerString
= getDnaMarker() == null ?
"" :getDnaMarker().getTitleCache();
346 String dateString
= getTimeperiod() == null ?
"" :getTimeperiod().toString();
349 String designation
= CdmUtils
.concat("_", new String
[]{institutionName
, staffName
, dnaMarkerString
, dateString
});
351 this.labelCache
= StringUtils
.isBlank(designation
) ?
"<Amplification:" + getUuid() + ">" : designation
;
356 // ********************** CLONE ***********************************/
358 * Clones <i>this</i> amplification. This is a shortcut that enables to create
359 * a new instance that differs only slightly from <i>this</i> amplification by
360 * modifying only some of the attributes.<BR><BR>
363 * @see EventBase#clone()
364 * @see java.lang.Object#clone()
367 public Object
clone() {
369 Amplification result
= (Amplification
)super.clone();
371 //don't change marker, forwardPrimer, reversePrimer,
372 //purifiaction, ladderUsed, electrophoresisVoltage,
373 //gelRunningTime, gelConcentration
375 }catch (CloneNotSupportedException e
) {
376 logger
.warn("Object does not implement cloneable");