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
.Entity
;
12 import javax
.persistence
.Enumerated
;
13 import javax
.persistence
.FetchType
;
14 import javax
.persistence
.ManyToOne
;
15 import javax
.persistence
.Transient
;
16 import javax
.xml
.bind
.annotation
.XmlAccessType
;
17 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
18 import javax
.xml
.bind
.annotation
.XmlAttribute
;
19 import javax
.xml
.bind
.annotation
.XmlElement
;
20 import javax
.xml
.bind
.annotation
.XmlIDREF
;
21 import javax
.xml
.bind
.annotation
.XmlRootElement
;
22 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
23 import javax
.xml
.bind
.annotation
.XmlType
;
25 import org
.apache
.log4j
.Logger
;
26 import org
.hibernate
.annotations
.Type
;
27 import org
.hibernate
.envers
.Audited
;
29 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
30 import eu
.etaxonomy
.cdm
.model
.common
.EventBase
;
31 import eu
.etaxonomy
.cdm
.model
.common
.TimePeriod
;
32 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
33 import eu
.etaxonomy
.cdm
.model
.occurrence
.MaterialOrMethodEvent
;
36 * Instances of this the {@link SingleRead} class describe the process and the result of a single
37 * sequence generation (read). It has as an input the PCR result ({@link Amplification}). A primer
38 * is used for expressing the DNA in either {@link SequenceDirection#Forward forward} or
39 * {@link SequenceDirection#Reverse reverse} direction.
40 * The result of the process is a {@link #getPherogram() pherogram} which by interpretation results
41 * in the most probable {@link #getSequence() sequence}.
42 * The event dates like the sequencing date and the sequencing agent(person) are inherited by {@link EventBase}.
51 @XmlAccessorType(XmlAccessType
.FIELD
)
52 @XmlType(name
= "SingleRead", propOrder
= {
60 @XmlRootElement(name
= "Primer")
63 public class SingleRead
extends EventBase
implements Cloneable
{
64 private static final long serialVersionUID
= 1735535003073536132L;
65 private static final Logger logger
= Logger
.getLogger(SingleRead
.class);
67 /** @see #getAmplification() */
68 @XmlElement(name
= "Amplification")
70 @XmlSchemaType(name
= "IDREF")
71 @ManyToOne(fetch
= FetchType
.LAZY
)
72 private Amplification amplification
;
74 /** @see #getPrimer()*/
75 @XmlElement(name
= "Primer")
77 @XmlSchemaType(name
= "IDREF")
78 @ManyToOne(fetch
= FetchType
.LAZY
)
79 private Primer primer
;
81 /** @see #getSequence()*/
82 /**{@link #getSequence()}*/
83 @XmlElement(name
= "Sequence")
84 private SequenceString sequence
= SequenceString
.NewInstance();
86 @XmlElement(name
= "Pherogram")
88 @XmlSchemaType(name
= "IDREF")
89 @ManyToOne(fetch
= FetchType
.LAZY
)
90 private Media pherogram
;
92 /** @see #getDirection()*/
93 @XmlAttribute(name
="direction")
95 @Type(type
= "eu.etaxonomy.cdm.hibernate.EnumUserType",
96 parameters
= {@org.hibernate
.annotations
.Parameter(name
= "enumClass", value
= "eu.etaxonomy.cdm.model.molecular.SequenceDirection")}
98 private SequenceDirection direction
;
100 @XmlElement(name
= "MaterialOrMethod")
102 @XmlSchemaType(name
= "IDREF")
103 @ManyToOne(fetch
= FetchType
.LAZY
)
104 private MaterialOrMethodEvent materialOrMethod
;
107 // ******************** FACTORY METHOD ******************/
109 public static SingleRead
NewInstance(){
110 return new SingleRead();
113 // ********************* CONSTRUCTOR ********************/
115 private SingleRead(){};
117 // ********************* GETTER / SETTER ********************/
121 * Returns the {@link Amplification amplification} that was the input for this
122 * {@link SingleRead single sequence}.
124 public Amplification
getAmplification() {
125 return amplification
;
129 * TODO this method is protected as long as bidirectionality is not clear.
130 * @see #getAmplification()
132 protected void setAmplification(Amplification amplification
) {
133 this.amplification
= amplification
;
137 * The {@link Primer primer} used for processing this single sequence.
139 public Primer
getPrimer() {
146 public void setPrimer(Primer primer
) {
147 this.primer
= primer
;
151 * The {@link SequenceString sequence string} of this single sequence process (e.g. AGTGGTAGGATG)
153 public SequenceString
getSequence() {
158 * @see #getSequence()
160 public void setSequence(SequenceString sequence
) {
161 if (sequence
== null){
162 SequenceString
.NewInstance();
164 this.sequence
= sequence
;
168 * The direction in which this single sequence has been created.
169 * Usually an amplification and a sequencing has a forward single sequence and/or
170 * a reverse single sequence.
172 public SequenceDirection
getDirection() {
177 * @see #getDirection()
179 public void setDirection(SequenceDirection direction
) {
180 this.direction
= direction
;
184 * The pherogram (chromatogram) which visualizes the result of this single sequence.
186 public Media
getPherogram() {
191 * @see #getPherogram()
193 public void setPherogram(Media pherogram
) {
194 this.pherogram
= pherogram
;
199 * The material and/or method used for this sequencing.
201 public MaterialOrMethodEvent
getMaterialOrMethod() {
202 return materialOrMethod
;
206 * @see #getMaterialOrMethod()
208 public void setMaterialOrMethod(MaterialOrMethodEvent materialOrMethod
) {
209 this.materialOrMethod
= materialOrMethod
;
214 //*************************** Transient GETTER /SETTER *****************************/
216 * Delegate method to get the text representation of the {@link #getSequence() sequence}.
217 * @see #setSequenceString(String)
220 public String
getSequenceString() {
221 return sequence
.getString();
225 * Delegate method to set the text representation of the {@link #getSequence() sequence}.
228 public void setSequenceString(String sequence
) {
229 this.sequence
.setString(sequence
);
233 * Transient convenience method which wrapps {@link EventBase#getActor()}.
234 * @return the {@link TimePeriod date/period} when this sequence was created.
237 public TimePeriod
getDateSequenced(){
238 return ((EventBase
)this).getTimeperiod();
242 * @see #getDateSequenced()
244 public void setDateSequenced(TimePeriod dateSequenced
){
245 this.setTimeperiod(dateSequenced
);
249 * Transient convenience method which wrapps {@link EventBase#getActor()}.
250 * @return the {@link AgentBase agent} who sequenced this single sequence.
253 public AgentBase
getSequencedBy(){
254 return ((EventBase
)this).getActor();
258 * @see #getSequencedBy()
260 public void setSequencedBy(AgentBase sequencedBy
){
261 this.setActor(sequencedBy
);
265 // ********************* CLONE ********************/
267 * Clones <i>this</i> sequence. This is a shortcut that enables to create
268 * a new instance that differs only slightly from <i>this</i> sequencing by
269 * modifying only some of the attributes.<BR><BR>
272 * @see eu.etaxonomy.cdm.model.media.IdentifiableEntity#clone()
273 * @see java.lang.Object#clone()
276 public Object
clone() {
278 SingleRead result
= (SingleRead
)super.clone();
281 result
.sequence
= (SequenceString
)this.sequence
.clone();
284 //Don't change amplification, pherogram, primer, sequence, direction
287 }catch (CloneNotSupportedException e
) {
288 logger
.warn("Object does not implement cloneable");