1 | import dbnp.studycapturing.* |
---|
2 | |
---|
3 | import dbnp.data.Ontology |
---|
4 | import dbnp.data.Term |
---|
5 | |
---|
6 | /** |
---|
7 | * Application Bootstrapper |
---|
8 | * @Author Jeroen Wesbeek |
---|
9 | * @Since 20091021 |
---|
10 | * |
---|
11 | * Revision information: |
---|
12 | * $Rev: 386 $ |
---|
13 | * $Author: roberth $ |
---|
14 | * $Date: 2010-04-27 13:53:06 +0000 (di, 27 apr 2010) $ |
---|
15 | */ |
---|
16 | class BootStrap { |
---|
17 | def init = {servletContext -> |
---|
18 | // define timezone |
---|
19 | System.setProperty('user.timezone', 'CET') |
---|
20 | |
---|
21 | // we could also check if we are in development by GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT |
---|
22 | if (Study.count() == 0) { |
---|
23 | println ".development bootstrapping..."; |
---|
24 | |
---|
25 | // add NCBI species ontology |
---|
26 | println ".adding NCBI species ontology" |
---|
27 | def speciesOntology = new Ontology( |
---|
28 | name: 'NCBI organismal classification', |
---|
29 | description: 'A taxonomic classification of living organisms and associated artifacts for their controlled description within the context of databases.', |
---|
30 | url: 'http://www.ncbi.nlm.nih.gov/Taxonomy/taxonomyhome.html/', |
---|
31 | versionNumber: '1.2', |
---|
32 | ncboId: '1132', |
---|
33 | ncboVersionedId: '38802' |
---|
34 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
35 | |
---|
36 | // add TERMS |
---|
37 | println ".adding mouse term" |
---|
38 | def mouseTerm = new Term( |
---|
39 | name: 'Mus musculus', |
---|
40 | ontology: speciesOntology, |
---|
41 | accession: '10090' |
---|
42 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
43 | println ".adding human term" |
---|
44 | def humanTerm = new Term( |
---|
45 | name: 'Homo sapiens', |
---|
46 | ontology: speciesOntology, |
---|
47 | accession: '9606' |
---|
48 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
49 | |
---|
50 | def bloodTerm = new Term( |
---|
51 | name: 'Portion of blood', |
---|
52 | ontology: speciesOntology, |
---|
53 | accession: '9670' |
---|
54 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
55 | |
---|
56 | |
---|
57 | // Create a few persons, roles and Affiliations |
---|
58 | println ".adding persons, roles and affiliations" |
---|
59 | def affiliation1 = new PersonAffiliation( |
---|
60 | name: "Science Institute NYC" |
---|
61 | ).save(); |
---|
62 | def affiliation2 = new PersonAffiliation( |
---|
63 | name: "InfoStats GmbH, Hamburg" |
---|
64 | ).save(); |
---|
65 | def role1 = new PersonRole( |
---|
66 | name: "Principal Investigator" |
---|
67 | ).save(); |
---|
68 | def role2 = new PersonRole( |
---|
69 | name: "Statician" |
---|
70 | ).save(); |
---|
71 | |
---|
72 | // Create 30 roles to test pagination |
---|
73 | def roleCounter = 1; |
---|
74 | 30.times { new PersonRole( name: "Rol #${roleCounter++}" ).save() } |
---|
75 | |
---|
76 | // Create persons |
---|
77 | def person1 = new Person( |
---|
78 | lastName: "Scientist", |
---|
79 | firstName: "John", |
---|
80 | gender: "Male", |
---|
81 | initials: "J.R.", |
---|
82 | email: "john@scienceinstitute.com", |
---|
83 | phone: "1-555-3049", |
---|
84 | address: "First street 2,NYC" |
---|
85 | ) |
---|
86 | .addToAffiliations( affiliation1 ) |
---|
87 | .addToAffiliations( affiliation2 ) |
---|
88 | .save(); |
---|
89 | |
---|
90 | def person2 = new Person( |
---|
91 | lastName: "Statician", |
---|
92 | firstName: "Jane", |
---|
93 | gender: "Female", |
---|
94 | initials: "W.J.", |
---|
95 | email: "jane@statisticalcompany.de", |
---|
96 | phone: "49-555-8291", |
---|
97 | address: "Dritten strasse 38, Hamburg, Germany" |
---|
98 | ) |
---|
99 | .addToAffiliations( affiliation2 ) |
---|
100 | .save(); |
---|
101 | |
---|
102 | // Create 30 persons to test pagination |
---|
103 | def personCounter = 1; |
---|
104 | 30.times { new Person( firstName: "Person #${personCounter}", lastName: "Testperson", email: "email${personCounter++}@testdomain.com" ).save() } |
---|
105 | |
---|
106 | /* COMMENTED OUT BECAUSE IT BREAKS EVERYTHING AFTER REFACTORING THE DATAMODEL |
---|
107 | |
---|
108 | // ontologies |
---|
109 | def speciesOntology = new Ontology( |
---|
110 | name: 'NCBI Taxonomy', |
---|
111 | shortName: 'Taxon', |
---|
112 | url: 'http://www.obofoundry.org/cgi-bin/detail.cgi?id=ncbi_taxonomy' |
---|
113 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
114 | |
---|
115 | def humanBodyOntology = new Ontology( |
---|
116 | name: 'Foundational Model of Anatomy', |
---|
117 | shortName: 'HumanBody', |
---|
118 | url: 'http://bioportal.bioontology.org/ontologies/39966' |
---|
119 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
120 | |
---|
121 | def nciOntology = new Ontology( |
---|
122 | name: 'NCI Thesaurus', |
---|
123 | shortName: 'NCI', |
---|
124 | url: 'http://bioportal.bioontology.org/ontologies/42331' |
---|
125 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
126 | |
---|
127 | // terms |
---|
128 | def mouseTerm = new Term( |
---|
129 | name: 'Mus musculus', |
---|
130 | ontology: speciesOntology, |
---|
131 | accession: '10090' |
---|
132 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
133 | def humanTerm = new Term( |
---|
134 | name: 'Homo sapiens', |
---|
135 | ontology: speciesOntology, |
---|
136 | accession: '9606' |
---|
137 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
138 | def arabTerm = new Term( |
---|
139 | name: 'Arabidopsis thaliana', |
---|
140 | ontology: speciesOntology, |
---|
141 | accession: '3702' |
---|
142 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
143 | |
---|
144 | |
---|
145 | def c57bl6Term = new Term( |
---|
146 | name: 'C57BL/6 Mouse', |
---|
147 | ontology: nciOntology, |
---|
148 | accession: 'C14424' |
---|
149 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
150 | |
---|
151 | def madmaxOntology = new Ontology( |
---|
152 | name: 'Madmax ontology', |
---|
153 | shortName: 'MDMX', |
---|
154 | url: 'madmax.bioinformatics.nl' |
---|
155 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
156 | |
---|
157 | def treatmentTerm = new Term( |
---|
158 | name: 'ExperimentalProtocol', |
---|
159 | ontology: madmaxOntology, |
---|
160 | accession: 'P-MDMXGE-264' |
---|
161 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
162 | |
---|
163 | def dietProtocol = new Protocol( |
---|
164 | name: 'Diet treatment Protocol NuGO PPS3 leptin module', |
---|
165 | reference: treatmentTerm |
---|
166 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
167 | |
---|
168 | def boostProtocol = new Protocol( |
---|
169 | name: 'Boost treatment Protocol NuGO PPS3 leptin module', |
---|
170 | reference: treatmentTerm |
---|
171 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
172 | |
---|
173 | def fastingProtocol = new Protocol( |
---|
174 | name: 'Fasting', |
---|
175 | reference: treatmentTerm |
---|
176 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
177 | |
---|
178 | |
---|
179 | // ParameterStringListItems |
---|
180 | def oil10= new ParameterStringListItem( |
---|
181 | name: '10% fat (palm oil)' |
---|
182 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
183 | def oil45= new ParameterStringListItem( |
---|
184 | name: '45% fat (palm oil)' |
---|
185 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
186 | def vehicle= new ParameterStringListItem( |
---|
187 | name: 'Vehicle' |
---|
188 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
189 | def leptin= new ParameterStringListItem( |
---|
190 | name: 'Leptin' |
---|
191 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
192 | |
---|
193 | |
---|
194 | dietProtocol |
---|
195 | .addToParameters(new ProtocolParameter( |
---|
196 | name: 'Diet', |
---|
197 | type: ProtocolParameterType.STRINGLIST, |
---|
198 | listEntries: [oil10,oil45])) |
---|
199 | .save() |
---|
200 | |
---|
201 | boostProtocol |
---|
202 | .addToParameters(new ProtocolParameter( |
---|
203 | name: 'Compound', |
---|
204 | type: ProtocolParameterType.STRINGLIST, |
---|
205 | listEntries: [vehicle,leptin])) |
---|
206 | .save() |
---|
207 | |
---|
208 | fastingProtocol |
---|
209 | .addToParameters(new ProtocolParameter( |
---|
210 | name: 'Fasting period', |
---|
211 | type: ProtocolParameterType.STRING)) |
---|
212 | .save() |
---|
213 | |
---|
214 | |
---|
215 | // sampling event protocols |
---|
216 | |
---|
217 | def liverSamplingProtocol = new Protocol( |
---|
218 | name: 'Liver sampling' |
---|
219 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
220 | |
---|
221 | liverSamplingProtocol |
---|
222 | .addToParameters(new ProtocolParameter( |
---|
223 | name: 'Sample weight', |
---|
224 | unit: 'mg', |
---|
225 | type: ProtocolParameterType.FLOAT)) |
---|
226 | .save() |
---|
227 | |
---|
228 | def bloodSamplingProtocol = new Protocol( |
---|
229 | name: 'Blood sampling' |
---|
230 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
231 | |
---|
232 | bloodSamplingProtocol |
---|
233 | .addToParameters(new ProtocolParameter( |
---|
234 | name: 'Sample volume', |
---|
235 | unit: 'ml', |
---|
236 | type: ProtocolParameterType.FLOAT)) |
---|
237 | .save() |
---|
238 | */ |
---|
239 | // create system user |
---|
240 | |
---|
241 | /*def systemUser = userService.createUser(InstanceGenerator.user( |
---|
242 | username: 'system', |
---|
243 | pass: 'system', |
---|
244 | passConfirm: 'system', |
---|
245 | enabled: true |
---|
246 | ))*/ |
---|
247 | |
---|
248 | |
---|
249 | def genderField = new TemplateField( |
---|
250 | name: 'Gender',type: TemplateFieldType.STRINGLIST, |
---|
251 | listEntries: [new TemplateFieldListItem(name:'Male'),new TemplateFieldListItem(name: 'Female')]) |
---|
252 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
253 | |
---|
254 | def ageField = new TemplateField( |
---|
255 | name: 'Age (years)',type: TemplateFieldType.INTEGER,unit: 'years') |
---|
256 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
257 | |
---|
258 | def genotypeField = new TemplateField( |
---|
259 | name: 'Genotype', type: TemplateFieldType.ONTOLOGYTERM) |
---|
260 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
261 | |
---|
262 | def genotypeTypeField = new TemplateField( |
---|
263 | name: 'Genotype type',type: TemplateFieldType.STRINGLIST, |
---|
264 | listEntries: [new TemplateFieldListItem(name:'wildtype'), |
---|
265 | new TemplateFieldListItem(name:'transgenic'), |
---|
266 | new TemplateFieldListItem(name:'knock-out'), |
---|
267 | new TemplateFieldListItem(name:'knock-in')]) |
---|
268 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
269 | |
---|
270 | |
---|
271 | // Nutritional study template |
---|
272 | |
---|
273 | println ".adding academic study template..." |
---|
274 | def studyTemplate = new Template( |
---|
275 | name: 'Academic study', entity: dbnp.studycapturing.Study) |
---|
276 | .addToFields(new TemplateField(name: 'Description',type: TemplateFieldType.TEXT)) |
---|
277 | .addToFields(new TemplateField(name: 'Study code',type: TemplateFieldType.STRING)) |
---|
278 | .addToFields(new TemplateField(name: 'Objectives',type: TemplateFieldType.TEXT)) |
---|
279 | .addToFields(new TemplateField(name: 'Consortium',type: TemplateFieldType.STRING)) |
---|
280 | .addToFields(new TemplateField(name: 'Cohort name',type: TemplateFieldType.STRING)) |
---|
281 | .addToFields(new TemplateField(name: 'Time zone',type: TemplateFieldType.STRING)) |
---|
282 | .addToFields(new TemplateField(name: 'Responsible scientist',type: TemplateFieldType.STRING)) |
---|
283 | .addToFields(new TemplateField(name: 'Lab id',type: TemplateFieldType.STRING)) |
---|
284 | .addToFields(new TemplateField(name: 'Institute',type: TemplateFieldType.STRING)) |
---|
285 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
286 | |
---|
287 | // Mouse template |
---|
288 | println ".adding mouse subject template..." |
---|
289 | def mouseTemplate = new Template( |
---|
290 | name: 'Mouse', entity: dbnp.studycapturing.Subject) |
---|
291 | .addToFields(new TemplateField( |
---|
292 | name: 'Strain', type: TemplateFieldType.ONTOLOGYTERM)) |
---|
293 | .addToFields(genotypeField) |
---|
294 | .addToFields(genotypeTypeField) |
---|
295 | .addToFields(genderField) |
---|
296 | .addToFields(new TemplateField( |
---|
297 | name: 'Age (weeks)', type: TemplateFieldType.INTEGER, unit: 'weeks')) |
---|
298 | .addToFields(new TemplateField( |
---|
299 | name: 'Age type',type: TemplateFieldType.STRINGLIST, |
---|
300 | listEntries: [new TemplateFieldListItem(name:'postnatal'),new TemplateFieldListItem(name:'embryonal')])) |
---|
301 | .addToFields(new TemplateField( |
---|
302 | name: 'Cage',type: TemplateFieldType.STRING)) |
---|
303 | .addToFields(new TemplateField( |
---|
304 | name: '#Mice in cage',type: TemplateFieldType.INTEGER)) |
---|
305 | .addToFields(new TemplateField( |
---|
306 | name: 'Litter size',type: TemplateFieldType.INTEGER)) |
---|
307 | .addToFields(new TemplateField( |
---|
308 | name: 'Weight (g)', type: TemplateFieldType.DOUBLE, unit: 'gram')) |
---|
309 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
310 | |
---|
311 | // Human template |
---|
312 | println ".adding human subject template..." |
---|
313 | def humanTemplate = new Template( |
---|
314 | name: 'Human', entity: dbnp.studycapturing.Subject) |
---|
315 | .addToFields(genderField) |
---|
316 | .addToFields(ageField) |
---|
317 | .addToFields(new TemplateField( |
---|
318 | name: 'DOB',type: TemplateFieldType.DATE)) |
---|
319 | .addToFields(new TemplateField( |
---|
320 | name: 'Height',type: TemplateFieldType.DOUBLE, unit: 'm')) |
---|
321 | .addToFields(new TemplateField( |
---|
322 | name: 'Weight (kg)',type: TemplateFieldType.DOUBLE, unit: 'kg')) |
---|
323 | .addToFields(new TemplateField( |
---|
324 | name: 'BMI',type: TemplateFieldType.DOUBLE, unit: 'kg/m2')) |
---|
325 | .addToFields(new TemplateField( |
---|
326 | name: 'Race',type: TemplateFieldType.STRING)) |
---|
327 | .addToFields(new TemplateField( |
---|
328 | name: 'Waist circumference',type: TemplateFieldType.FLOAT, unit: 'cm')) |
---|
329 | .addToFields(new TemplateField( |
---|
330 | name: 'Hip circumference',type: TemplateFieldType.FLOAT, unit: 'cm')) |
---|
331 | .addToFields(new TemplateField( |
---|
332 | name: 'Systolic blood pressure',type: TemplateFieldType.FLOAT, unit: 'mmHg')) |
---|
333 | .addToFields(new TemplateField( |
---|
334 | name: 'Diastolic blood pressure',type: TemplateFieldType.FLOAT, unit: 'mmHg')) |
---|
335 | .addToFields(new TemplateField( |
---|
336 | name: 'Heart rate',type: TemplateFieldType.FLOAT, unit: 'beats/min')) |
---|
337 | .addToFields(new TemplateField( |
---|
338 | name: 'Run-in-food',type: TemplateFieldType.TEXT)) |
---|
339 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
340 | |
---|
341 | |
---|
342 | def sampleDescriptionField = new TemplateField( |
---|
343 | name: 'Description',type: TemplateFieldType.TEXT) |
---|
344 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
345 | def sampleTypeField = new TemplateField( |
---|
346 | name: 'SampleType',type: TemplateFieldType.STRING) |
---|
347 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
348 | def sampleProtocolField = new TemplateField( |
---|
349 | name: 'SampleProtocol',type: TemplateFieldType.STRING) |
---|
350 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
351 | def sampleVialTextField = new TemplateField( |
---|
352 | name: 'Text on vial',type: TemplateFieldType.STRING) |
---|
353 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
354 | |
---|
355 | // Human sample template |
---|
356 | println ".adding human sample template..." |
---|
357 | def humanSampleTemplate = new Template( |
---|
358 | name: 'Human tissue sample', entity: dbnp.studycapturing.Sample) |
---|
359 | .addToFields(sampleDescriptionField) |
---|
360 | .addToFields(sampleTypeField) |
---|
361 | .addToFields(sampleProtocolField) |
---|
362 | .addToFields(sampleVialTextField) |
---|
363 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
364 | |
---|
365 | //Plant template |
---|
366 | println ".adding plant template..." |
---|
367 | def plantTemplate = new Template( |
---|
368 | name: 'Plant template', entity: dbnp.studycapturing.Subject) |
---|
369 | .addToFields(new TemplateField( |
---|
370 | name: 'Variety', type: TemplateFieldType.STRING)) |
---|
371 | .addToFields(new TemplateField( |
---|
372 | name: 'Ecotype', type: TemplateFieldType.STRING)) |
---|
373 | .addToFields(genotypeField) |
---|
374 | .addToFields(genotypeTypeField) |
---|
375 | .addToFields(new TemplateField( |
---|
376 | name: 'Growth location', type: TemplateFieldType.STRINGLIST, |
---|
377 | listEntries: [new TemplateFieldListItem(name:'Greenhouse'),new TemplateFieldListItem(name: 'Field')])) |
---|
378 | .addToFields(new TemplateField( |
---|
379 | name: 'Room', type: TemplateFieldType.STRING, |
---|
380 | comment: 'Chamber number in case of Greenhouse')) |
---|
381 | .addToFields(new TemplateField( |
---|
382 | name: 'Position X', type: TemplateFieldType.FLOAT)) |
---|
383 | .addToFields(new TemplateField( |
---|
384 | name: 'Position Y', type: TemplateFieldType.FLOAT)) |
---|
385 | .addToFields(new TemplateField( |
---|
386 | name: 'Block', type: TemplateFieldType.STRING)) |
---|
387 | .addToFields(new TemplateField( |
---|
388 | name: 'Temperature at day', type: TemplateFieldType.FLOAT)) |
---|
389 | .addToFields(new TemplateField( |
---|
390 | name: 'Temperature at night', type: TemplateFieldType.FLOAT)) |
---|
391 | .addToFields(new TemplateField( |
---|
392 | name: 'Photo period', type: TemplateFieldType.STRING)) |
---|
393 | .addToFields(new TemplateField( |
---|
394 | name: 'Light intensity', type: TemplateFieldType.STRING)) |
---|
395 | .addToFields(new TemplateField( |
---|
396 | name: 'Start date', type: TemplateFieldType.DATE)) |
---|
397 | .addToFields(new TemplateField( |
---|
398 | name: 'Harvest date', type: TemplateFieldType.DATE)) |
---|
399 | .addToFields(new TemplateField( |
---|
400 | name: 'Growth type', type: TemplateFieldType.STRINGLIST, |
---|
401 | listEntries: [new TemplateFieldListItem(name:'Standard'),new TemplateFieldListItem(name: 'Experimental')])) |
---|
402 | .addToFields(new TemplateField( |
---|
403 | name: 'Growth protocol', type: TemplateFieldType.TEXT)) |
---|
404 | .addToFields(new TemplateField( |
---|
405 | name: 'Harvest delay', type: TemplateFieldType.TEXT)) |
---|
406 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
407 | |
---|
408 | println ".adding plant sample template..." |
---|
409 | def plantSampleTemplate = new Template( |
---|
410 | name: 'Plant sample', entity: dbnp.studycapturing.Sample) |
---|
411 | .addToFields(sampleDescriptionField) |
---|
412 | .addToFields(sampleTypeField) |
---|
413 | .addToFields(sampleProtocolField) |
---|
414 | .addToFields(sampleVialTextField) |
---|
415 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
416 | |
---|
417 | |
---|
418 | // Event templates |
---|
419 | println ".adding event templates..." |
---|
420 | |
---|
421 | def startDateField = new TemplateField( |
---|
422 | name: 'Start time', type: TemplateFieldType.DATE |
---|
423 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
424 | |
---|
425 | def endDateField = new TemplateField( |
---|
426 | name: 'End time', type: TemplateFieldType.DATE |
---|
427 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
428 | |
---|
429 | Event.systemFields = [startDateField,endDateField] |
---|
430 | |
---|
431 | def dietTreatmentTemplate = new Template( |
---|
432 | name: 'Diet treatment', entity: dbnp.studycapturing.Event) |
---|
433 | .addToFields(sampleDescriptionField) |
---|
434 | .addToFields(new TemplateField( |
---|
435 | name: 'Diet', type: TemplateFieldType.STRINGLIST, |
---|
436 | listEntries: [new TemplateFieldListItem(name:'10% fat (palm oil)'),new TemplateFieldListItem(name: '45% fat (palm oil)')])) |
---|
437 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
438 | |
---|
439 | def boostTreatmentTemplate = new Template( |
---|
440 | name: 'Boost treatment', entity: dbnp.studycapturing.Event) |
---|
441 | .addToFields(sampleDescriptionField) |
---|
442 | .addToFields(new TemplateField( |
---|
443 | name: 'Compound', type: TemplateFieldType.STRING, |
---|
444 | listEntries: [new TemplateFieldListItem(name:'Vehicle'),new TemplateFieldListItem(name: 'Leptin')])) |
---|
445 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
446 | |
---|
447 | def bloodSamplingEventTemplate = new Template( |
---|
448 | name: 'Blood extraction', entity: dbnp.studycapturing.Event) |
---|
449 | .addToFields(sampleDescriptionField) |
---|
450 | .addToFields(new TemplateField( |
---|
451 | name: 'Sample volume', type: TemplateFieldType.FLOAT)) |
---|
452 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
453 | |
---|
454 | def fastingTreatmentTemplate = new Template( |
---|
455 | name: 'Fasting treatment', entity: dbnp.studycapturing.Event) |
---|
456 | .addToFields(sampleDescriptionField) |
---|
457 | .addToFields(new TemplateField( |
---|
458 | name: 'Fasting period', type: TemplateFieldType.STRING)) |
---|
459 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
460 | |
---|
461 | /* |
---|
462 | //events |
---|
463 | def eventDiet = new EventDescription( |
---|
464 | name: 'Diet treatment', |
---|
465 | description: 'Diet treatment (fat percentage)', |
---|
466 | classification: treatmentTerm, |
---|
467 | protocol: dietProtocol, |
---|
468 | isSamplingEvent: false |
---|
469 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
470 | |
---|
471 | def eventBoost = new EventDescription( |
---|
472 | name: 'Boost treatment', |
---|
473 | description: 'Boost treatment (leptin or vehicle)', |
---|
474 | classification: treatmentTerm, |
---|
475 | protocol: boostProtocol, |
---|
476 | isSamplingEvent: false |
---|
477 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
478 | |
---|
479 | def samplingEvent = new EventDescription( |
---|
480 | name: 'Liver extraction', |
---|
481 | description: 'Liver sampling for transcriptomics arrays', |
---|
482 | protocol: liverSamplingProtocol, |
---|
483 | isSamplingEvent: true |
---|
484 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
485 | |
---|
486 | def bloodSamplingEventDescription = new EventDescription( |
---|
487 | name: 'Blood extraction', |
---|
488 | description: 'Blood extraction targeted at lipid assays', |
---|
489 | protocol: bloodSamplingProtocol, |
---|
490 | isSamplingEvent: true |
---|
491 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
492 | |
---|
493 | |
---|
494 | def fastingTreatment = new EventDescription( |
---|
495 | name: 'Fasting treatment', |
---|
496 | description: 'Fasting Protocol NuGO PPSH', |
---|
497 | protocol: fastingProtocol, |
---|
498 | isSamplingEvent: false |
---|
499 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
500 | |
---|
501 | println('Adding PPS3 study...') |
---|
502 | */ |
---|
503 | // studies |
---|
504 | println ".adding NuGO PPS3 leptin example study..." |
---|
505 | def exampleStudy = new Study( |
---|
506 | template: studyTemplate, |
---|
507 | title:"NuGO PPS3 mouse study leptin module", |
---|
508 | code:"PPS3_leptin_module", |
---|
509 | researchQuestion:"Leptin etc.", |
---|
510 | ecCode:"2007117.c", |
---|
511 | startDate: Date.parse('yyyy-MM-dd','2007-12-11') |
---|
512 | ) |
---|
513 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
514 | |
---|
515 | exampleStudy.setFieldValue( 'Description', "C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet. After 1 week 10 mice that received a low fat diet were given an IP leptin challenge and 10 mice of the low-fat group received placebo injections. The same procedure was performed with mice that were fed the high-fat diet. After 4 weeks the procedure was repeated. In total 80 mice were culled." ) |
---|
516 | exampleStudy.save() |
---|
517 | |
---|
518 | |
---|
519 | /* Test output of fields things */ |
---|
520 | println "-----------------------------" |
---|
521 | print "Diet domain fields: " |
---|
522 | println exampleStudy.giveDomainFields().join( ", " ) |
---|
523 | |
---|
524 | print "Diet template fields: " |
---|
525 | println exampleStudy.giveTemplateFields().join( ", " ) |
---|
526 | |
---|
527 | print "Diet all fields: " |
---|
528 | println exampleStudy.giveFields().join( ", " ) |
---|
529 | |
---|
530 | println "-----------------------------" |
---|
531 | |
---|
532 | println ".adding NuGO PPSH example study..." |
---|
533 | def exampleHumanStudy = new Study( |
---|
534 | template: studyTemplate, |
---|
535 | title:"Human example template", |
---|
536 | code:"Human example code", |
---|
537 | researchQuestion:"Leptin etc.", |
---|
538 | ecCode:"2007117.c", |
---|
539 | startDate: Date.parse('yyyy-MM-dd','2007-12-11') |
---|
540 | ) |
---|
541 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
542 | |
---|
543 | exampleHumanStudy.setFieldValue( 'Description', "C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet. After 1 week 10 mice that received a low fat diet were given an IP leptin challenge and 10 mice of the low-fat group received placebo injections. The same procedure was performed with mice that were fed the high-fat diet. After 4 weeks the procedure was repeated. In total 80 mice were culled." ) |
---|
544 | exampleHumanStudy.save() |
---|
545 | |
---|
546 | def evLF = new Event( |
---|
547 | template: dietTreatmentTemplate, |
---|
548 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
549 | endTime: Date.parse('yyyy-MM-dd','2008-01-14') |
---|
550 | ) |
---|
551 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
552 | |
---|
553 | evLF.setFieldValue( 'Diet','10% fat (palm oil)' ) |
---|
554 | evLF.save(flush:true) |
---|
555 | |
---|
556 | println "Saved diet treatment" |
---|
557 | // TODO: find out why Diet is not set and Compound is |
---|
558 | |
---|
559 | def evHF = new Event( |
---|
560 | template: dietTreatmentTemplate, |
---|
561 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
562 | endTime: Date.parse('yyyy-MM-dd','2008-01-14') |
---|
563 | ) |
---|
564 | .setFieldValue( 'Diet','45% fat (palm oil)' ) |
---|
565 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
566 | |
---|
567 | def evBV = new Event( |
---|
568 | template: boostTreatmentTemplate, |
---|
569 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
570 | endTime: Date.parse('yyyy-MM-dd','2008-01-14') |
---|
571 | ) |
---|
572 | .setFieldValue( 'Compound','Vehicle' ) |
---|
573 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
574 | |
---|
575 | def evBL = new Event( |
---|
576 | template: boostTreatmentTemplate, |
---|
577 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
578 | endTime: Date.parse('yyyy-MM-dd','2008-01-14') |
---|
579 | ) |
---|
580 | .setFieldValue( 'Compound','Leptin' ) |
---|
581 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
582 | |
---|
583 | /* |
---|
584 | def evLF4 = new Event( |
---|
585 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
586 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
587 | eventDescription: eventDiet, |
---|
588 | parameterStringValues: ['Diet':'10% fat (palm oil)'] |
---|
589 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
590 | |
---|
591 | def evHF4 = new Event( |
---|
592 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
593 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
594 | eventDescription: eventDiet, |
---|
595 | parameterStringValues: ['Diet':'45% fat (palm oil)'] |
---|
596 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
597 | |
---|
598 | def evBV4 = new Event( |
---|
599 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
600 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
601 | eventDescription: eventBoost, |
---|
602 | parameterStringValues: ['Compound':'Vehicle'] |
---|
603 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
604 | |
---|
605 | def evBL4 = new Event( |
---|
606 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
607 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
608 | eventDescription: eventBoost, |
---|
609 | parameterStringValues: ['Compound':'Leptin'] |
---|
610 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
611 | |
---|
612 | def evS = new SamplingEvent( |
---|
613 | startTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
614 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
615 | eventDescription: samplingEvent, |
---|
616 | parameterFloatValues: ['Sample weight':5F] |
---|
617 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
618 | |
---|
619 | def evS4 = new SamplingEvent( |
---|
620 | startTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
621 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
622 | eventDescription: samplingEvent, |
---|
623 | parameterFloatValues: ['Sample weight':5F] |
---|
624 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
625 | */ |
---|
626 | |
---|
627 | // Add events to study |
---|
628 | exampleStudy |
---|
629 | .addToEvents(evLF) |
---|
630 | .addToEvents(evHF) |
---|
631 | .addToEvents(evBV) |
---|
632 | .addToEvents(evBL) |
---|
633 | /* |
---|
634 | .addToEvents(evLF4) |
---|
635 | .addToEvents(evHF4) |
---|
636 | .addToEvents(evBV4) |
---|
637 | .addToEvents(evBL4) |
---|
638 | .addToSamplingEvents(evS) |
---|
639 | .addToSamplingEvents(evS4) |
---|
640 | */ |
---|
641 | .save() |
---|
642 | |
---|
643 | def LFBV1 = new EventGroup(name:"10% fat + vehicle for 1 week") |
---|
644 | .addToEvents(evLF) |
---|
645 | .addToEvents(evBV) |
---|
646 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
647 | |
---|
648 | def LFBL1 = new EventGroup(name:"10% fat + leptin for 1 week") |
---|
649 | .addToEvents(evLF) |
---|
650 | .addToEvents(evBL) |
---|
651 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
652 | |
---|
653 | def HFBV1 = new EventGroup(name:"45% fat + vehicle for 1 week") |
---|
654 | .addToEvents(evHF) |
---|
655 | .addToEvents(evBV) |
---|
656 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
657 | |
---|
658 | def HFBL1 = new EventGroup(name:"45% fat + leptin for 1 week") |
---|
659 | .addToEvents(evHF) |
---|
660 | .addToEvents(evBL) |
---|
661 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
662 | |
---|
663 | /* |
---|
664 | def LFBV4 = new EventGroup(name:"10% fat + vehicle for 4 weeks") |
---|
665 | .addToEvents(evLF4) |
---|
666 | .addToEvents(evBV4) |
---|
667 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
668 | |
---|
669 | def LFBL4 = new EventGroup(name:"10% fat + leptin for 4 weeks") |
---|
670 | .addToEvents(evLF4) |
---|
671 | .addToEvents(evBL4) |
---|
672 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
673 | |
---|
674 | def HFBV4 = new EventGroup(name:"45% fat + vehicle for 4 weeks") |
---|
675 | .addToEvents(evHF4) |
---|
676 | .addToEvents(evBV4) |
---|
677 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
678 | |
---|
679 | def HFBL4 = new EventGroup(name:"45% fat + leptin for 4 weeks") |
---|
680 | .addToEvents(evHF4) |
---|
681 | .addToEvents(evBL4) |
---|
682 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
683 | */ |
---|
684 | |
---|
685 | // Add subjects and samples and compose EventGroups |
---|
686 | |
---|
687 | def x=1 |
---|
688 | 12.times { |
---|
689 | def currentSubject = new Subject( |
---|
690 | name: "A" + x++, |
---|
691 | species: mouseTerm, |
---|
692 | template: mouseTemplate, |
---|
693 | ) |
---|
694 | .setFieldValue("Gender", "Male") |
---|
695 | //.setFieldValue("Genotype", c57bl6Term) |
---|
696 | .setFieldValue("Age (weeks)", 17) |
---|
697 | .setFieldValue("Cage", "" + (int)(x/2)) |
---|
698 | .with { if (!validate()) { errors.each { println it} } else save(flush:true)} |
---|
699 | |
---|
700 | exampleStudy.addToSubjects(currentSubject) |
---|
701 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
702 | |
---|
703 | // Add subject to appropriate EventGroup |
---|
704 | /* |
---|
705 | if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } |
---|
706 | else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } |
---|
707 | else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() } |
---|
708 | else if (x > 40) { LFBV4.addToSubjects(currentSubject).save() } |
---|
709 | else if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } |
---|
710 | else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } |
---|
711 | else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } |
---|
712 | else { LFBV1.addToSubjects(currentSubject).save() } |
---|
713 | */ |
---|
714 | |
---|
715 | if (x > 9) { HFBL1.addToSubjects(currentSubject).save() } |
---|
716 | else if (x > 6) { HFBV1.addToSubjects(currentSubject).save() } |
---|
717 | else if (x > 3) { LFBL1.addToSubjects(currentSubject).save() } |
---|
718 | else { LFBV1.addToSubjects(currentSubject).save() } |
---|
719 | |
---|
720 | } |
---|
721 | |
---|
722 | // Also add some human subjects |
---|
723 | 2.times { |
---|
724 | def currentSubject = new Subject( |
---|
725 | name: "H" + x++, |
---|
726 | species: humanTerm, |
---|
727 | template: humanTemplate, |
---|
728 | ) |
---|
729 | .setFieldValue("Gender", "Male") |
---|
730 | //.setFieldValue("Genotype", c57bl6Term) |
---|
731 | .setFieldValue("Age (years)", 27) |
---|
732 | .setFieldValue("Height", 1.5) |
---|
733 | .with { if (!validate()) { errors.each { println it} } else save(flush:true)} |
---|
734 | |
---|
735 | exampleStudy.addToSubjects(currentSubject) |
---|
736 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
737 | |
---|
738 | // Add subject to appropriate EventGroup |
---|
739 | /* |
---|
740 | if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } |
---|
741 | else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } |
---|
742 | else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() } |
---|
743 | else if (x > 40) { LFBV4.addToSubjects(currentSubject).save() } |
---|
744 | else if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } |
---|
745 | else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } |
---|
746 | else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } |
---|
747 | else { LFBV1.addToSubjects(currentSubject).save() } |
---|
748 | */ |
---|
749 | |
---|
750 | if (x == 0) { HFBL1.addToSubjects(currentSubject).save() } |
---|
751 | else { LFBV1.addToSubjects(currentSubject).save() } |
---|
752 | |
---|
753 | } |
---|
754 | |
---|
755 | |
---|
756 | // Add EventGroups to study |
---|
757 | exampleStudy |
---|
758 | .addToEventGroups(LFBV1) |
---|
759 | .addToEventGroups(LFBL1) |
---|
760 | .addToEventGroups(HFBV1) |
---|
761 | .addToEventGroups(HFBL1) |
---|
762 | //.addToEventGroups(LFBV4) |
---|
763 | //.addToEventGroups(LFBL4) |
---|
764 | //.addToEventGroups(HFBV4) |
---|
765 | //.addToEventGroups(HFBL4) |
---|
766 | |
---|
767 | // Add persons to study |
---|
768 | def studyperson1 = new StudyPerson( person: person1, role: role1 ).save(); |
---|
769 | def studyperson2 = new StudyPerson( person: person2, role: role2 ).save(); |
---|
770 | |
---|
771 | exampleStudy |
---|
772 | .addToPersons( studyperson1 ) |
---|
773 | .addToPersons( studyperson2 ) |
---|
774 | .save() |
---|
775 | |
---|
776 | println 'Adding PPSH study' |
---|
777 | |
---|
778 | def humanStudy = new Study( |
---|
779 | template: studyTemplate, |
---|
780 | title:"NuGO PPS human study", |
---|
781 | code:"PPSH", |
---|
782 | researchQuestion:"How much are fasting plasma and urine metabolite levels affected by prolonged fasting ?", |
---|
783 | ecCode:"unknown", |
---|
784 | startDate: Date.parse('yyyy-MM-dd','2009-01-01') |
---|
785 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
786 | |
---|
787 | def fastingEvent = new Event( |
---|
788 | template: fastingTreatmentTemplate, |
---|
789 | startTime: Date.parse('yyyy-MM-dd','2008-01-14' ), |
---|
790 | endTime: Date.parse('yyyy-MM-dd','2008-01-14' ) |
---|
791 | ) |
---|
792 | .setFieldValue( 'Fasting period','8h' ) |
---|
793 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
794 | |
---|
795 | def bloodSamplingEvent = new SamplingEvent( |
---|
796 | template: bloodSamplingEventTemplate, |
---|
797 | startTime: Date.parse('yyyy-MM-dd','2008-01-14' ), |
---|
798 | endTime: Date.parse('yyyy-MM-dd','2008-01-14' ) |
---|
799 | ) |
---|
800 | .setFieldValue( 'Sample volume',4.5F ) |
---|
801 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
802 | |
---|
803 | def rootGroup = new EventGroup(name: 'Root group'); |
---|
804 | rootGroup.addToEvents fastingEvent |
---|
805 | rootGroup.addToEvents bloodSamplingEvent |
---|
806 | rootGroup.save() |
---|
807 | |
---|
808 | def y = 1 |
---|
809 | 11.times { |
---|
810 | def currentSubject = new Subject( |
---|
811 | name: "" + y++, |
---|
812 | species: humanTerm, |
---|
813 | template: humanTemplate).setFieldValue("Gender", (boolean) (x / 2) ? "Male" : "Female").setFieldValue("DOB", new java.text.SimpleDateFormat("dd-mm-yy").parse("01-02-19" + (10 + (int) (Math.random() * 80)))).setFieldValue("Age (years)", 30).setFieldValue("Height", Math.random() * 2F).setFieldValue("Weight (kg)", Math.random() * 150F).setFieldValue("BMI", 20 + Math.random() * 10F).with { if (!validate()) { errors.each { println it} } else save()} |
---|
814 | |
---|
815 | rootGroup.addToSubjects currentSubject |
---|
816 | rootGroup.save() |
---|
817 | |
---|
818 | def currentSample = new Sample( |
---|
819 | name: currentSubject.name + '_B', |
---|
820 | material: bloodTerm, |
---|
821 | parentSubject: currentSubject, |
---|
822 | parentEvent: bloodSamplingEvent); |
---|
823 | |
---|
824 | humanStudy.addToSubjects(currentSubject).addToSamples(currentSample).with { if (!validate()) { errors.each { println it} } else save()} |
---|
825 | } |
---|
826 | |
---|
827 | humanStudy.addToEvents(fastingEvent) |
---|
828 | humanStudy.addToSamplingEvents(bloodSamplingEvent) |
---|
829 | humanStudy.addToEventGroups rootGroup |
---|
830 | humanStudy.save() |
---|
831 | // Add clinical data |
---|
832 | |
---|
833 | def lipidAssay = new dbnp.clinicaldata.ClinicalAssay( |
---|
834 | name: 'Lipid profile', |
---|
835 | approved: true |
---|
836 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
837 | |
---|
838 | def ldlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( |
---|
839 | name: 'LDL', |
---|
840 | unit: 'mg/dL', |
---|
841 | type: dbnp.data.FeatureType.QUANTITATIVE, |
---|
842 | referenceValues: '100 mg/dL', |
---|
843 | detectableLimit: 250, |
---|
844 | isDrug: false, isIntake: true, inSerum: true |
---|
845 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
846 | |
---|
847 | def hdlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( |
---|
848 | name: 'HDL', |
---|
849 | unit: 'mg/dL', |
---|
850 | type: dbnp.data.FeatureType.QUANTITATIVE, |
---|
851 | referenceValues: '50 mg/dL', |
---|
852 | detectableLimit: 100, |
---|
853 | isDrug: false, isIntake: true, inSerum: true |
---|
854 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
855 | |
---|
856 | lipidAssay.addToMeasurements ldlMeasurement |
---|
857 | lipidAssay.addToMeasurements hdlMeasurement |
---|
858 | |
---|
859 | def lipidAssayInstance = new dbnp.clinicaldata.ClinicalAssayInstance( |
---|
860 | assay: lipidAssay |
---|
861 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
862 | |
---|
863 | humanStudy.samples*.each { |
---|
864 | new dbnp.clinicaldata.ClinicalFloatData( |
---|
865 | assay: lipidAssayInstance, |
---|
866 | measurement: ldlMeasurement, |
---|
867 | sample: it.name, |
---|
868 | value: Math.round(Math.random()*ldlMeasurement.detectableLimit) |
---|
869 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
870 | |
---|
871 | new dbnp.clinicaldata.ClinicalFloatData( |
---|
872 | assay: lipidAssayInstance, |
---|
873 | measurement: hdlMeasurement, |
---|
874 | sample: it.name, |
---|
875 | value: Math.round(Math.random()*hdlMeasurement.detectableLimit) |
---|
876 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
877 | } |
---|
878 | |
---|
879 | // Add assay to study capture module |
---|
880 | def clinicalModule = new AssayModule( |
---|
881 | name: 'Clinical data', |
---|
882 | type: AssayType.CLINICAL_DATA, |
---|
883 | platform: 'clinical measurements', |
---|
884 | url: 'http://localhost:8080/gscf' |
---|
885 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
886 | |
---|
887 | def lipidAssayRef = new Assay( |
---|
888 | name: 'Lipid profiling', |
---|
889 | module: clinicalModule, |
---|
890 | externalAssayId: lipidAssayInstance.id |
---|
891 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
892 | |
---|
893 | humanStudy.samples*.each { |
---|
894 | lipidAssayRef.addToSamples(it) |
---|
895 | } |
---|
896 | lipidAssayRef.save() |
---|
897 | |
---|
898 | humanStudy.addToAssays(lipidAssayRef); |
---|
899 | |
---|
900 | // Add some sample assay |
---|
901 | // Add assay to study capture module |
---|
902 | def dummyModule = new AssayModule( |
---|
903 | name: 'Dummy data', |
---|
904 | type: AssayType.CLINICAL_DATA, |
---|
905 | platform: 'other type of measurement platform', |
---|
906 | url: 'http://localhost:8080/gscf' |
---|
907 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
908 | |
---|
909 | def dummyAssayRef = new Assay( |
---|
910 | name: 'Test assay', |
---|
911 | module: dummyModule, |
---|
912 | externalAssayId: lipidAssayInstance.id |
---|
913 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
914 | |
---|
915 | humanStudy.addToAssays(dummyAssayRef); |
---|
916 | |
---|
917 | humanStudy.save() |
---|
918 | } |
---|
919 | } |
---|
920 | |
---|
921 | def destroy = { |
---|
922 | } |
---|
923 | } |
---|