1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.io.vamsas; |
22 |
|
|
23 |
|
import jalview.datamodel.DBRefEntry; |
24 |
|
import jalview.datamodel.SequenceFeature; |
25 |
|
import jalview.datamodel.SequenceI; |
26 |
|
import jalview.io.VamsasAppDatastore; |
27 |
|
|
28 |
|
import java.util.List; |
29 |
|
|
30 |
|
import uk.ac.vamsas.objects.core.DataSet; |
31 |
|
import uk.ac.vamsas.objects.core.DbRef; |
32 |
|
import uk.ac.vamsas.objects.core.Sequence; |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
@author |
40 |
|
|
41 |
|
|
|
|
| 0% |
Uncovered Elements: 126 (126) |
Complexity: 34 |
Complexity Density: 0.39 |
|
42 |
|
public class Datasetsequence extends DatastoreItem |
43 |
|
{ |
44 |
|
String dict; |
45 |
|
|
46 |
|
private DataSet dataset; |
47 |
|
|
48 |
|
|
49 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
50 |
0 |
public Datasetsequence(VamsasAppDatastore vamsasAppDatastore,... |
51 |
|
SequenceI sq, String theDict, DataSet theDataset) |
52 |
|
{ |
53 |
0 |
super(vamsasAppDatastore, sq, uk.ac.vamsas.objects.core.Sequence.class); |
54 |
0 |
this.dataset = theDataset; |
55 |
|
|
56 |
0 |
this.dict = theDict; |
57 |
0 |
doSync(); |
58 |
|
} |
59 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
60 |
0 |
public Datasetsequence(VamsasAppDatastore vamsasAppDatastore,... |
61 |
|
Sequence vdseq) |
62 |
|
{ |
63 |
0 |
super(vamsasAppDatastore, vdseq, SequenceI.class); |
64 |
0 |
doJvUpdate(); |
65 |
|
} |
66 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
67 |
0 |
@Override... |
68 |
|
public void addFromDocument() |
69 |
|
{ |
70 |
0 |
Sequence vseq = (Sequence) vobj; |
71 |
0 |
SequenceI dsseq = new jalview.datamodel.Sequence(vseq.getName(), |
72 |
|
vseq.getSequence(), (int) vseq.getStart(), (int) vseq.getEnd()); |
73 |
0 |
dsseq.setDescription(vseq.getDescription()); |
74 |
0 |
bindjvvobj(dsseq, vseq); |
75 |
0 |
dsseq.setVamsasId(vseq.getVorbaId().getId()); |
76 |
0 |
jvobj = dsseq; |
77 |
0 |
modified = true; |
78 |
|
} |
79 |
|
|
|
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 10 |
Complexity Density: 0.59 |
|
80 |
0 |
@Override... |
81 |
|
public void updateFromDoc() |
82 |
|
{ |
83 |
0 |
Sequence sq = (Sequence) vobj; |
84 |
0 |
SequenceI sequence = (SequenceI) jvobj; |
85 |
0 |
if (!sequence.getSequenceAsString().equals(sq.getSequence())) |
86 |
|
{ |
87 |
0 |
log.warn( |
88 |
|
"Potential Client Error ! - mismatch of dataset sequence: and jalview internal dataset sequence."); |
89 |
|
} |
90 |
|
else |
91 |
|
{ |
92 |
|
|
93 |
0 |
if (sequence.getDescription() != null |
94 |
|
&& (sequence.getDescription() == null || !sequence |
95 |
|
.getDescription().equals(sq.getDescription()))) |
96 |
|
{ |
97 |
0 |
sequence.setDescription(sq.getDescription()); |
98 |
0 |
modified = true; |
99 |
|
} |
100 |
0 |
if (sequence.getSequence() == null |
101 |
|
|| !sequence.getSequenceAsString().equals(sq.getSequence())) |
102 |
|
{ |
103 |
0 |
if (sequence.getStart() != sq.getStart() |
104 |
|
|| sequence.getEnd() != sq.getEnd()) |
105 |
|
{ |
106 |
|
|
107 |
0 |
sequence.setSequence(sq.getSequence()); |
108 |
0 |
sequence.setStart((int) sq.getStart()); |
109 |
0 |
sequence.setEnd((int) sq.getEnd()); |
110 |
0 |
modified = true; |
111 |
|
} |
112 |
|
} |
113 |
0 |
if (!sequence.getName().equals(sq.getName())) |
114 |
|
{ |
115 |
0 |
sequence.setName(sq.getName()); |
116 |
0 |
modified = true; |
117 |
|
} |
118 |
0 |
modified |= updateJvDbRefs(); |
119 |
|
|
120 |
|
} |
121 |
|
} |
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
135 |
0 |
private boolean updateSqFeatures()... |
136 |
|
{ |
137 |
0 |
boolean changed = false; |
138 |
0 |
SequenceI sq = (SequenceI) jvobj; |
139 |
|
|
140 |
|
|
141 |
0 |
List<SequenceFeature> sfs = sq.getSequenceFeatures(); |
142 |
0 |
for (SequenceFeature sf : sfs) |
143 |
|
{ |
144 |
0 |
changed |= new jalview.io.vamsas.Sequencefeature(datastore, sf, |
145 |
|
dataset, (Sequence) vobj).docWasUpdated(); |
146 |
|
} |
147 |
|
|
148 |
0 |
return changed; |
149 |
|
} |
150 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
|
151 |
0 |
@Override... |
152 |
|
public void addToDocument() |
153 |
|
{ |
154 |
0 |
SequenceI sq = (SequenceI) jvobj; |
155 |
0 |
Sequence sequence = new Sequence(); |
156 |
0 |
bindjvvobj(sq, sequence); |
157 |
0 |
sq.setVamsasId(sequence.getVorbaId().getId()); |
158 |
0 |
sequence.setSequence(sq.getSequenceAsString()); |
159 |
0 |
sequence.setDictionary(dict); |
160 |
0 |
sequence.setName(sq.getName()); |
161 |
0 |
sequence.setStart(sq.getStart()); |
162 |
0 |
sequence.setEnd(sq.getEnd()); |
163 |
0 |
sequence.setDescription(sq.getDescription()); |
164 |
0 |
dataset.addSequence(sequence); |
165 |
0 |
vobj = sequence; |
166 |
0 |
updateSqFeatures(); |
167 |
0 |
updateDbRefs(); |
168 |
|
} |
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
@return |
174 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
175 |
0 |
private boolean updateDbRefs()... |
176 |
|
{ |
177 |
0 |
boolean modifiedthedoc = false; |
178 |
0 |
SequenceI sq = (SequenceI) jvobj; |
179 |
|
|
180 |
0 |
if (sq.getDatasetSequence() == null && sq.getDBRefs() != null) |
181 |
|
{ |
182 |
|
|
183 |
0 |
List<DBRefEntry> entries = sq.getDBRefs(); |
184 |
|
|
185 |
0 |
for (int db = 0, dn = entries.size(); db < dn; db++) |
186 |
|
{ |
187 |
0 |
modifiedthedoc |= new jalview.io.vamsas.Dbref(datastore, |
188 |
|
|
189 |
|
entries.get(db), sq, (Sequence) vobj, dataset) |
190 |
|
.docWasUpdated(); |
191 |
|
|
192 |
|
} |
193 |
|
|
194 |
|
} |
195 |
0 |
return modifiedthedoc; |
196 |
|
} |
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
@return |
202 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
203 |
0 |
private boolean updateJvDbRefs()... |
204 |
|
{ |
205 |
0 |
boolean modifiedtheseq = false; |
206 |
0 |
SequenceI sq = (SequenceI) jvobj; |
207 |
0 |
Sequence vsq = (Sequence) vobj; |
208 |
0 |
if (vsq.getDbRefCount() > 0) |
209 |
|
{ |
210 |
|
|
211 |
0 |
DbRef[] entries = vsq.getDbRef(); |
212 |
|
|
213 |
0 |
for (int db = 0; db < entries.length; db++) |
214 |
|
{ |
215 |
0 |
modifiedtheseq |= new jalview.io.vamsas.Dbref(datastore, |
216 |
|
|
217 |
|
entries[db], vsq, sq).jvWasUpdated(); |
218 |
|
} |
219 |
|
} |
220 |
0 |
return modifiedtheseq; |
221 |
|
} |
222 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
223 |
0 |
@Override... |
224 |
|
public void conflict() |
225 |
|
{ |
226 |
0 |
log.warn( |
227 |
|
"Conflict in dataset sequence update to document. Overwriting document"); |
228 |
|
|
229 |
0 |
updateToDoc(); |
230 |
|
} |
231 |
|
|
232 |
|
boolean modified = false; |
233 |
|
|
|
|
| 0% |
Uncovered Elements: 29 (29) |
Complexity: 10 |
Complexity Density: 0.53 |
|
234 |
0 |
@Override... |
235 |
|
public void updateToDoc() |
236 |
|
{ |
237 |
0 |
SequenceI sq = (SequenceI) jvobj; |
238 |
0 |
Sequence sequence = (Sequence) vobj; |
239 |
|
|
240 |
0 |
if (sequence.getDescription() != null |
241 |
|
&& (sequence.getDescription() == null || !sequence |
242 |
|
.getDescription().equals(sq.getDescription()))) |
243 |
|
{ |
244 |
0 |
sequence.setDescription(sq.getDescription()); |
245 |
0 |
modified = true; |
246 |
|
} |
247 |
0 |
if (sequence.getSequence() == null |
248 |
|
|| !sequence.getSequence().equals(sq.getSequenceAsString())) |
249 |
|
{ |
250 |
0 |
if (sequence.getStart() != sq.getStart() |
251 |
|
|| sequence.getEnd() != sq.getEnd()) |
252 |
|
{ |
253 |
|
|
254 |
0 |
sequence.setSequence(sq.getSequenceAsString()); |
255 |
0 |
sequence.setStart(sq.getStart()); |
256 |
0 |
sequence.setEnd(sq.getEnd()); |
257 |
0 |
modified = true; |
258 |
|
} |
259 |
|
} |
260 |
0 |
if (!dict.equals(sequence.getDictionary())) |
261 |
|
{ |
262 |
0 |
sequence.setDictionary(dict); |
263 |
0 |
modified = true; |
264 |
|
} |
265 |
0 |
if (!sequence.getName().equals(sq.getName())) |
266 |
|
{ |
267 |
0 |
sequence.setName(sq.getName()); |
268 |
0 |
modified = true; |
269 |
|
} |
270 |
0 |
modified |= updateDbRefs(); |
271 |
0 |
modified |= updateSqFeatures(); |
272 |
|
} |
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
@return |
278 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
279 |
0 |
public boolean getModified()... |
280 |
|
{ |
281 |
0 |
return modified; |
282 |
|
} |
283 |
|
|
284 |
|
} |