4 package eu
.etaxonomy
.cdm
.model
.molecular
;
6 import javax
.persistence
.Entity
;
7 import javax
.persistence
.FetchType
;
8 import javax
.persistence
.Lob
;
9 import javax
.persistence
.ManyToOne
;
10 import javax
.xml
.bind
.annotation
.XmlAccessType
;
11 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
12 import javax
.xml
.bind
.annotation
.XmlElement
;
13 import javax
.xml
.bind
.annotation
.XmlIDREF
;
14 import javax
.xml
.bind
.annotation
.XmlRootElement
;
15 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
16 import javax
.xml
.bind
.annotation
.XmlType
;
18 import org
.hibernate
.annotations
.Cascade
;
19 import org
.hibernate
.annotations
.CascadeType
;
20 import org
.hibernate
.annotations
.Type
;
21 import org
.hibernate
.envers
.Audited
;
23 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
28 @XmlAccessorType(XmlAccessType
.FIELD
)
29 @XmlType(name
= "SingleReadAlignment", propOrder
= {
36 @XmlRootElement(name
= "SingleReadAlignment")
39 public class SingleReadAlignment
extends VersionableEntity
{
40 private static final long serialVersionUID
= 6141518347067279304L;
42 /** @see #getDnaMarker() */
43 @XmlElement(name
= "ConsensusAlignment")
45 @XmlSchemaType(name
= "IDREF")
46 @ManyToOne(fetch
= FetchType
.LAZY
)
47 //for now we do not cascade but expect the user to save the sequence manually
48 private Sequence consensusAlignment
;
50 /** @see #getDnaMarker() */
51 @XmlElement(name
= "SingleRead")
53 @XmlSchemaType(name
= "IDREF")
54 @ManyToOne(fetch
= FetchType
.LAZY
)
55 @Cascade({CascadeType
.SAVE_UPDATE
, CascadeType
.MERGE
})
56 private SingleRead singleRead
;
58 //TODO XML mapping / user type
59 @Type(type
="shiftUserType")
60 private Shift
[] shifts
;
62 @XmlElement(name
= "EditedSequence")
64 private String editedSequence
;
66 @XmlElement(name
= "ReverseComplement")
67 private boolean reverseComplement
;
70 public static class Shift
{
75 public Shift(int position
, int steps
) {
76 this.position
= position
;
81 public String
toString(){
82 return String
.valueOf(position
) + "," + String
.valueOf(shift
);
86 //****************** FACTORY *******************/
88 public static SingleReadAlignment
NewInstance(Sequence consensusSequence
, SingleRead singleRead
){
89 return new SingleReadAlignment(consensusSequence
, singleRead
, null, null);
92 public static SingleReadAlignment
NewInstance(Sequence consensusSequence
, SingleRead singleRead
,
93 Shift
[] shifts
, String editedSequence
){
94 return new SingleReadAlignment(consensusSequence
, singleRead
, shifts
, editedSequence
);
97 // ***************** CONSTRUCTOR *************************/
99 protected SingleReadAlignment(){};
101 private SingleReadAlignment(Sequence consensusAlignment
, SingleRead singleRead
,
102 Shift
[] shifts
, String editedSequence
){
103 setConsensusAlignment(consensusAlignment
);
104 setSingleRead(singleRead
);
105 this.shifts
= shifts
;
106 this.editedSequence
= editedSequence
;
110 // ****************** GETTER / SETTER ***********************/
113 public Sequence
getConsensusSequence() {
114 return consensusAlignment
;
116 public void setConsensusAlignment(Sequence consensusAlignment
) {
117 if (this.consensusAlignment
!= null && this.consensusAlignment
.getSingleReadAlignments().contains(this)){
118 this.consensusAlignment
.removeSingleReadAlignment(this);
120 this.consensusAlignment
= consensusAlignment
;
121 if (consensusAlignment
!= null && ! consensusAlignment
.getSingleReadAlignments().contains(this)){
122 consensusAlignment
.addSingleReadAlignment(this);
126 public SingleRead
getSingleRead() {
129 public void setSingleRead(SingleRead singleRead
) {
130 // if (this.singleRead != null xxx){
131 // this.singleRead.removeSingleReadAlignment(this);
133 this.singleRead
= singleRead
;
134 // if (singleRead != null && singleRead.getSingleReadAlignments().contains(this)){
135 // singleRead.addSingleReadAlignment(this);
140 public Shift
[] getShifts() {
143 public void setShifts(Shift
[] shifts
) {
144 this.shifts
= shifts
;
148 public String
getEditedSequence() {
149 return editedSequence
;
152 public void setEditedSequence(String editedSequence
) {
153 this.editedSequence
= editedSequence
;
156 // ******************* CLONE *********************/
161 public Object
clone() throws CloneNotSupportedException
{
162 //all objects can be reused
163 return super.clone();