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.ManyToOne;
|
14
|
import javax.persistence.Transient;
|
15
|
import javax.xml.bind.annotation.XmlAccessType;
|
16
|
import javax.xml.bind.annotation.XmlAccessorType;
|
17
|
import javax.xml.bind.annotation.XmlAttribute;
|
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.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
|
25
|
import org.hibernate.annotations.Cascade;
|
26
|
import org.hibernate.annotations.CascadeType;
|
27
|
import org.hibernate.annotations.Type;
|
28
|
import org.hibernate.envers.Audited;
|
29
|
|
30
|
import eu.etaxonomy.cdm.model.agent.AgentBase;
|
31
|
import eu.etaxonomy.cdm.model.common.EventBase;
|
32
|
import eu.etaxonomy.cdm.model.common.TimePeriod;
|
33
|
import eu.etaxonomy.cdm.model.media.Media;
|
34
|
import eu.etaxonomy.cdm.model.occurrence.MaterialOrMethodEvent;
|
35
|
|
36
|
/**
|
37
|
* Instances of this the {@link SingleRead} class describe the process and the result of a single
|
38
|
* sequence generation (read). It has as an input the PCR result ({@link AmplificationResult}). A primer
|
39
|
* is used for expressing the DNA in either {@link SequenceDirection#Forward forward} or
|
40
|
* {@link SequenceDirection#Reverse reverse} direction.
|
41
|
* The result of the process is a {@link #getPherogram() pherogram} which by interpretation results
|
42
|
* in the most probable {@link #getSequence() sequence}.
|
43
|
* The event dates like the sequencing date and the sequencing agent(person) are inherited by {@link EventBase}.
|
44
|
*
|
45
|
* @see AmplificationResult
|
46
|
* @see SequenceString
|
47
|
* @see Sequence
|
48
|
*
|
49
|
* @author a.mueller
|
50
|
* @since 2013-07-05
|
51
|
*/
|
52
|
@XmlAccessorType(XmlAccessType.FIELD)
|
53
|
@XmlType(name = "SingleRead", propOrder = {
|
54
|
"amplificationResult",
|
55
|
"sequence",
|
56
|
"primer",
|
57
|
"direction",
|
58
|
"pherogram",
|
59
|
"materialOrMethod"
|
60
|
})
|
61
|
@XmlRootElement(name = "SingleRead")
|
62
|
@Entity
|
63
|
@Audited
|
64
|
public class SingleRead extends EventBase implements Cloneable{
|
65
|
private static final long serialVersionUID = 1735535003073536132L;
|
66
|
private static final Logger logger = LogManager.getLogger(SingleRead.class);
|
67
|
|
68
|
/** @see #getAmplificationResult() */
|
69
|
@XmlElement(name = "AmplificationResult")
|
70
|
@XmlIDREF
|
71
|
@XmlSchemaType(name = "IDREF")
|
72
|
@ManyToOne(fetch = FetchType.LAZY)
|
73
|
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
|
74
|
private AmplificationResult amplificationResult;
|
75
|
|
76
|
/** @see #getPrimer()*/
|
77
|
@XmlElement(name = "Primer")
|
78
|
@XmlIDREF
|
79
|
@XmlSchemaType(name = "IDREF")
|
80
|
@ManyToOne(fetch = FetchType.LAZY)
|
81
|
private Primer primer;
|
82
|
|
83
|
/** @see #getSequence()*/
|
84
|
/**{@link #getSequence()}*/
|
85
|
@XmlElement(name = "Sequence")
|
86
|
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
|
87
|
private SequenceString sequence = SequenceString.NewInstance();
|
88
|
|
89
|
@XmlElement(name = "Pherogram")
|
90
|
@XmlIDREF
|
91
|
@XmlSchemaType(name = "IDREF")
|
92
|
@ManyToOne(fetch = FetchType.LAZY)
|
93
|
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
|
94
|
private Media pherogram;
|
95
|
|
96
|
/** @see #getDirection()*/
|
97
|
@XmlAttribute(name ="direction")
|
98
|
//TODO length = 3
|
99
|
@Type(type = "eu.etaxonomy.cdm.hibernate.EnumUserType",
|
100
|
parameters = {@org.hibernate.annotations.Parameter(name = "enumClass", value = "eu.etaxonomy.cdm.model.molecular.SequenceDirection")}
|
101
|
)
|
102
|
private SequenceDirection direction;
|
103
|
|
104
|
@XmlElement(name = "MaterialOrMethod")
|
105
|
@XmlIDREF
|
106
|
@XmlSchemaType(name = "IDREF")
|
107
|
@ManyToOne(fetch = FetchType.LAZY)
|
108
|
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
|
109
|
private MaterialOrMethodEvent materialOrMethod;
|
110
|
|
111
|
|
112
|
// ******************** FACTORY METHOD ******************/
|
113
|
|
114
|
public static SingleRead NewInstance(){
|
115
|
return new SingleRead();
|
116
|
}
|
117
|
|
118
|
// ********************* CONSTRUCTOR ********************/
|
119
|
|
120
|
//protected for Javassist, otherwise private
|
121
|
protected SingleRead(){};
|
122
|
|
123
|
// ********************* GETTER / SETTER ********************/
|
124
|
|
125
|
|
126
|
/**
|
127
|
* Returns the {@link AmplificationResult amplification product} that was the input for this
|
128
|
* {@link SingleRead single sequence}.
|
129
|
*/
|
130
|
public AmplificationResult getAmplificationResult() {
|
131
|
return amplificationResult;
|
132
|
}
|
133
|
|
134
|
/**
|
135
|
* TODO this method is protected as long as bidirectionality is not clear.
|
136
|
* @see #getAmplificationResult()
|
137
|
*/
|
138
|
protected void setAmplificationResult(AmplificationResult amplificationResult) {
|
139
|
this.amplificationResult = amplificationResult;
|
140
|
}
|
141
|
|
142
|
/**
|
143
|
* The {@link Primer primer} used for processing this single sequence.
|
144
|
* Often this primer already has been used in the according {@link Amplification amplification}.
|
145
|
* However, there are exceptions from this rule.
|
146
|
*/
|
147
|
public Primer getPrimer() {
|
148
|
return primer;
|
149
|
}
|
150
|
|
151
|
/**
|
152
|
* @see #getPrimer()
|
153
|
*/
|
154
|
public void setPrimer(Primer primer) {
|
155
|
this.primer = primer;
|
156
|
}
|
157
|
|
158
|
/**
|
159
|
* The {@link SequenceString sequence string} of this single sequence process (e.g. AGTGGTAGGATG)
|
160
|
*/
|
161
|
public SequenceString getSequence() {
|
162
|
return sequence;
|
163
|
}
|
164
|
|
165
|
/**
|
166
|
* @see #getSequence()
|
167
|
*/
|
168
|
public void setSequence(SequenceString sequence) {
|
169
|
if (sequence == null){
|
170
|
SequenceString.NewInstance();
|
171
|
}
|
172
|
this.sequence = sequence;
|
173
|
}
|
174
|
|
175
|
/**
|
176
|
* The {@link SequenceDirection direction} in which this single sequence has been created.
|
177
|
* Usually an {@link Amplification amplification} leads to 2 single sequences per {@link DnaSample},
|
178
|
* a {@link SequenceDirection#Forward forward} and a {@link SequenceDirection#Reverse reverse} one.
|
179
|
* These 2 result then in a {@link Sequence consensus sequence}.
|
180
|
* But there are exceptions from this rule.
|
181
|
*/
|
182
|
public SequenceDirection getDirection() {
|
183
|
return direction;
|
184
|
}
|
185
|
|
186
|
/**
|
187
|
* @see #getDirection()
|
188
|
*/
|
189
|
public void setDirection(SequenceDirection direction) {
|
190
|
this.direction = direction;
|
191
|
}
|
192
|
|
193
|
/**
|
194
|
* The pherogram (chromatogram) which visualizes the result of this single sequence.
|
195
|
*/
|
196
|
public Media getPherogram() {
|
197
|
return pherogram;
|
198
|
}
|
199
|
|
200
|
/**
|
201
|
* @see #getPherogram()
|
202
|
*/
|
203
|
public void setPherogram(Media pherogram) {
|
204
|
this.pherogram = pherogram;
|
205
|
}
|
206
|
|
207
|
|
208
|
/**
|
209
|
* The material and/or method used for this sequencing.
|
210
|
*/
|
211
|
public MaterialOrMethodEvent getMaterialOrMethod() {
|
212
|
return materialOrMethod;
|
213
|
}
|
214
|
|
215
|
/**
|
216
|
* @see #getMaterialOrMethod()
|
217
|
*/
|
218
|
public void setMaterialOrMethod(MaterialOrMethodEvent materialOrMethod) {
|
219
|
this.materialOrMethod = materialOrMethod;
|
220
|
}
|
221
|
|
222
|
|
223
|
|
224
|
//*************************** Transient GETTER /SETTER *****************************/
|
225
|
/**
|
226
|
* Delegate method to get the text representation of the {@link #getSequence() sequence}.
|
227
|
* @see #setSequenceString(String)
|
228
|
*/
|
229
|
@Transient
|
230
|
public String getSequenceString() {
|
231
|
return sequence.getString();
|
232
|
}
|
233
|
|
234
|
/**
|
235
|
* Delegate method to set the text representation of the {@link #getSequence() sequence}.
|
236
|
*/
|
237
|
@Transient
|
238
|
public void setSequenceString(String sequence) {
|
239
|
this.sequence.setString(sequence);
|
240
|
}
|
241
|
|
242
|
/**
|
243
|
* Transient convenience method which wrapps {@link EventBase#getActor()}.
|
244
|
* @return the {@link TimePeriod date/period} when this sequence was created.
|
245
|
*/
|
246
|
@Transient
|
247
|
public TimePeriod getDateSequenced(){
|
248
|
return ((EventBase)this).getTimeperiod();
|
249
|
}
|
250
|
|
251
|
/**
|
252
|
* @see #getDateSequenced()
|
253
|
*/
|
254
|
public void setDateSequenced(TimePeriod dateSequenced){
|
255
|
this.setTimeperiod(dateSequenced);
|
256
|
}
|
257
|
|
258
|
/**
|
259
|
* Transient convenience method which wrapps {@link EventBase#getActor()}.
|
260
|
* @return the {@link AgentBase agent} who sequenced this single sequence.
|
261
|
*/
|
262
|
@Transient
|
263
|
public AgentBase getSequencedBy(){
|
264
|
return ((EventBase)this).getActor();
|
265
|
}
|
266
|
|
267
|
/**
|
268
|
* @see #getSequencedBy()
|
269
|
*/
|
270
|
public void setSequencedBy(AgentBase sequencedBy){
|
271
|
this.setActor(sequencedBy);
|
272
|
}
|
273
|
|
274
|
|
275
|
// ********************* CLONE ********************/
|
276
|
/**
|
277
|
* Clones <i>this</i> sequence. This is a shortcut that enables to create
|
278
|
* a new instance that differs only slightly from <i>this</i> sequencing by
|
279
|
* modifying only some of the attributes.<BR><BR>
|
280
|
*
|
281
|
* @see java.lang.Object#clone()
|
282
|
*/
|
283
|
@Override
|
284
|
public SingleRead clone() {
|
285
|
try{
|
286
|
SingleRead result = (SingleRead)super.clone();
|
287
|
|
288
|
//sequences
|
289
|
result.sequence = (SequenceString)this.sequence.clone();
|
290
|
|
291
|
//don't change amplification, pherogram, primer, sequence, direction
|
292
|
return result;
|
293
|
|
294
|
}catch (CloneNotSupportedException e) {
|
295
|
logger.warn("Object does not implement cloneable");
|
296
|
e.printStackTrace();
|
297
|
return null;
|
298
|
}
|
299
|
}
|
300
|
}
|