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: 367 $ |
---|
13 | * $Author: duh $ |
---|
14 | * $Date: 2010-04-21 15:26:21 +0000 (wo, 21 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 | |
---|
51 | /* COMMENTED OUT BECAUSE IT BREAKS EVERYTHING AFTER REFACTORING THE DATAMODEL |
---|
52 | |
---|
53 | // ontologies |
---|
54 | def speciesOntology = new Ontology( |
---|
55 | name: 'NCBI Taxonomy', |
---|
56 | shortName: 'Taxon', |
---|
57 | url: 'http://www.obofoundry.org/cgi-bin/detail.cgi?id=ncbi_taxonomy' |
---|
58 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
59 | |
---|
60 | def humanBodyOntology = new Ontology( |
---|
61 | name: 'Foundational Model of Anatomy', |
---|
62 | shortName: 'HumanBody', |
---|
63 | url: 'http://bioportal.bioontology.org/ontologies/39966' |
---|
64 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
65 | |
---|
66 | def nciOntology = new Ontology( |
---|
67 | name: 'NCI Thesaurus', |
---|
68 | shortName: 'NCI', |
---|
69 | url: 'http://bioportal.bioontology.org/ontologies/42331' |
---|
70 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
71 | |
---|
72 | // terms |
---|
73 | def mouseTerm = new Term( |
---|
74 | name: 'Mus musculus', |
---|
75 | ontology: speciesOntology, |
---|
76 | accession: '10090' |
---|
77 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
78 | def humanTerm = new Term( |
---|
79 | name: 'Homo sapiens', |
---|
80 | ontology: speciesOntology, |
---|
81 | accession: '9606' |
---|
82 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
83 | def arabTerm = new Term( |
---|
84 | name: 'Arabidopsis thaliana', |
---|
85 | ontology: speciesOntology, |
---|
86 | accession: '3702' |
---|
87 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
88 | |
---|
89 | def bloodTerm = new Term( |
---|
90 | name: 'Portion of blood', |
---|
91 | ontology: humanBodyOntology, |
---|
92 | accession: '9670' |
---|
93 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
94 | |
---|
95 | def c57bl6Term = new Term( |
---|
96 | name: 'C57BL/6 Mouse', |
---|
97 | ontology: nciOntology, |
---|
98 | accession: 'C14424' |
---|
99 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
100 | |
---|
101 | def madmaxOntology = new Ontology( |
---|
102 | name: 'Madmax ontology', |
---|
103 | shortName: 'MDMX', |
---|
104 | url: 'madmax.bioinformatics.nl' |
---|
105 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
106 | |
---|
107 | def treatmentTerm = new Term( |
---|
108 | name: 'ExperimentalProtocol', |
---|
109 | ontology: madmaxOntology, |
---|
110 | accession: 'P-MDMXGE-264' |
---|
111 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
112 | |
---|
113 | def dietProtocol = new Protocol( |
---|
114 | name: 'Diet treatment Protocol NuGO PPS3 leptin module', |
---|
115 | reference: treatmentTerm |
---|
116 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
117 | |
---|
118 | def boostProtocol = new Protocol( |
---|
119 | name: 'Boost treatment Protocol NuGO PPS3 leptin module', |
---|
120 | reference: treatmentTerm |
---|
121 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
122 | |
---|
123 | def fastingProtocol = new Protocol( |
---|
124 | name: 'Fasting', |
---|
125 | reference: treatmentTerm |
---|
126 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
127 | |
---|
128 | |
---|
129 | // ParameterStringListItems |
---|
130 | def oil10= new ParameterStringListItem( |
---|
131 | name: '10% fat (palm oil)' |
---|
132 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
133 | def oil45= new ParameterStringListItem( |
---|
134 | name: '45% fat (palm oil)' |
---|
135 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
136 | def vehicle= new ParameterStringListItem( |
---|
137 | name: 'Vehicle' |
---|
138 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
139 | def leptin= new ParameterStringListItem( |
---|
140 | name: 'Leptin' |
---|
141 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
142 | |
---|
143 | |
---|
144 | dietProtocol |
---|
145 | .addToParameters(new ProtocolParameter( |
---|
146 | name: 'Diet', |
---|
147 | type: ProtocolParameterType.STRINGLIST, |
---|
148 | listEntries: [oil10,oil45])) |
---|
149 | .save() |
---|
150 | |
---|
151 | boostProtocol |
---|
152 | .addToParameters(new ProtocolParameter( |
---|
153 | name: 'Compound', |
---|
154 | type: ProtocolParameterType.STRINGLIST, |
---|
155 | listEntries: [vehicle,leptin])) |
---|
156 | .save() |
---|
157 | |
---|
158 | fastingProtocol |
---|
159 | .addToParameters(new ProtocolParameter( |
---|
160 | name: 'Fasting period', |
---|
161 | type: ProtocolParameterType.STRING)) |
---|
162 | .save() |
---|
163 | |
---|
164 | |
---|
165 | // sampling event protocols |
---|
166 | |
---|
167 | def liverSamplingProtocol = new Protocol( |
---|
168 | name: 'Liver sampling' |
---|
169 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
170 | |
---|
171 | liverSamplingProtocol |
---|
172 | .addToParameters(new ProtocolParameter( |
---|
173 | name: 'Sample weight', |
---|
174 | unit: 'mg', |
---|
175 | type: ProtocolParameterType.FLOAT)) |
---|
176 | .save() |
---|
177 | |
---|
178 | def bloodSamplingProtocol = new Protocol( |
---|
179 | name: 'Blood sampling' |
---|
180 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
181 | |
---|
182 | bloodSamplingProtocol |
---|
183 | .addToParameters(new ProtocolParameter( |
---|
184 | name: 'Sample volume', |
---|
185 | unit: 'ml', |
---|
186 | type: ProtocolParameterType.FLOAT)) |
---|
187 | .save() |
---|
188 | */ |
---|
189 | // create system user |
---|
190 | |
---|
191 | /*def systemUser = userService.createUser(InstanceGenerator.user( |
---|
192 | username: 'system', |
---|
193 | pass: 'system', |
---|
194 | passConfirm: 'system', |
---|
195 | enabled: true |
---|
196 | ))*/ |
---|
197 | |
---|
198 | |
---|
199 | def genderField = new TemplateField( |
---|
200 | name: 'Gender',type: TemplateFieldType.STRINGLIST, |
---|
201 | listEntries: [new TemplateFieldListItem(name:'Male'),new TemplateFieldListItem(name: 'Female')]) |
---|
202 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
203 | |
---|
204 | def ageField = new TemplateField( |
---|
205 | name: 'Age (years)',type: TemplateFieldType.INTEGER,unit: 'years') |
---|
206 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
207 | |
---|
208 | def genotypeField = new TemplateField( |
---|
209 | name: 'Genotype', type: TemplateFieldType.ONTOLOGYTERM) |
---|
210 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
211 | |
---|
212 | def genotypeTypeField = new TemplateField( |
---|
213 | name: 'Genotype type',type: TemplateFieldType.STRINGLIST, |
---|
214 | listEntries: [new TemplateFieldListItem(name:'transgenic'), |
---|
215 | new TemplateFieldListItem(name:'knock-out'), |
---|
216 | new TemplateFieldListItem(name:'knock-in')]) |
---|
217 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
218 | |
---|
219 | |
---|
220 | // Nutritional study template |
---|
221 | |
---|
222 | println ".adding academic study template..." |
---|
223 | def studyTemplate = new Template( |
---|
224 | name: 'Academic study', entity: dbnp.studycapturing.Study) |
---|
225 | .addToFields(new TemplateField(name: 'Description',type: TemplateFieldType.TEXT)) |
---|
226 | .addToFields(new TemplateField(name: 'Study code',type: TemplateFieldType.STRING)) |
---|
227 | .addToFields(new TemplateField(name: 'Objectives',type: TemplateFieldType.TEXT)) |
---|
228 | .addToFields(new TemplateField(name: 'Consortium',type: TemplateFieldType.STRING)) |
---|
229 | .addToFields(new TemplateField(name: 'Cohort name',type: TemplateFieldType.STRING)) |
---|
230 | .addToFields(new TemplateField(name: 'Time zone',type: TemplateFieldType.STRING)) |
---|
231 | .addToFields(new TemplateField(name: 'Responsible scientist',type: TemplateFieldType.STRING)) |
---|
232 | .addToFields(new TemplateField(name: 'Lab id',type: TemplateFieldType.STRING)) |
---|
233 | .addToFields(new TemplateField(name: 'Institute',type: TemplateFieldType.STRING)) |
---|
234 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
235 | |
---|
236 | // Mouse template |
---|
237 | println ".adding mouse subject template..." |
---|
238 | def mouseTemplate = new Template( |
---|
239 | name: 'Mouse', entity: dbnp.studycapturing.Subject) |
---|
240 | .addToFields(new TemplateField( |
---|
241 | name: 'Strain', type: TemplateFieldType.ONTOLOGYTERM)) |
---|
242 | .addToFields(genotypeField) |
---|
243 | .addToFields(genotypeTypeField) |
---|
244 | .addToFields(genderField) |
---|
245 | .addToFields(new TemplateField( |
---|
246 | name: 'Age (weeks)', type: TemplateFieldType.INTEGER, unit: 'weeks')) |
---|
247 | .addToFields(new TemplateField( |
---|
248 | name: 'Age type',type: TemplateFieldType.STRINGLIST, |
---|
249 | listEntries: [new TemplateFieldListItem(name:'postnatal'),new TemplateFieldListItem(name:'embryonal')])) |
---|
250 | .addToFields(new TemplateField( |
---|
251 | name: 'Cage',type: TemplateFieldType.STRING)) |
---|
252 | .addToFields(new TemplateField( |
---|
253 | name: '#Mice in cage',type: TemplateFieldType.INTEGER)) |
---|
254 | .addToFields(new TemplateField( |
---|
255 | name: 'Litter size',type: TemplateFieldType.INTEGER)) |
---|
256 | .addToFields(new TemplateField( |
---|
257 | name: 'Weight (g)', type: TemplateFieldType.DOUBLE, unit: 'gram')) |
---|
258 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
259 | |
---|
260 | // Human template |
---|
261 | println ".adding human subject template..." |
---|
262 | def humanTemplate = new Template( |
---|
263 | name: 'Human', entity: dbnp.studycapturing.Subject) |
---|
264 | .addToFields(genderField) |
---|
265 | .addToFields(ageField) |
---|
266 | .addToFields(new TemplateField( |
---|
267 | name: 'DOB',type: TemplateFieldType.DATE)) |
---|
268 | .addToFields(new TemplateField( |
---|
269 | name: 'Height',type: TemplateFieldType.DOUBLE, unit: 'm')) |
---|
270 | .addToFields(new TemplateField( |
---|
271 | name: 'Weight (kg)',type: TemplateFieldType.DOUBLE, unit: 'kg')) |
---|
272 | .addToFields(new TemplateField( |
---|
273 | name: 'BMI',type: TemplateFieldType.DOUBLE, unit: 'kg/m2')) |
---|
274 | .addToFields(new TemplateField( |
---|
275 | name: 'Race',type: TemplateFieldType.STRING)) |
---|
276 | .addToFields(new TemplateField( |
---|
277 | name: 'Waist circumference',type: TemplateFieldType.FLOAT, unit: 'cm')) |
---|
278 | .addToFields(new TemplateField( |
---|
279 | name: 'Hip circumference',type: TemplateFieldType.FLOAT, unit: 'cm')) |
---|
280 | .addToFields(new TemplateField( |
---|
281 | name: 'Systolic blood pressure',type: TemplateFieldType.FLOAT, unit: 'mmHg')) |
---|
282 | .addToFields(new TemplateField( |
---|
283 | name: 'Diastolic blood pressure',type: TemplateFieldType.FLOAT, unit: 'mmHg')) |
---|
284 | .addToFields(new TemplateField( |
---|
285 | name: 'Heart rate',type: TemplateFieldType.FLOAT, unit: 'beats/min')) |
---|
286 | .addToFields(new TemplateField( |
---|
287 | name: 'Run-in-food',type: TemplateFieldType.TEXT)) |
---|
288 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
289 | |
---|
290 | |
---|
291 | def sampleDescriptionField = new TemplateField( |
---|
292 | name: 'Description',type: TemplateFieldType.TEXT) |
---|
293 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
294 | def sampleTypeField = new TemplateField( |
---|
295 | name: 'SampleType',type: TemplateFieldType.STRING) |
---|
296 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
297 | def sampleProtocolField = new TemplateField( |
---|
298 | name: 'SampleProtocol',type: TemplateFieldType.STRING) |
---|
299 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
300 | def sampleVialTextField = new TemplateField( |
---|
301 | name: 'Text on vial',type: TemplateFieldType.STRING) |
---|
302 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
303 | |
---|
304 | // Human sample template |
---|
305 | /* COMMENTED OUT AS IT BREAKS THE WHOLE LOT |
---|
306 | def humanSampleTemplate = new Template( |
---|
307 | name: 'Human tissue sample', entity: dbnp.studycapturing.Sample) |
---|
308 | .addToFields(sampleDescriptionField) |
---|
309 | .addToFields(sampleTypeField) |
---|
310 | .addToFields(sampleProtocolField) |
---|
311 | .addToFields(sampleVialTextField) |
---|
312 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
313 | |
---|
314 | //Plant template |
---|
315 | def plantTemplate = new Template( |
---|
316 | name: 'Plant template', entity: dbnp.studycapturing.Subject) |
---|
317 | .addToFields(new TemplateField( |
---|
318 | name: 'Variety', type: TemplateFieldType.STRING)) |
---|
319 | .addToFields(new TemplateField( |
---|
320 | name: 'Ecotype', type: TemplateFieldType.STRING)) |
---|
321 | .addToFields(genotypeField) |
---|
322 | .addToFields(genotypeTypeField) |
---|
323 | .addToFields(new TemplateField( |
---|
324 | name: 'Growth location', type: TemplateFieldType.STRINGLIST, |
---|
325 | listEntries: [new TemplateFieldListItem(name:'Greenhouse'),new TemplateFieldListItem(name: 'Field')])) |
---|
326 | .addToFields(new TemplateField( |
---|
327 | name: 'Room', type: TemplateFieldType.STRING, |
---|
328 | comment: 'Chamber number in case of Greenhouse')) |
---|
329 | .addToFields(new TemplateField( |
---|
330 | name: 'Position X', type: TemplateFieldType.FLOAT)) |
---|
331 | .addToFields(new TemplateField( |
---|
332 | name: 'Position Y', type: TemplateFieldType.FLOAT)) |
---|
333 | .addToFields(new TemplateField( |
---|
334 | name: 'Block', type: TemplateFieldType.STRING)) |
---|
335 | .addToFields(new TemplateField( |
---|
336 | name: 'Temperature at day', type: TemplateFieldType.FLOAT)) |
---|
337 | .addToFields(new TemplateField( |
---|
338 | name: 'Temperature at night', type: TemplateFieldType.FLOAT)) |
---|
339 | .addToFields(new TemplateField( |
---|
340 | name: 'Photo period', type: TemplateFieldType.STRING)) |
---|
341 | .addToFields(new TemplateField( |
---|
342 | name: 'Light intensity', type: TemplateFieldType.STRING)) |
---|
343 | .addToFields(new TemplateField( |
---|
344 | name: 'Start date', type: TemplateFieldType.DATE)) |
---|
345 | .addToFields(new TemplateField( |
---|
346 | name: 'Harvest date', type: TemplateFieldType.DATE)) |
---|
347 | .addToFields(new TemplateField( |
---|
348 | name: 'Growth type', type: TemplateFieldType.STRINGLIST, |
---|
349 | listEntries: [new TemplateFieldListItem(name:'Standard'),new TemplateFieldListItem(name: 'Experimental')])) |
---|
350 | .addToFields(new TemplateField( |
---|
351 | name: 'Growth protocol', type: TemplateFieldType.TEXT)) |
---|
352 | .addToFields(new TemplateField( |
---|
353 | name: 'Harvest delay', type: TemplateFieldType.TEXT)) |
---|
354 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
355 | |
---|
356 | def plantSampleTemplate = new Template( |
---|
357 | name: 'Plant sample', entity: dbnp.studycapturing.Sample) |
---|
358 | .addToFields(sampleDescriptionField) |
---|
359 | .addToFields(sampleTypeField) |
---|
360 | .addToFields(sampleProtocolField) |
---|
361 | .addToFields(sampleVialTextField) |
---|
362 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
363 | |
---|
364 | |
---|
365 | //events |
---|
366 | def eventDiet = new EventDescription( |
---|
367 | name: 'Diet treatment', |
---|
368 | description: 'Diet treatment (fat percentage)', |
---|
369 | classification: treatmentTerm, |
---|
370 | protocol: dietProtocol, |
---|
371 | isSamplingEvent: false |
---|
372 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
373 | |
---|
374 | def eventBoost = new EventDescription( |
---|
375 | name: 'Boost treatment', |
---|
376 | description: 'Boost treatment (leptin or vehicle)', |
---|
377 | classification: treatmentTerm, |
---|
378 | protocol: boostProtocol, |
---|
379 | isSamplingEvent: false |
---|
380 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
381 | |
---|
382 | def samplingEvent = new EventDescription( |
---|
383 | name: 'Liver extraction', |
---|
384 | description: 'Liver sampling for transcriptomics arrays', |
---|
385 | protocol: liverSamplingProtocol, |
---|
386 | isSamplingEvent: true |
---|
387 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
388 | |
---|
389 | def bloodSamplingEventDescription = new EventDescription( |
---|
390 | name: 'Blood extraction', |
---|
391 | description: 'Blood extraction targeted at lipid assays', |
---|
392 | protocol: bloodSamplingProtocol, |
---|
393 | isSamplingEvent: true |
---|
394 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
395 | |
---|
396 | |
---|
397 | def fastingTreatment = new EventDescription( |
---|
398 | name: 'Fasting treatment', |
---|
399 | description: 'Fasting Protocol NuGO PPSH', |
---|
400 | protocol: fastingProtocol, |
---|
401 | isSamplingEvent: false |
---|
402 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
403 | |
---|
404 | println('Adding PPS3 study...') |
---|
405 | |
---|
406 | // studies |
---|
407 | def exampleStudy = new Study( |
---|
408 | template: studyTemplate, |
---|
409 | title:"NuGO PPS3 mouse study leptin module", |
---|
410 | code:"PPS3_leptin_module", |
---|
411 | researchQuestion:"Leptin etc.", |
---|
412 | 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.", |
---|
413 | ecCode:"2007117.c", |
---|
414 | startDate: Date.parse('yyyy-MM-dd','2007-12-11') |
---|
415 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
416 | |
---|
417 | def exampleHumanStudy = new Study( |
---|
418 | template: humanTemplate, |
---|
419 | title:"Human example template", |
---|
420 | code:"Human example code", |
---|
421 | researchQuestion:"Leptin etc.", |
---|
422 | 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.", |
---|
423 | ecCode:"2007117.c", |
---|
424 | startDate: Date.parse('yyyy-MM-dd','2007-12-11') |
---|
425 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
426 | |
---|
427 | def evLF = new Event( |
---|
428 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
429 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
430 | eventDescription: eventDiet, |
---|
431 | parameterStringValues: ['Diet':'10% fat (palm oil)'] |
---|
432 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
433 | |
---|
434 | def evHF = new Event( |
---|
435 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
436 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
437 | eventDescription: eventDiet, |
---|
438 | parameterStringValues: ['Diet':'45% fat (palm oil)'] |
---|
439 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
440 | |
---|
441 | def evBV = new Event( |
---|
442 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
443 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
444 | eventDescription: eventBoost, |
---|
445 | parameterStringValues: ['Compound':'Vehicle'] |
---|
446 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
447 | |
---|
448 | def evBL = new Event( |
---|
449 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
450 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
451 | eventDescription: eventBoost, |
---|
452 | parameterStringValues: ['Compound':'Leptin'] |
---|
453 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
454 | |
---|
455 | def evLF4 = new Event( |
---|
456 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
457 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
458 | eventDescription: eventDiet, |
---|
459 | parameterStringValues: ['Diet':'10% fat (palm oil)'] |
---|
460 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
461 | |
---|
462 | def evHF4 = new Event( |
---|
463 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
464 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
465 | eventDescription: eventDiet, |
---|
466 | parameterStringValues: ['Diet':'45% fat (palm oil)'] |
---|
467 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
468 | |
---|
469 | def evBV4 = new Event( |
---|
470 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
471 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
472 | eventDescription: eventBoost, |
---|
473 | parameterStringValues: ['Compound':'Vehicle'] |
---|
474 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
475 | |
---|
476 | def evBL4 = new Event( |
---|
477 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
478 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
479 | eventDescription: eventBoost, |
---|
480 | parameterStringValues: ['Compound':'Leptin'] |
---|
481 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
482 | |
---|
483 | def evS = new SamplingEvent( |
---|
484 | startTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
485 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
486 | eventDescription: samplingEvent, |
---|
487 | parameterFloatValues: ['Sample weight':5F] |
---|
488 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
489 | |
---|
490 | def evS4 = new SamplingEvent( |
---|
491 | startTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
492 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
493 | eventDescription: samplingEvent, |
---|
494 | parameterFloatValues: ['Sample weight':5F] |
---|
495 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
496 | |
---|
497 | // Add events to study |
---|
498 | exampleStudy |
---|
499 | .addToEvents(evLF) |
---|
500 | .addToEvents(evHF) |
---|
501 | .addToEvents(evBV) |
---|
502 | .addToEvents(evBL) |
---|
503 | .addToEvents(evLF4) |
---|
504 | .addToEvents(evHF4) |
---|
505 | .addToEvents(evBV4) |
---|
506 | .addToEvents(evBL4) |
---|
507 | .addToSamplingEvents(evS) |
---|
508 | .addToSamplingEvents(evS4) |
---|
509 | .save() |
---|
510 | |
---|
511 | def LFBV1 = new EventGroup(name:"10% fat + vehicle for 1 week") |
---|
512 | .addToEvents(evLF) |
---|
513 | .addToEvents(evBV) |
---|
514 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
515 | |
---|
516 | def LFBL1 = new EventGroup(name:"10% fat + leptin for 1 week") |
---|
517 | .addToEvents(evLF) |
---|
518 | .addToEvents(evBL) |
---|
519 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
520 | |
---|
521 | def HFBV1 = new EventGroup(name:"45% fat + vehicle for 1 week") |
---|
522 | .addToEvents(evHF) |
---|
523 | .addToEvents(evBV) |
---|
524 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
525 | |
---|
526 | def HFBL1 = new EventGroup(name:"45% fat + leptin for 1 week") |
---|
527 | .addToEvents(evHF) |
---|
528 | .addToEvents(evBL) |
---|
529 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
530 | |
---|
531 | def LFBV4 = new EventGroup(name:"10% fat + vehicle for 4 weeks") |
---|
532 | .addToEvents(evLF4) |
---|
533 | .addToEvents(evBV4) |
---|
534 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
535 | |
---|
536 | def LFBL4 = new EventGroup(name:"10% fat + leptin for 4 weeks") |
---|
537 | .addToEvents(evLF4) |
---|
538 | .addToEvents(evBL4) |
---|
539 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
540 | |
---|
541 | def HFBV4 = new EventGroup(name:"45% fat + vehicle for 4 weeks") |
---|
542 | .addToEvents(evHF4) |
---|
543 | .addToEvents(evBV4) |
---|
544 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
545 | |
---|
546 | def HFBL4 = new EventGroup(name:"45% fat + leptin for 4 weeks") |
---|
547 | .addToEvents(evHF4) |
---|
548 | .addToEvents(evBL4) |
---|
549 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
550 | |
---|
551 | // Add subjects and samples and compose EventGroups |
---|
552 | |
---|
553 | def x=1 |
---|
554 | 80.times { |
---|
555 | def currentSubject = new Subject( |
---|
556 | name: "A" + x++, |
---|
557 | species: mouseTerm, |
---|
558 | template: mouseTemplate, |
---|
559 | ) |
---|
560 | .setFieldValue("Gender", "Male") |
---|
561 | .setFieldValue("Genotype", c57bl6Term) |
---|
562 | .setFieldValue("Age (weeks)", 17) |
---|
563 | .setFieldValue("Cage", "" + (int)(x/2)) |
---|
564 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
565 | |
---|
566 | exampleStudy.addToSubjects(currentSubject) |
---|
567 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
568 | |
---|
569 | // Add subject to appropriate EventGroup |
---|
570 | if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } |
---|
571 | else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } |
---|
572 | else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() } |
---|
573 | else if (x > 40) { LFBV4.addToSubjects(currentSubject).save() } |
---|
574 | else if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } |
---|
575 | else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } |
---|
576 | else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } |
---|
577 | else { LFBV1.addToSubjects(currentSubject).save() } |
---|
578 | |
---|
579 | } |
---|
580 | |
---|
581 | // Add EventGroups to study |
---|
582 | exampleStudy |
---|
583 | .addToEventGroups(LFBV1) |
---|
584 | .addToEventGroups(LFBL1) |
---|
585 | .addToEventGroups(HFBV1) |
---|
586 | .addToEventGroups(HFBL1) |
---|
587 | .addToEventGroups(LFBV4) |
---|
588 | .addToEventGroups(LFBL4) |
---|
589 | .addToEventGroups(HFBV4) |
---|
590 | .addToEventGroups(HFBL4) |
---|
591 | .save() |
---|
592 | |
---|
593 | println 'Adding PPSH study' |
---|
594 | |
---|
595 | def humanStudy = new Study( |
---|
596 | template: studyTemplate, |
---|
597 | title:"NuGO PPS human study", |
---|
598 | code:"PPSH", |
---|
599 | researchQuestion:"How much are fasting plasma and urine metabolite levels affected by prolonged fasting ?", |
---|
600 | description:"Human study", |
---|
601 | ecCode:"unknown", |
---|
602 | startDate: Date.parse('yyyy-MM-dd','2009-01-01') |
---|
603 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
604 | |
---|
605 | def fastingEvent = new Event( |
---|
606 | startTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
607 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
608 | eventDescription: fastingTreatment, |
---|
609 | parameterStringValues: ['Fasting period':'8h']); |
---|
610 | |
---|
611 | def bloodSamplingEvent = new SamplingEvent( |
---|
612 | startTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
613 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
614 | eventDescription: bloodSamplingEventDescription, |
---|
615 | parameterFloatValues: ['Sample volume':4.5F]); |
---|
616 | |
---|
617 | def rootGroup = new EventGroup(name: 'Root group'); |
---|
618 | rootGroup.addToEvents fastingEvent |
---|
619 | rootGroup.addToEvents bloodSamplingEvent |
---|
620 | rootGroup.save() |
---|
621 | |
---|
622 | def y = 1 |
---|
623 | 11.times { |
---|
624 | def currentSubject = new Subject( |
---|
625 | name: "" + y++, |
---|
626 | species: humanTerm, |
---|
627 | 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()} |
---|
628 | |
---|
629 | rootGroup.addToSubjects currentSubject |
---|
630 | rootGroup.save() |
---|
631 | |
---|
632 | def currentSample = new Sample( |
---|
633 | name: currentSubject.name + '_B', |
---|
634 | material: bloodTerm, |
---|
635 | parentSubject: currentSubject, |
---|
636 | parentEvent: bloodSamplingEvent); |
---|
637 | |
---|
638 | |
---|
639 | humanStudy.addToSubjects(currentSubject).addToSamples(currentSample).with { if (!validate()) { errors.each { println it} } else save()} |
---|
640 | } |
---|
641 | |
---|
642 | humanStudy.addToEvents(fastingEvent) |
---|
643 | humanStudy.addToSamplingEvents(bloodSamplingEvent) |
---|
644 | humanStudy.addToEventGroups rootGroup |
---|
645 | humanStudy.save() |
---|
646 | |
---|
647 | // Add clinical data |
---|
648 | |
---|
649 | def lipidAssay = new dbnp.clinicaldata.ClinicalAssay( |
---|
650 | name: 'Lipid profile', |
---|
651 | approved: true |
---|
652 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
653 | |
---|
654 | def ldlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( |
---|
655 | name: 'LDL', |
---|
656 | unit: 'mg/dL', |
---|
657 | type: dbnp.data.FeatureType.QUANTITATIVE, |
---|
658 | referenceValues: '100 mg/dL', |
---|
659 | detectableLimit: 250, |
---|
660 | isDrug: false, isIntake: true, inSerum: true |
---|
661 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
662 | |
---|
663 | def hdlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( |
---|
664 | name: 'HDL', |
---|
665 | unit: 'mg/dL', |
---|
666 | type: dbnp.data.FeatureType.QUANTITATIVE, |
---|
667 | referenceValues: '50 mg/dL', |
---|
668 | detectableLimit: 100, |
---|
669 | isDrug: false, isIntake: true, inSerum: true |
---|
670 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
671 | |
---|
672 | lipidAssay.addToMeasurements ldlMeasurement |
---|
673 | lipidAssay.addToMeasurements hdlMeasurement |
---|
674 | |
---|
675 | def lipidAssayInstance = new dbnp.clinicaldata.ClinicalAssayInstance( |
---|
676 | assay: lipidAssay |
---|
677 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
678 | |
---|
679 | humanStudy.samples*.each { |
---|
680 | new dbnp.clinicaldata.ClinicalFloatData( |
---|
681 | assay: lipidAssayInstance, |
---|
682 | measurement: ldlMeasurement, |
---|
683 | sample: it.name, |
---|
684 | value: Math.round(Math.random()*ldlMeasurement.detectableLimit) |
---|
685 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
686 | |
---|
687 | new dbnp.clinicaldata.ClinicalFloatData( |
---|
688 | assay: lipidAssayInstance, |
---|
689 | measurement: hdlMeasurement, |
---|
690 | sample: it.name, |
---|
691 | value: Math.round(Math.random()*hdlMeasurement.detectableLimit) |
---|
692 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
693 | } |
---|
694 | |
---|
695 | // Add assay to study capture module |
---|
696 | |
---|
697 | def clinicalModule = new AssayModule( |
---|
698 | name: 'Clinical data', |
---|
699 | type: AssayType.CLINICAL_DATA, |
---|
700 | platform: 'clinical measurements', |
---|
701 | url: 'http://localhost:8080/gscf' |
---|
702 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
703 | |
---|
704 | def lipidAssayRef = new Assay( |
---|
705 | name: 'Lipid profiling', |
---|
706 | module: clinicalModule, |
---|
707 | externalAssayId: lipidAssayInstance.id |
---|
708 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
709 | |
---|
710 | humanStudy.samples*.each { |
---|
711 | lipidAssayRef.addToSamples(it) |
---|
712 | } |
---|
713 | lipidAssayRef.save() |
---|
714 | |
---|
715 | humanStudy.addToAssays(lipidAssayRef); |
---|
716 | humanStudy.save() |
---|
717 | */ |
---|
718 | } |
---|
719 | } |
---|
720 | |
---|
721 | def destroy = { |
---|
722 | } |
---|
723 | } |
---|