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
.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
;
24 import org
.apache
.log4j
.Logger
;
25 import org
.hibernate
.annotations
.Type
;
26 import org
.hibernate
.envers
.Audited
;
28 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
29 import eu
.etaxonomy
.cdm
.model
.common
.EventBase
;
30 import eu
.etaxonomy
.cdm
.model
.common
.TimePeriod
;
31 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
32 import eu
.etaxonomy
.cdm
.model
.occurrence
.MaterialOrMethodEvent
;
35 * Instances of this the {@link SingleRead} class describe the process and the result of a single
36 * sequence generation (read). It has as an input the PCR result ({@link Amplification}). A primer
37 * is used for expressing the DNA in either {@link SequenceDirection#Forward forward} or
38 * {@link SequenceDirection#Reverse reverse} direction.
39 * The result of the process is a {@link #getPherogram() pherogram} which by interpretation results
40 * in the most probable {@link #getSequence() sequence}.
41 * The event dates like the sequencing date and the sequencing agent(person) are inherited by {@link EventBase}.
50 @XmlAccessorType(XmlAccessType
.FIELD
)
51 @XmlType(name
= "SingleRead", propOrder
= {
59 @XmlRootElement(name
= "Primer")
62 public class SingleRead
extends EventBase
implements Cloneable
{
63 private static final long serialVersionUID
= 1735535003073536132L;
64 private static final Logger logger
= Logger
.getLogger(SingleRead
.class);
66 /** @see #getAmplification() */
67 @XmlElement(name
= "Amplification")
69 @XmlSchemaType(name
= "IDREF")
70 @ManyToOne(fetch
= FetchType
.LAZY
)
71 private Amplification amplification
;
73 /** @see #getPrimer()*/
74 @XmlElement(name
= "Primer")
76 @XmlSchemaType(name
= "IDREF")
77 @ManyToOne(fetch
= FetchType
.LAZY
)
78 private Primer primer
;
80 /** @see #getSequence()*/
81 /**{@link #getSequence()}*/
82 @XmlElement(name
= "Sequence")
83 private SequenceString sequence
= SequenceString
.NewInstance();
85 @XmlElement(name
= "Pherogram")
87 @XmlSchemaType(name
= "IDREF")
88 @ManyToOne(fetch
= FetchType
.LAZY
)
89 private Media pherogram
;
91 /** @see #getDirection()*/
92 @XmlAttribute(name
="direction")
94 @Type(type
= "eu.etaxonomy.cdm.hibernate.EnumUserType",
95 parameters
= {@org.hibernate
.annotations
.Parameter(name
= "enumClass", value
= "eu.etaxonomy.cdm.model.molecular.SequenceDirection")}
97 private SequenceDirection direction
;
99 @XmlElement(name
= "MaterialOrMethod")
101 @XmlSchemaType(name
= "IDREF")
102 @ManyToOne(fetch
= FetchType
.LAZY
)
103 private MaterialOrMethodEvent materialOrMethod
;
106 // ******************** FACTORY METHOD ******************/
108 public static SingleRead
NewInstance(){
109 return new SingleRead();
112 // ********************* CONSTRUCTOR ********************/
114 private SingleRead(){};
116 // ********************* GETTER / SETTER ********************/
120 * Returns the {@link Amplification amplification} that was the input for this
121 * {@link SingleRead single sequence}.
123 public Amplification
getAmplification() {
124 return amplification
;
128 * TODO this method is protected as long as bidirectionality is not clear.
129 * @see #getAmplification()
131 protected void setAmplification(Amplification amplification
) {
132 this.amplification
= amplification
;
136 * The {@link Primer primer} used for processing this single sequence.
137 * Often this primer already has been used in the according amplification.
138 * However, there are exceptions from this rule.
140 public Primer
getPrimer() {
147 public void setPrimer(Primer primer
) {
148 this.primer
= primer
;
152 * The {@link SequenceString sequence string} of this single sequence process (e.g. AGTGGTAGGATG)
154 public SequenceString
getSequence() {
159 * @see #getSequence()
161 public void setSequence(SequenceString sequence
) {
162 if (sequence
== null){
163 SequenceString
.NewInstance();
165 this.sequence
= sequence
;
169 * The {@link SequenceDirection direction} in which this single sequence has been created.
170 * Usually an {@link Amplification amplification} leads to 2 single sequences a
171 * {@link SequenceDirection#Forward forward} and a {@link SequenceDirection#Reverse reverse} one.
172 * These 2 result then in a {@link Sequence consensus sequence}.
173 * But there are exceptions from this rule.
175 public SequenceDirection
getDirection() {
180 * @see #getDirection()
182 public void setDirection(SequenceDirection direction
) {
183 this.direction
= direction
;
187 * The pherogram (chromatogram) which visualizes the result of this single sequence.
189 public Media
getPherogram() {
194 * @see #getPherogram()
196 public void setPherogram(Media pherogram
) {
197 this.pherogram
= pherogram
;
202 * The material and/or method used for this sequencing.
204 public MaterialOrMethodEvent
getMaterialOrMethod() {
205 return materialOrMethod
;
209 * @see #getMaterialOrMethod()
211 public void setMaterialOrMethod(MaterialOrMethodEvent materialOrMethod
) {
212 this.materialOrMethod
= materialOrMethod
;
217 //*************************** Transient GETTER /SETTER *****************************/
219 * Delegate method to get the text representation of the {@link #getSequence() sequence}.
220 * @see #setSequenceString(String)
223 public String
getSequenceString() {
224 return sequence
.getString();
228 * Delegate method to set the text representation of the {@link #getSequence() sequence}.
231 public void setSequenceString(String sequence
) {
232 this.sequence
.setString(sequence
);
236 * Transient convenience method which wrapps {@link EventBase#getActor()}.
237 * @return the {@link TimePeriod date/period} when this sequence was created.
240 public TimePeriod
getDateSequenced(){
241 return ((EventBase
)this).getTimeperiod();
245 * @see #getDateSequenced()
247 public void setDateSequenced(TimePeriod dateSequenced
){
248 this.setTimeperiod(dateSequenced
);
252 * Transient convenience method which wrapps {@link EventBase#getActor()}.
253 * @return the {@link AgentBase agent} who sequenced this single sequence.
256 public AgentBase
getSequencedBy(){
257 return ((EventBase
)this).getActor();
261 * @see #getSequencedBy()
263 public void setSequencedBy(AgentBase sequencedBy
){
264 this.setActor(sequencedBy
);
268 // ********************* CLONE ********************/
270 * Clones <i>this</i> sequence. This is a shortcut that enables to create
271 * a new instance that differs only slightly from <i>this</i> sequencing by
272 * modifying only some of the attributes.<BR><BR>
275 * @see eu.etaxonomy.cdm.model.media.IdentifiableEntity#clone()
276 * @see java.lang.Object#clone()
279 public Object
clone() {
281 SingleRead result
= (SingleRead
)super.clone();
284 result
.sequence
= (SequenceString
)this.sequence
.clone();
287 //Don't change amplification, pherogram, primer, sequence, direction
290 }catch (CloneNotSupportedException e
) {
291 logger
.warn("Object does not implement cloneable");