/
Cohort.java
348 lines (291 loc) · 10.5 KB
/
Cohort.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
/*
* Copyright 2015-2020 OpenCB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opencb.opencga.core.models.cohort;
import org.opencb.biodata.models.common.Status;
import org.opencb.commons.annotations.DataClass;
import org.opencb.commons.annotations.DataField;
import org.opencb.opencga.core.api.FieldConstants;
import org.opencb.opencga.core.models.common.Annotable;
import org.opencb.opencga.core.models.common.AnnotationSet;
import org.opencb.opencga.core.models.common.Enums;
import org.opencb.opencga.core.models.sample.Sample;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@DataClass(id = "Cohort", since = "1.0",
description = "Cohort data model hosts information about any cohort.")
public class Cohort extends Annotable {
/**
* Cohort ID is a mandatory parameter when creating a new Cohort, this ID cannot be changed at the moment.
*
* @apiNote Required, Immutable, Unique
*/
@DataField(id = "id", required = true, indexed = true, unique = true, immutable = true,
description = FieldConstants.GENERIC_ID_DESCRIPTION)
private String id;
/**
* Cohort name parameter.
*
*/
private String name;
/**
* Global unique ID at the whole OpenCGA installation. This is automatically created during the Cohort creation and cannot be changed.
*
* @apiNote Internal, Unique, Immutable
*/
@DataField(id = "uuid", managed = true, indexed = true, unique = true, immutable = true,
description = FieldConstants.GENERIC_UUID_DESCRIPTION)
private String uuid;
@DataField(id = "type", indexed = true,
description = FieldConstants.COHORT_TYPE)
private Enums.CohortType type;
/**
* String representing when the Cohort was created, this is automatically set by OpenCGA.
*
* @apiNote Internal
*/
@DataField(id = "creationDate", indexed = true,
description = FieldConstants.GENERIC_CREATION_DATE_DESCRIPTION)
private String creationDate;
/**
* String representing when was the last time the Cohort was modified, this is automatically set by OpenCGA.
*
* @apiNote Internal
*/
@DataField(id = "modificationDate", indexed = true, since = "1.0",
description = FieldConstants.GENERIC_MODIFICATION_DATE_DESCRIPTION)
private String modificationDate;
/**
* An string to describe the properties of the Cohort.
*
* @apiNote
*/
@DataField(id = "description", defaultValue = "No description available",
description = FieldConstants.GENERIC_DESCRIPTION_DESCRIPTION)
private String description;
@DataField(id = "samples", indexed = true,
description = FieldConstants.COHORT_SAMPLES)
private List<Sample> samples;
@DataField(id = "numSamples", indexed = true,
description = FieldConstants.COHORT_NUM_SAMPLES)
private int numSamples;
@DataField(id = "release", indexed = true,
description = FieldConstants.GENERIC_RELEASE_DESCRIPTION)
private int release;
/**
* An object describing the status of the Sample.
*
* @apiNote
*/
@DataField(id = "status", indexed = true,
description = FieldConstants.GENERIC_CUSTOM_STATUS)
private Status status;
/**
* An object describing the internal information of the Sample. This is managed by OpenCGA.
*
* @apiNote Internal
*/
@DataField(id = "internal", indexed = true,
description = FieldConstants.GENERIC_INTERNAL)
private CohortInternal internal;
/**
* You can use this field to store any other information, keep in mind this is not indexed so you cannot search by attributes.
*
* @apiNote
*/
@DataField(id = "attributes", indexed = true,
description = FieldConstants.GENERIC_ATTRIBUTES_DESCRIPTION)
private Map<String, Object> attributes;
public Cohort() {
}
public Cohort(String id, String name, Enums.CohortType type, String creationDate, String modificationDate, String description,
List<Sample> samples, int release, Map<String, Object> attributes) {
this(id, name, type, creationDate, modificationDate, description, samples, 0, Collections.emptyList(), release, new Status(),
null, attributes);
}
public Cohort(String id, String name, Enums.CohortType type, String creationDate, String modificationDate, String description,
List<Sample> samples, List<AnnotationSet> annotationSetList, int release, Map<String, Object> attributes) {
this(id, name, type, creationDate, modificationDate, description, samples, 0, annotationSetList, release, new Status(),
null, attributes);
}
public Cohort(String id, String name, Enums.CohortType type, String creationDate, String modificationDate, String description,
List<Sample> samples, int numSamples, List<AnnotationSet> annotationSets, int release, Status status,
CohortInternal internal, Map<String, Object> attributes) {
this.id = id;
this.name = name;
this.type = type;
this.creationDate = creationDate;
this.modificationDate = modificationDate;
this.description = description;
this.samples = samples;
this.numSamples = numSamples;
this.annotationSets = annotationSets;
this.release = release;
this.status = status;
this.internal = internal;
this.attributes = attributes;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("Cohort{");
sb.append("id='").append(id).append('\'');
sb.append(", name='").append(name).append('\'');
sb.append(", uuid='").append(uuid).append('\'');
sb.append(", type=").append(type);
sb.append(", creationDate='").append(creationDate).append('\'');
sb.append(", modificationDate='").append(modificationDate).append('\'');
sb.append(", description='").append(description).append('\'');
sb.append(", samples=").append(samples);
sb.append(", numSamples=").append(numSamples);
sb.append(", release=").append(release);
sb.append(", status=").append(status);
sb.append(", internal=").append(internal);
sb.append(", attributes=").append(attributes);
sb.append(", annotationSets=").append(annotationSets);
sb.append('}');
return sb.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Cohort)) {
return false;
}
Cohort cohort = (Cohort) o;
return release == cohort.release
&& Objects.equals(uuid, cohort.uuid)
&& Objects.equals(id, cohort.id)
&& type == cohort.type
&& Objects.equals(creationDate, cohort.creationDate)
&& Objects.equals(internal, cohort.internal)
&& Objects.equals(description, cohort.description)
&& Objects.equals(samples, cohort.samples)
&& Objects.equals(numSamples, cohort.numSamples)
&& Objects.equals(status, cohort.status)
&& Objects.equals(attributes, cohort.attributes);
}
@Override
public int hashCode() {
return Objects.hash(uuid, id, type, creationDate, internal, description, samples, numSamples, status, release, attributes);
}
@Override
public Cohort setUid(long uid) {
super.setUid(uid);
return this;
}
@Override
public Cohort setStudyUid(long studyUid) {
super.setStudyUid(studyUid);
return this;
}
@Override
public String getUuid() {
return uuid;
}
public Cohort setUuid(String uuid) {
this.uuid = uuid;
return this;
}
@Override
public String getId() {
return id;
}
@Override
public Cohort setId(String id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public Cohort setName(String name) {
this.name = name;
return this;
}
public Enums.CohortType getType() {
return type;
}
public Cohort setType(Enums.CohortType type) {
this.type = type;
return this;
}
public String getCreationDate() {
return creationDate;
}
public Cohort setCreationDate(String creationDate) {
this.creationDate = creationDate;
return this;
}
public String getModificationDate() {
return modificationDate;
}
public Cohort setModificationDate(String modificationDate) {
this.modificationDate = modificationDate;
return this;
}
public CohortInternal getInternal() {
return internal;
}
public Cohort setInternal(CohortInternal internal) {
this.internal = internal;
return this;
}
public String getDescription() {
return description;
}
public Cohort setDescription(String description) {
this.description = description;
return this;
}
public List<Sample> getSamples() {
return samples;
}
public Cohort setSamples(List<Sample> samples) {
this.samples = samples;
return this;
}
public int getNumSamples() {
return numSamples;
}
public Cohort setNumSamples(int numSamples) {
this.numSamples = numSamples;
return this;
}
public int getRelease() {
return release;
}
public Cohort setRelease(int release) {
this.release = release;
return this;
}
public Status getStatus() {
return status;
}
public Cohort setStatus(Status status) {
this.status = status;
return this;
}
public Map<String, Object> getAttributes() {
return attributes;
}
public Cohort setAttributes(Map<String, Object> attributes) {
this.attributes = attributes;
return this;
}
}