1 | /** |
---|
2 | * @Author kees |
---|
3 | * @Since Jun 25, 2010 |
---|
4 | * |
---|
5 | * Revision information: |
---|
6 | * $Rev: $ |
---|
7 | * $Author: $ |
---|
8 | * $Date: $ |
---|
9 | */ |
---|
10 | |
---|
11 | import dbnp.studycapturing.* |
---|
12 | |
---|
13 | class BootStrapStudies { |
---|
14 | |
---|
15 | public static void addExampleStudies() { |
---|
16 | |
---|
17 | // TODO: Strip this code from all references to template and term objects |
---|
18 | // which now are not there anymore because this code was separated from the template bootstrapping |
---|
19 | // and because terms should be dynamically added |
---|
20 | |
---|
21 | /* |
---|
22 | // Create a few persons, roles and Affiliations |
---|
23 | println ".adding persons, roles and affiliations" |
---|
24 | def affiliation1 = new PersonAffiliation( |
---|
25 | institute: "Science Institute NYC", |
---|
26 | department: "Department of Mathematics" |
---|
27 | ).save(); |
---|
28 | def affiliation2 = new PersonAffiliation( |
---|
29 | institute: "InfoStats GmbH, Hamburg", |
---|
30 | department: "Life Sciences" |
---|
31 | ).save(); |
---|
32 | def role1 = new PersonRole( |
---|
33 | name: "Principal Investigator" |
---|
34 | ).save(); |
---|
35 | def role2 = new PersonRole( |
---|
36 | name: "Statician" |
---|
37 | ).save(); |
---|
38 | |
---|
39 | // Create persons |
---|
40 | def person1 = new Person( |
---|
41 | lastName: "Scientist", |
---|
42 | firstName: "John", |
---|
43 | gender: "Male", |
---|
44 | initials: "J.R.", |
---|
45 | email: "john@scienceinstitute.com", |
---|
46 | phone: "1-555-3049", |
---|
47 | address: "First street 2,NYC" |
---|
48 | ) |
---|
49 | .addToAffiliations( affiliation1 ) |
---|
50 | .addToAffiliations( affiliation2 ) |
---|
51 | .save(); |
---|
52 | |
---|
53 | def person2 = new Person( |
---|
54 | lastName: "Statician", |
---|
55 | firstName: "Jane", |
---|
56 | gender: "Female", |
---|
57 | initials: "W.J.", |
---|
58 | email: "jane@statisticalcompany.de", |
---|
59 | phone: "49-555-8291", |
---|
60 | address: "Dritten strasse 38, Hamburg, Germany" |
---|
61 | ) |
---|
62 | .addToAffiliations( affiliation2 ) |
---|
63 | .save(); |
---|
64 | |
---|
65 | // Create 30 persons to test pagination |
---|
66 | def personCounter = 1; |
---|
67 | 30.times { new Person( firstName: "Person #${personCounter}", lastName: "Testperson", email: "email${personCounter++}@testdomain.com" ).save() } |
---|
68 | |
---|
69 | // Create a few publications |
---|
70 | println ".adding publications" |
---|
71 | def publication1 = new Publication( |
---|
72 | title: "Postnatal development of hypothalamic leptin receptors", |
---|
73 | authorsList: "Cottrell EC, Mercer JG, Ozanne SE.", |
---|
74 | pubMedID: "20472140", |
---|
75 | comments: "Not published yet", |
---|
76 | DOI: "unknown" |
---|
77 | ) |
---|
78 | .save(); |
---|
79 | |
---|
80 | def publication2 = new Publication( |
---|
81 | title: "Induction of regulatory T cells decreases adipose inflammation and alleviates insulin resistance in ob/ob mice", |
---|
82 | authorsList: "Ilan Y, Maron R, Tukpah AM, Maioli TU, Murugaiyan G, Yang K, Wu HY, Weiner HL.", |
---|
83 | pubMedID: "20445103", |
---|
84 | comments: "", |
---|
85 | DOI: "" |
---|
86 | ) |
---|
87 | .save(); |
---|
88 | |
---|
89 | // Add example mouse study |
---|
90 | println ".adding NuGO PPS3 leptin example study..." |
---|
91 | def mouseStudy = new Study( |
---|
92 | template: studyTemplate, |
---|
93 | title:"NuGO PPS3 mouse study leptin module", |
---|
94 | code:"PPS3_leptin_module", |
---|
95 | researchQuestion:"Leptin etc.", |
---|
96 | ecCode:"2007117.c", |
---|
97 | startDate: Date.parse('yyyy-MM-dd','2008-01-02'), |
---|
98 | ) |
---|
99 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
100 | |
---|
101 | mouseStudy.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." ) |
---|
102 | mouseStudy.save() |
---|
103 | |
---|
104 | def evLF = new Event( |
---|
105 | startTime: 3600, |
---|
106 | endTime: 3600 +7 * 24 * 3600, |
---|
107 | template: dietTreatmentTemplate |
---|
108 | ) |
---|
109 | .setFieldValue( 'Diet','low fat') |
---|
110 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
111 | |
---|
112 | def evHF = new Event( |
---|
113 | startTime: 3600, |
---|
114 | endTime: 3600 +7 * 24 * 3600, |
---|
115 | template: dietTreatmentTemplate |
---|
116 | ) |
---|
117 | .setFieldValue( 'Diet','high fat' ) |
---|
118 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
119 | |
---|
120 | def evBV = new Event( |
---|
121 | startTime: 3600, |
---|
122 | endTime: 3600 +7 * 24 * 3600, |
---|
123 | template: boostTreatmentTemplate |
---|
124 | ) |
---|
125 | .setFieldValue( 'Control','true' ) |
---|
126 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
127 | |
---|
128 | def evBL = new Event( |
---|
129 | startTime: 3600, |
---|
130 | endTime: 3600 +7 * 24 * 3600, |
---|
131 | template: boostTreatmentTemplate |
---|
132 | ) |
---|
133 | .setFieldValue( 'Control','false' ) |
---|
134 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
135 | |
---|
136 | def evLF4 = new Event( |
---|
137 | startTime: 3600, |
---|
138 | endTime: 3600 + 4 * 7 * 24 * 3600, |
---|
139 | template: dietTreatmentTemplate |
---|
140 | ) |
---|
141 | .setFieldValue( 'Diet','low fat') |
---|
142 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
143 | |
---|
144 | def evHF4 = new Event( |
---|
145 | startTime: 3600, |
---|
146 | endTime: 3600 + 4 * 7 * 24 * 3600, |
---|
147 | template: dietTreatmentTemplate |
---|
148 | ) |
---|
149 | .setFieldValue( 'Diet','high fat' ) |
---|
150 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
151 | |
---|
152 | def evBV4 = new Event( |
---|
153 | startTime: 3600, |
---|
154 | endTime: 3600 + 4 * 7 * 24 * 3600, |
---|
155 | template: boostTreatmentTemplate |
---|
156 | ) |
---|
157 | .setFieldValue( 'Control','true' ) |
---|
158 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
159 | |
---|
160 | def evBL4 = new Event( |
---|
161 | startTime: 3600, |
---|
162 | endTime: 3600 + 4 * 7 * 24 * 3600, |
---|
163 | template: boostTreatmentTemplate |
---|
164 | ) |
---|
165 | .setFieldValue( 'Control','false' ) |
---|
166 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
167 | |
---|
168 | def evS = new SamplingEvent( |
---|
169 | startTime: 3600 +7 * 24 * 3600, |
---|
170 | endTime: 3600 +7 * 24 * 3600, |
---|
171 | template: liverSamplingEventTemplate) |
---|
172 | .setFieldValue('Sample weight',5F) |
---|
173 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
174 | |
---|
175 | def evS4 = new SamplingEvent( |
---|
176 | startTime: 3600 +7 * 24 * 3600, |
---|
177 | endTime: 3600 +7 * 24 * 3600, |
---|
178 | template: liverSamplingEventTemplate) |
---|
179 | .setFieldValue('Sample weight',5F) |
---|
180 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
181 | |
---|
182 | // Add events to study |
---|
183 | mouseStudy |
---|
184 | .addToEvents(evLF) |
---|
185 | .addToEvents(evHF) |
---|
186 | .addToEvents(evBV) |
---|
187 | .addToEvents(evBL) |
---|
188 | .addToEvents(evLF4) |
---|
189 | .addToEvents(evHF4) |
---|
190 | .addToEvents(evBV4) |
---|
191 | .addToEvents(evBL4) |
---|
192 | .addToSamplingEvents(evS) |
---|
193 | .addToSamplingEvents(evS4) |
---|
194 | .save() |
---|
195 | |
---|
196 | def LFBV1 = new EventGroup(name:"10% fat + vehicle for 1 week") |
---|
197 | .addToEvents(evLF) |
---|
198 | .addToEvents(evBV) |
---|
199 | .addToEvents(evS) |
---|
200 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
201 | |
---|
202 | def LFBL1 = new EventGroup(name:"10% fat + leptin for 1 week") |
---|
203 | .addToEvents(evLF) |
---|
204 | .addToEvents(evBL) |
---|
205 | .addToEvents(evS) |
---|
206 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
207 | |
---|
208 | def HFBV1 = new EventGroup(name:"45% fat + vehicle for 1 week") |
---|
209 | .addToEvents(evHF) |
---|
210 | .addToEvents(evBV) |
---|
211 | .addToEvents(evS) |
---|
212 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
213 | |
---|
214 | def HFBL1 = new EventGroup(name:"45% fat + leptin for 1 week") |
---|
215 | .addToEvents(evHF) |
---|
216 | .addToEvents(evBL) |
---|
217 | .addToEvents(evS) |
---|
218 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
219 | |
---|
220 | def LFBV4 = new EventGroup(name:"10% fat + vehicle for 4 weeks") |
---|
221 | .addToEvents(evLF4) |
---|
222 | .addToEvents(evBV4) |
---|
223 | .addToEvents(evS4) |
---|
224 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
225 | |
---|
226 | def LFBL4 = new EventGroup(name:"10% fat + leptin for 4 weeks") |
---|
227 | .addToEvents(evLF4) |
---|
228 | .addToEvents(evBL4) |
---|
229 | .addToEvents(evS4) |
---|
230 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
231 | |
---|
232 | def HFBV4 = new EventGroup(name:"45% fat + vehicle for 4 weeks") |
---|
233 | .addToEvents(evHF4) |
---|
234 | .addToEvents(evBV4) |
---|
235 | .addToEvents(evS4) |
---|
236 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
237 | |
---|
238 | def HFBL4 = new EventGroup(name:"45% fat + leptin for 4 weeks") |
---|
239 | .addToEvents(evHF4) |
---|
240 | .addToEvents(evBL4) |
---|
241 | .addToEvents(evS4) |
---|
242 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
243 | |
---|
244 | // Add subjects and samples and compose EventGroups |
---|
245 | def x=1 |
---|
246 | 20.times { |
---|
247 | def currentSubject = new Subject( |
---|
248 | name: "A" + x++, |
---|
249 | species: mouseTerm, |
---|
250 | template: mouseTemplate, |
---|
251 | ) |
---|
252 | .setFieldValue("Gender", "Male") |
---|
253 | .setFieldValue("Genotype", c57bl6Term) |
---|
254 | .setFieldValue("Age", 17) |
---|
255 | .setFieldValue("Cage", "" + (int)(x/2)) |
---|
256 | .with { if (!validate()) { errors.each { println it} } else save(flush:true)} |
---|
257 | |
---|
258 | mouseStudy.addToSubjects(currentSubject) |
---|
259 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
260 | |
---|
261 | // Add subject to appropriate EventGroup |
---|
262 | if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } |
---|
263 | else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } |
---|
264 | else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() } |
---|
265 | else if (x > 40) { LFBV4.addToSubjects(currentSubject).save() } |
---|
266 | else if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } |
---|
267 | else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } |
---|
268 | else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } |
---|
269 | else { LFBV1.addToSubjects(currentSubject).save() } |
---|
270 | |
---|
271 | } |
---|
272 | |
---|
273 | // Add EventGroups to study |
---|
274 | mouseStudy |
---|
275 | .addToEventGroups(LFBV1) |
---|
276 | .addToEventGroups(LFBL1) |
---|
277 | .addToEventGroups(HFBV1) |
---|
278 | .addToEventGroups(HFBL1) |
---|
279 | .addToEventGroups(LFBV4) |
---|
280 | .addToEventGroups(LFBL4) |
---|
281 | .addToEventGroups(HFBV4) |
---|
282 | .addToEventGroups(HFBL4) |
---|
283 | |
---|
284 | // Add persons and publications to study |
---|
285 | def studyperson1 = new StudyPerson( person: person1, role: role1 ).save(); |
---|
286 | def studyperson2 = new StudyPerson( person: person2, role: role2 ).save(); |
---|
287 | |
---|
288 | mouseStudy |
---|
289 | .addToPersons( studyperson1 ) |
---|
290 | .addToPersons( studyperson2 ) |
---|
291 | .addToPublications( publication1 ) |
---|
292 | .addToPublications( publication2 ) |
---|
293 | .save() |
---|
294 | |
---|
295 | // Add example human study |
---|
296 | println ".adding NuGO PPSH example study..." |
---|
297 | |
---|
298 | def humanStudy = new Study( |
---|
299 | template: studyTemplate, |
---|
300 | title:"NuGO PPS human study", |
---|
301 | code:"PPSH", |
---|
302 | researchQuestion:"How much are fasting plasma and urine metabolite levels affected by prolonged fasting ?", |
---|
303 | description:"Human study", |
---|
304 | ecCode:"unknown", |
---|
305 | startDate: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
306 | ) |
---|
307 | .setFieldValue( 'Description', "Human study performed at RRI; centres involved: RRI, IFR, TUM, Maastricht U." ) |
---|
308 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
309 | |
---|
310 | def rootGroup = new EventGroup(name: 'Root group'); |
---|
311 | |
---|
312 | def fastingEvent = new Event( |
---|
313 | startTime: 3 * 24 * 3600 + 22 * 3600, |
---|
314 | endTime: 3 * 24 * 3600 + 30 * 3600, |
---|
315 | template: fastingTreatment) |
---|
316 | .setFieldValue('Fasting period','8h'); |
---|
317 | |
---|
318 | |
---|
319 | def bloodSamplingEvent = new SamplingEvent( |
---|
320 | startTime: 3 * 24 * 3600 + 30 * 3600, |
---|
321 | endTime: 3 * 24 * 3600 + 30 * 3600, |
---|
322 | template: bloodSamplingEventTemplate) |
---|
323 | .setFieldValue('Sample volume',4.5F); |
---|
324 | |
---|
325 | rootGroup.addToEvents fastingEvent |
---|
326 | rootGroup.addToEvents bloodSamplingEvent |
---|
327 | rootGroup.save() |
---|
328 | |
---|
329 | def y = 1 |
---|
330 | 11.times { |
---|
331 | def currentSubject = new Subject( |
---|
332 | name: "" + y++, |
---|
333 | species: humanTerm, |
---|
334 | template: humanTemplate |
---|
335 | ) |
---|
336 | .setFieldValue("Gender", (Math.random() > 0.5) ? "Male" : "Female") |
---|
337 | .setFieldValue("DOB", new java.text.SimpleDateFormat("dd-mm-yy").parse("01-02-19" + (10 + (int) (Math.random() * 80)))) |
---|
338 | .setFieldValue("Age", 30) |
---|
339 | .setFieldValue("Height", Math.random() * 2F) |
---|
340 | .setFieldValue("Weight", Math.random() * 150F) |
---|
341 | .setFieldValue("BMI", 20 + Math.random() * 10F) |
---|
342 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
343 | |
---|
344 | rootGroup.addToSubjects currentSubject |
---|
345 | rootGroup.save() |
---|
346 | |
---|
347 | def currentSample = new Sample( |
---|
348 | name: currentSubject.name + '_B', |
---|
349 | material: bloodTerm, |
---|
350 | template: humanBloodSampleTemplate, |
---|
351 | parentSubject: currentSubject, |
---|
352 | parentEvent: bloodSamplingEvent |
---|
353 | ); |
---|
354 | currentSample.setFieldValue( "Text on vial", "T" + (Math.random() * 100L) ) |
---|
355 | |
---|
356 | humanStudy.addToSubjects(currentSubject).addToSamples(currentSample).with { if (!validate()) { errors.each { println it} } else save()} |
---|
357 | } |
---|
358 | |
---|
359 | humanStudy.addToEvents(fastingEvent) |
---|
360 | humanStudy.addToSamplingEvents(bloodSamplingEvent) |
---|
361 | humanStudy.addToEventGroups rootGroup |
---|
362 | |
---|
363 | |
---|
364 | // Add persons to study |
---|
365 | def studyperson3 = new StudyPerson( person: person1, role: role2 ).save(); |
---|
366 | |
---|
367 | humanStudy |
---|
368 | .addToPersons( studyperson3 ) |
---|
369 | .addToPublications( publication2 ) |
---|
370 | .save() |
---|
371 | |
---|
372 | // Add clinical data ==> to be moved to SAM |
---|
373 | |
---|
374 | def lipidAssay = new dbnp.clinicaldata.ClinicalAssay( |
---|
375 | name: 'Lipid profile', |
---|
376 | approved: true |
---|
377 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
378 | |
---|
379 | def ldlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( |
---|
380 | name: 'LDL', |
---|
381 | unit: 'mg/dL', |
---|
382 | type: dbnp.data.FeatureType.QUANTITATIVE, |
---|
383 | referenceValues: '100 mg/dL', |
---|
384 | detectableLimit: 250, |
---|
385 | isDrug: false, isIntake: true, inSerum: true |
---|
386 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
387 | |
---|
388 | def hdlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( |
---|
389 | name: 'HDL', |
---|
390 | unit: 'mg/dL', |
---|
391 | type: dbnp.data.FeatureType.QUANTITATIVE, |
---|
392 | referenceValues: '50 mg/dL', |
---|
393 | detectableLimit: 100, |
---|
394 | isDrug: false, isIntake: true, inSerum: true |
---|
395 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
396 | |
---|
397 | lipidAssay.addToMeasurements ldlMeasurement |
---|
398 | lipidAssay.addToMeasurements hdlMeasurement |
---|
399 | |
---|
400 | def lipidAssayInstance = new dbnp.clinicaldata.ClinicalAssayInstance( |
---|
401 | assay: lipidAssay |
---|
402 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
403 | |
---|
404 | humanStudy.samples*.each { |
---|
405 | new dbnp.clinicaldata.ClinicalFloatData( |
---|
406 | assay: lipidAssayInstance, |
---|
407 | measurement: ldlMeasurement, |
---|
408 | sample: it.name, |
---|
409 | value: Math.round(Math.random()*ldlMeasurement.detectableLimit) |
---|
410 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
411 | |
---|
412 | new dbnp.clinicaldata.ClinicalFloatData( |
---|
413 | assay: lipidAssayInstance, |
---|
414 | measurement: hdlMeasurement, |
---|
415 | sample: it.name, |
---|
416 | value: Math.round(Math.random()*hdlMeasurement.detectableLimit) |
---|
417 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
418 | } |
---|
419 | |
---|
420 | // Add assay to study capture module |
---|
421 | |
---|
422 | def clinicalModule = new AssayModule( |
---|
423 | name: 'Clinical data', |
---|
424 | type: AssayType.CLINICAL_DATA, |
---|
425 | platform: 'clinical measurements', |
---|
426 | url: 'http://localhost:8080/gscf' |
---|
427 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
428 | |
---|
429 | def lipidAssayRef = new Assay( |
---|
430 | name: 'Lipid profiling', |
---|
431 | module: clinicalModule, |
---|
432 | externalAssayId: 0 |
---|
433 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
434 | |
---|
435 | humanStudy.samples*.each { |
---|
436 | lipidAssayRef.addToSamples(it) |
---|
437 | } |
---|
438 | lipidAssayRef.save() |
---|
439 | |
---|
440 | humanStudy.addToAssays(lipidAssayRef); |
---|
441 | humanStudy.save() |
---|
442 | |
---|
443 | mouseStudy.addToAssays(lipidAssayRef); |
---|
444 | mouseStudy.save() |
---|
445 | */ |
---|
446 | } |
---|
447 | |
---|
448 | } |
---|