1 | import org.codehaus.groovy.grails.commons.GrailsApplication |
---|
2 | import grails.util.GrailsUtil |
---|
3 | import dbnp.studycapturing.* |
---|
4 | |
---|
5 | import dbnp.data.Ontology |
---|
6 | import dbnp.data.Term |
---|
7 | import java.text.SimpleDateFormat |
---|
8 | |
---|
9 | /** |
---|
10 | * Application Bootstrapper |
---|
11 | * @Author Jeroen Wesbeek |
---|
12 | * @Since 20091021 |
---|
13 | * |
---|
14 | * Revision information: |
---|
15 | * $Rev: 232 $ |
---|
16 | * $Author: keesvb $ |
---|
17 | * $Date: 2010-03-03 16:18:22 +0000 (wo, 03 mrt 2010) $ |
---|
18 | */ |
---|
19 | class BootStrap { |
---|
20 | def init = {servletContext -> |
---|
21 | // define timezone |
---|
22 | System.setProperty('user.timezone', 'CET') |
---|
23 | |
---|
24 | if (GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT) { |
---|
25 | printf("development bootstrapping....\n\n"); |
---|
26 | |
---|
27 | // ontologies |
---|
28 | def speciesOntology = new Ontology( |
---|
29 | name: 'NCBI Taxonomy', |
---|
30 | shortName: 'Taxon', |
---|
31 | url: 'http://www.obofoundry.org/cgi-bin/detail.cgi?id=ncbi_taxonomy' |
---|
32 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
33 | |
---|
34 | def humanBodyOntology = new Ontology( |
---|
35 | name: 'Foundational Model of Anatomy', |
---|
36 | shortName: 'HumanBody', |
---|
37 | url: 'http://bioportal.bioontology.org/ontologies/39966' |
---|
38 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
39 | |
---|
40 | // terms |
---|
41 | def mouseTerm = new Term( |
---|
42 | name: 'Mus musculus', |
---|
43 | ontology: speciesOntology, |
---|
44 | accession: '10090' |
---|
45 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
46 | def humanTerm = new Term( |
---|
47 | name: 'Homo sapiens', |
---|
48 | ontology: speciesOntology, |
---|
49 | accession: '9606' |
---|
50 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
51 | |
---|
52 | def bloodTerm = new Term( |
---|
53 | name: 'Portion of blood', |
---|
54 | ontology: humanBodyOntology, |
---|
55 | accession: '9670' |
---|
56 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
57 | |
---|
58 | def madmaxOntology = new Ontology( |
---|
59 | name: 'Madmax ontology', |
---|
60 | shortName: 'MDMX', |
---|
61 | url: 'madmax.bioinformatics.nl' |
---|
62 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
63 | |
---|
64 | def treatmentTerm = new Term( |
---|
65 | name: 'ExperimentalProtocol', |
---|
66 | ontology: madmaxOntology, |
---|
67 | accession: 'P-MDMXGE-264' |
---|
68 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
69 | |
---|
70 | def dietProtocol = new Protocol( |
---|
71 | name: 'Diet treatment Protocol NuGO PPS3 leptin module', |
---|
72 | reference: treatmentTerm |
---|
73 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
74 | |
---|
75 | def boostProtocol = new Protocol( |
---|
76 | name: 'Boost treatment Protocol NuGO PPS3 leptin module', |
---|
77 | reference: treatmentTerm |
---|
78 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
79 | |
---|
80 | def fastingProtocol = new Protocol( |
---|
81 | name: 'Fasting', |
---|
82 | reference: treatmentTerm |
---|
83 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
84 | |
---|
85 | dietProtocol |
---|
86 | .addToParameters(new ProtocolParameter( |
---|
87 | name: 'Diet', |
---|
88 | type: ProtocolParameterType.STRINGLIST, |
---|
89 | listEntries: ['10% fat (palm oil)','45% fat (palm oil)'])) |
---|
90 | .save() |
---|
91 | |
---|
92 | boostProtocol |
---|
93 | .addToParameters(new ProtocolParameter( |
---|
94 | name: 'Compound', |
---|
95 | type: ProtocolParameterType.STRINGLIST, |
---|
96 | listEntries: ['Vehicle','Leptin'])) |
---|
97 | .save() |
---|
98 | |
---|
99 | fastingProtocol |
---|
100 | .addToParameters(new ProtocolParameter( |
---|
101 | name: 'Fasting period', |
---|
102 | type: ProtocolParameterType.STRING)) |
---|
103 | .save() |
---|
104 | |
---|
105 | // sampling event protocols |
---|
106 | |
---|
107 | def liverSamplingProtocol = new Protocol( |
---|
108 | name: 'Liver sampling' |
---|
109 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
110 | |
---|
111 | liverSamplingProtocol |
---|
112 | .addToParameters(new ProtocolParameter( |
---|
113 | name: 'Sample weight', |
---|
114 | unit: 'mg', |
---|
115 | type: ProtocolParameterType.FLOAT)) |
---|
116 | .save() |
---|
117 | |
---|
118 | def bloodSamplingProtocol = new Protocol( |
---|
119 | name: 'Liver sampling' |
---|
120 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
121 | |
---|
122 | bloodSamplingProtocol |
---|
123 | .addToParameters(new ProtocolParameter( |
---|
124 | name: 'Sample volume', |
---|
125 | unit: 'ml', |
---|
126 | type: ProtocolParameterType.FLOAT)) |
---|
127 | .save() |
---|
128 | |
---|
129 | // create system user |
---|
130 | |
---|
131 | /*def systemUser = userService.createUser(InstanceGenerator.user( |
---|
132 | username: 'system', |
---|
133 | pass: 'system', |
---|
134 | passConfirm: 'system', |
---|
135 | enabled: true |
---|
136 | ))*/ |
---|
137 | |
---|
138 | |
---|
139 | def genderField = new TemplateField( |
---|
140 | name: 'Gender',type: TemplateFieldType.STRINGLIST, |
---|
141 | listEntries: [new TemplateFieldListItem(name:'Male'),new TemplateFieldListItem(name: 'Female')]) |
---|
142 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
143 | |
---|
144 | def ageField = new TemplateField( |
---|
145 | name: 'Age',type: TemplateFieldType.INTEGER) |
---|
146 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
147 | |
---|
148 | // Nutritional study template |
---|
149 | |
---|
150 | def studyTemplate = new Template( |
---|
151 | name: 'Nutritional study', entity: dbnp.studycapturing.Study |
---|
152 | ).addToFields(new TemplateField( |
---|
153 | name: 'NuGO Code',type: TemplateFieldType.STRING) |
---|
154 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
155 | |
---|
156 | |
---|
157 | // Mouse template |
---|
158 | def mouseTemplate = new Template( |
---|
159 | name: 'Mouse', entity: dbnp.studycapturing.Subject |
---|
160 | ).addToFields(new TemplateField( |
---|
161 | name: 'Genotype',type: TemplateFieldType.STRINGLIST, |
---|
162 | listEntries: [new TemplateFieldListItem(name:'C57/Bl6j'),new TemplateFieldListItem(name:'wild type')])) |
---|
163 | .addToFields(genderField) |
---|
164 | .addToFields(ageField) |
---|
165 | .addToFields(new TemplateField( |
---|
166 | name: 'Cage',type: TemplateFieldType.INTEGER)) |
---|
167 | .addToFields(new TemplateField( |
---|
168 | name: 'Some double', type: TemplateFieldType.DOUBLE)) |
---|
169 | .addToFields(new TemplateField( |
---|
170 | name: 'Some ontology', type: TemplateFieldType.ONTOLOGYTERM)) |
---|
171 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
172 | |
---|
173 | // Human template |
---|
174 | def humanTemplate = new Template( |
---|
175 | name: 'Human', entity: dbnp.studycapturing.Subject) |
---|
176 | .addToFields(genderField) |
---|
177 | .addToFields(ageField) |
---|
178 | .addToFields(new TemplateField( |
---|
179 | name: 'DOB',type: TemplateFieldType.DATE)) |
---|
180 | .addToFields(new TemplateField( |
---|
181 | name: 'Height',type: TemplateFieldType.DOUBLE)) |
---|
182 | .addToFields(new TemplateField( |
---|
183 | name: 'Weight',type: TemplateFieldType.DOUBLE)) |
---|
184 | .addToFields(new TemplateField( |
---|
185 | name: 'BMI',type: TemplateFieldType.DOUBLE)) |
---|
186 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
187 | |
---|
188 | //events |
---|
189 | def eventDiet = new EventDescription( |
---|
190 | name: 'Diet treatment', |
---|
191 | description: 'Diet treatment (fat percentage)', |
---|
192 | classification: treatmentTerm, |
---|
193 | protocol: dietProtocol, |
---|
194 | isSamplingEvent: false |
---|
195 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
196 | |
---|
197 | def eventBoost = new EventDescription( |
---|
198 | name: 'Boost treatment', |
---|
199 | description: 'Boost treatment (leptin or vehicle)', |
---|
200 | classification: treatmentTerm, |
---|
201 | protocol: boostProtocol, |
---|
202 | isSamplingEvent: false |
---|
203 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
204 | |
---|
205 | def samplingEvent = new EventDescription( |
---|
206 | name: 'Liver extraction', |
---|
207 | description: 'Liver sampling for transcriptomics arrays', |
---|
208 | protocol: liverSamplingProtocol, |
---|
209 | isSamplingEvent: true |
---|
210 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
211 | |
---|
212 | def bloodSamplingEventDescription = new EventDescription( |
---|
213 | name: 'Blood extraction', |
---|
214 | description: 'Blood extraction targeted at lipid assays', |
---|
215 | protocol: bloodSamplingProtocol, |
---|
216 | isSamplingEvent: true |
---|
217 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
218 | |
---|
219 | |
---|
220 | def fastingTreatment = new EventDescription( |
---|
221 | name: 'Fasting treatment', |
---|
222 | description: 'Fasting Protocol NuGO PPSH', |
---|
223 | protocol: fastingProtocol, |
---|
224 | isSamplingEvent: false |
---|
225 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
226 | |
---|
227 | println('Adding PPS3 study...') |
---|
228 | |
---|
229 | // studies |
---|
230 | def exampleStudy = new Study( |
---|
231 | template: studyTemplate, |
---|
232 | title:"NuGO PPS3 mouse study leptin module", |
---|
233 | code:"PPS3_leptin_module", |
---|
234 | researchQuestion:"Leptin etc.", |
---|
235 | 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.", |
---|
236 | ecCode:"2007117.c", |
---|
237 | startDate: Date.parse('yyyy-MM-dd','2007-12-11') |
---|
238 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
239 | |
---|
240 | def evLF = new Event( |
---|
241 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
242 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
243 | eventDescription: eventDiet, |
---|
244 | parameterStringValues: ['Diet':'10% fat (palm oil)'] |
---|
245 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
246 | |
---|
247 | def evHF = new Event( |
---|
248 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
249 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
250 | eventDescription: eventDiet, |
---|
251 | parameterStringValues: ['Diet':'45% fat (palm oil)'] |
---|
252 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
253 | |
---|
254 | def evBV = new Event( |
---|
255 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
256 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
257 | eventDescription: eventBoost, |
---|
258 | parameterStringValues: ['Compound':'Vehicle'] |
---|
259 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
260 | |
---|
261 | def evBL = new Event( |
---|
262 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
263 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
264 | eventDescription: eventBoost, |
---|
265 | parameterStringValues: ['Compound':'Leptin'] |
---|
266 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
267 | |
---|
268 | def evLF4 = new Event( |
---|
269 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
270 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
271 | eventDescription: eventDiet, |
---|
272 | parameterStringValues: ['Diet':'10% fat (palm oil)'] |
---|
273 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
274 | |
---|
275 | def evHF4 = new Event( |
---|
276 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
277 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
278 | eventDescription: eventDiet, |
---|
279 | parameterStringValues: ['Diet':'45% fat (palm oil)'] |
---|
280 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
281 | |
---|
282 | def evBV4 = new Event( |
---|
283 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
284 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
285 | eventDescription: eventBoost, |
---|
286 | parameterStringValues: ['Compound':'Vehicle'] |
---|
287 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
288 | |
---|
289 | def evBL4 = new Event( |
---|
290 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
291 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
292 | eventDescription: eventBoost, |
---|
293 | parameterStringValues: ['Compound':'Leptin'] |
---|
294 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
295 | |
---|
296 | def evS = new SamplingEvent( |
---|
297 | startTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
298 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
299 | eventDescription: samplingEvent, |
---|
300 | parameterFloatValues: ['Sample weight':5F] |
---|
301 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
302 | |
---|
303 | def evS4 = new SamplingEvent( |
---|
304 | startTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
305 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
306 | eventDescription: samplingEvent, |
---|
307 | parameterFloatValues: ['Sample weight':5F] |
---|
308 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
309 | |
---|
310 | // Add events to study |
---|
311 | exampleStudy |
---|
312 | .addToEvents(evLF) |
---|
313 | .addToEvents(evHF) |
---|
314 | .addToEvents(evBV) |
---|
315 | .addToEvents(evBL) |
---|
316 | .addToEvents(evLF4) |
---|
317 | .addToEvents(evHF4) |
---|
318 | .addToEvents(evBV4) |
---|
319 | .addToEvents(evBL4) |
---|
320 | .addToSamplingEvents(evS) |
---|
321 | .addToSamplingEvents(evS4) |
---|
322 | .save() |
---|
323 | |
---|
324 | def LFBV1 = new EventGroup(name:"10% fat + vehicle for 1 week") |
---|
325 | .addToEvents(evLF) |
---|
326 | .addToEvents(evBV) |
---|
327 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
328 | |
---|
329 | def LFBL1 = new EventGroup(name:"10% fat + leptin for 1 week") |
---|
330 | .addToEvents(evLF) |
---|
331 | .addToEvents(evBL) |
---|
332 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
333 | |
---|
334 | def HFBV1 = new EventGroup(name:"45% fat + vehicle for 1 week") |
---|
335 | .addToEvents(evHF) |
---|
336 | .addToEvents(evBV) |
---|
337 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
338 | |
---|
339 | def HFBL1 = new EventGroup(name:"45% fat + leptin for 1 week") |
---|
340 | .addToEvents(evHF) |
---|
341 | .addToEvents(evBL) |
---|
342 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
343 | |
---|
344 | def LFBV4 = new EventGroup(name:"10% fat + vehicle for 4 weeks") |
---|
345 | .addToEvents(evLF4) |
---|
346 | .addToEvents(evBV4) |
---|
347 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
348 | |
---|
349 | def LFBL4 = new EventGroup(name:"10% fat + leptin for 4 weeks") |
---|
350 | .addToEvents(evLF4) |
---|
351 | .addToEvents(evBL4) |
---|
352 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
353 | |
---|
354 | def HFBV4 = new EventGroup(name:"45% fat + vehicle for 4 weeks") |
---|
355 | .addToEvents(evHF4) |
---|
356 | .addToEvents(evBV4) |
---|
357 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
358 | |
---|
359 | def HFBL4 = new EventGroup(name:"45% fat + leptin for 4 weeks") |
---|
360 | .addToEvents(evHF4) |
---|
361 | .addToEvents(evBL4) |
---|
362 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
363 | |
---|
364 | |
---|
365 | |
---|
366 | def x=1 |
---|
367 | 80.times { |
---|
368 | def currentSubject = new Subject( |
---|
369 | name: "A" + x++, |
---|
370 | species: mouseTerm, |
---|
371 | template: mouseTemplate, |
---|
372 | templateStringFields: ["Genotype" : "C57/Bl6j", "Gender" : "Male"], |
---|
373 | templateIntegerFields: ["Age" : 17, "Cage" : (int)(x/2)] |
---|
374 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
375 | |
---|
376 | exampleStudy.addToSubjects(currentSubject) |
---|
377 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
378 | |
---|
379 | // Add subject to appropriate EventGroup |
---|
380 | if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } |
---|
381 | else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } |
---|
382 | else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() } |
---|
383 | else if (x > 40) { LFBV4.addToSubjects(currentSubject).save() } |
---|
384 | else if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } |
---|
385 | else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } |
---|
386 | else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } |
---|
387 | else { LFBV1.addToSubjects(currentSubject).save() } |
---|
388 | |
---|
389 | } |
---|
390 | |
---|
391 | println 'Adding PPSH study' |
---|
392 | |
---|
393 | def humanStudy = new Study( |
---|
394 | template: studyTemplate, |
---|
395 | title:"NuGO PPS human study", |
---|
396 | code:"PPSH", |
---|
397 | researchQuestion:"How much are fasting plasma and urine metabolite levels affected by prolonged fasting ?", |
---|
398 | description:"Human study", |
---|
399 | ecCode:"unknown", |
---|
400 | startDate: Date.parse('yyyy-MM-dd','2009-01-01') |
---|
401 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
402 | |
---|
403 | def fastingEvent = new Event( |
---|
404 | startTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
405 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
406 | eventDescription: fastingTreatment, |
---|
407 | parameterStringValues: ['Fasting period':'8h']); |
---|
408 | |
---|
409 | def bloodSamplingEvent = new SamplingEvent( |
---|
410 | startTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
411 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
412 | eventDescription: bloodSamplingEventDescription, |
---|
413 | parameterFloatValues: ['Sample volume':4.5F]); |
---|
414 | |
---|
415 | def rootGroup = new EventGroup(name: 'Root group'); |
---|
416 | rootGroup.addToEvents fastingEvent |
---|
417 | rootGroup.addToEvents bloodSamplingEvent |
---|
418 | rootGroup.save() |
---|
419 | |
---|
420 | def y=1 |
---|
421 | 11.times { |
---|
422 | def currentSubject = new Subject( |
---|
423 | name: "" + y++, |
---|
424 | species: humanTerm, |
---|
425 | template: humanTemplate, |
---|
426 | templateStringFields: [ |
---|
427 | "Gender" : (boolean)(x/2) ? "Male" : "Female" |
---|
428 | ], |
---|
429 | templateDateFields: [ |
---|
430 | "DOB" : new java.text.SimpleDateFormat("dd-mm-yy").parse("01-02-19"+(10+(int)(Math.random()*80))) |
---|
431 | ], |
---|
432 | templateIntegerFields: [ |
---|
433 | "Age" : 30 |
---|
434 | ], |
---|
435 | templateDoubleFields: [ |
---|
436 | "Height" : Math.random()*2F, |
---|
437 | "Weight" : Math.random()*150F, |
---|
438 | "BMI" : 20 + Math.random()*10F |
---|
439 | ] |
---|
440 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
441 | |
---|
442 | def currentSample = new Sample( |
---|
443 | name: currentSubject.name + '_B', |
---|
444 | material: bloodTerm, |
---|
445 | parentSubject: currentSubject, |
---|
446 | parentEvent: bloodSamplingEvent); |
---|
447 | |
---|
448 | rootGroup.addToSubjects currentSubject |
---|
449 | rootGroup.save() |
---|
450 | |
---|
451 | humanStudy.addToSubjects(currentSubject) |
---|
452 | .addToSamples(currentSample) |
---|
453 | .addToEventGroups rootGroup |
---|
454 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
455 | } |
---|
456 | |
---|
457 | // new Study(title:"example",code:"Excode",researchQuestion:"ExRquestion",description:"Exdescription",ecCode:"ExecCode",dateCreated:new Date(),lastUpdated:new Date(),startDate:new Date()).save() |
---|
458 | // new Study(title:"testAgain",code:"testcode",researchQuestion:"testRquestion",description:"testdescription",ecCode:"testCode",dateCreated:new Date(),lastUpdated:new Date(),startDate:new Date()).save() |
---|
459 | // new Study(title:"Exampletest",code:"Examplecode",researchQuestion:"ExampleRquestion",description:"Exampledescription",ecCode:"ExampleecCode",dateCreated:new Date(),lastUpdated:new Date(),startDate:new Date()).save() |
---|
460 | |
---|
461 | // Add clinical data |
---|
462 | |
---|
463 | def lipidAssay = new dbnp.clinicaldata.ClinicalAssay( |
---|
464 | name: 'Lipid profile', |
---|
465 | approved: true |
---|
466 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
467 | |
---|
468 | def ldlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( |
---|
469 | name: 'LDL', |
---|
470 | unit: 'mg/dL', |
---|
471 | type: dbnp.data.FeatureType.QUANTITATIVE, |
---|
472 | referenceValues: '100 mg/dL', |
---|
473 | detectableLimit: 250, |
---|
474 | isDrug: false, isIntake: true, inSerum: true |
---|
475 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
476 | |
---|
477 | def hdlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( |
---|
478 | name: 'HDL', |
---|
479 | unit: 'mg/dL', |
---|
480 | type: dbnp.data.FeatureType.QUANTITATIVE, |
---|
481 | referenceValues: '50 mg/dL', |
---|
482 | detectableLimit: 100, |
---|
483 | isDrug: false, isIntake: true, inSerum: true |
---|
484 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
485 | |
---|
486 | lipidAssay.addToMeasurements ldlMeasurement |
---|
487 | lipidAssay.addToMeasurements hdlMeasurement |
---|
488 | |
---|
489 | def lipidAssayInstance = new dbnp.clinicaldata.ClinicalAssayInstance( |
---|
490 | assay: lipidAssay |
---|
491 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
492 | |
---|
493 | humanStudy.samples*.each { |
---|
494 | new dbnp.clinicaldata.ClinicalFloatData( |
---|
495 | assay: lipidAssayInstance, |
---|
496 | measurement: ldlMeasurement, |
---|
497 | sample: it.name, |
---|
498 | value: Math.round(Math.random()*ldlMeasurement.detectableLimit) |
---|
499 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
500 | |
---|
501 | new dbnp.clinicaldata.ClinicalFloatData( |
---|
502 | assay: lipidAssayInstance, |
---|
503 | measurement: hdlMeasurement, |
---|
504 | sample: it.name, |
---|
505 | value: Math.round(Math.random()*hdlMeasurement.detectableLimit) |
---|
506 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
507 | } |
---|
508 | |
---|
509 | // Add assay to study capture module |
---|
510 | |
---|
511 | def clinicalModule = new AssayModule( |
---|
512 | name: 'Clinical data', |
---|
513 | type: AssayType.CLINICAL_DATA, |
---|
514 | platform: 'clinical measurements', |
---|
515 | url: 'http://localhost:8080/gscf' |
---|
516 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
517 | |
---|
518 | def lipidAssayRef = new Assay( |
---|
519 | name: 'Lipid profiling', |
---|
520 | module: clinicalModule, |
---|
521 | externalAssayId: lipidAssayInstance.id |
---|
522 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
523 | |
---|
524 | humanStudy.samples*.each { |
---|
525 | lipidAssayRef.addToSamples(it) |
---|
526 | } |
---|
527 | lipidAssayRef.save() |
---|
528 | |
---|
529 | humanStudy.addToAssays(lipidAssayRef); |
---|
530 | humanStudy.save() |
---|
531 | |
---|
532 | } |
---|
533 | } |
---|
534 | |
---|
535 | def destroy = { |
---|
536 | } |
---|
537 | } |
---|