1 | import dbnp.studycapturing.* |
---|
2 | |
---|
3 | import dbnp.data.Ontology |
---|
4 | import dbnp.data.Term |
---|
5 | import org.codehaus.groovy.grails.commons.GrailsApplication |
---|
6 | |
---|
7 | /** |
---|
8 | * Application Bootstrapper |
---|
9 | * @Author Jeroen Wesbeek |
---|
10 | * @Since 20091021 |
---|
11 | * |
---|
12 | * Revision information: |
---|
13 | * $Rev: 423 $ |
---|
14 | * $Author: duh $ |
---|
15 | * $Date: 2010-05-17 14:32:57 +0000 (ma, 17 mei 2010) $ |
---|
16 | */ |
---|
17 | class BootStrap { |
---|
18 | def init = {servletContext -> |
---|
19 | // define timezone |
---|
20 | System.setProperty('user.timezone', 'CET') |
---|
21 | |
---|
22 | // we could also check if we are in development by GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT |
---|
23 | if (Study.count() == 0) { |
---|
24 | println ".development bootstrapping..."; |
---|
25 | |
---|
26 | // add Subject>species ontology |
---|
27 | println ".adding NCBI species ontology" |
---|
28 | def speciesOntology = new Ontology( |
---|
29 | name: 'NCBI organismal classification', |
---|
30 | description: 'A taxonomic classification of living organisms and associated artifacts for their controlled description within the context of databases.', |
---|
31 | url: 'http://www.ncbi.nlm.nih.gov/Taxonomy/taxonomyhome.html/', |
---|
32 | versionNumber: '1.2', |
---|
33 | ncboId: '1132', |
---|
34 | ncboVersionedId: '38802' |
---|
35 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
36 | |
---|
37 | // add Sample>material ontology |
---|
38 | println ".adding BRENDA source material ontology" |
---|
39 | def brendaOntology = new Ontology( |
---|
40 | name: 'BRENDA tissue / enzyme source', |
---|
41 | description: 'A structured controlled vocabulary for the source of an enzyme. It comprises terms for tissues, cell lines, cell types and cell cultures from uni- and multicellular organisms.', |
---|
42 | url: 'http://www.brenda-enzymes.info', |
---|
43 | versionNumber: '1.3', |
---|
44 | ncboId: '1005', |
---|
45 | ncboVersionedId: '40643' |
---|
46 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
47 | |
---|
48 | // add NCI ontology which is used in Mouse genotype template field |
---|
49 | def nciOntology = new Ontology( |
---|
50 | name: 'NCI Thesaurus', |
---|
51 | description: 'A vocabulary for clinical care, translational and basic research, and public information and administrative activities.', |
---|
52 | url: 'http://ncicb.nci.nih.gov/core/EVS', |
---|
53 | versionNumber: '10.01', |
---|
54 | ncboId: '1032', |
---|
55 | ncboVersionedId: '42693' |
---|
56 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
57 | |
---|
58 | // add Terms |
---|
59 | println ".adding mouse term" |
---|
60 | def mouseTerm = new Term( |
---|
61 | name: 'Mus musculus', |
---|
62 | ontology: speciesOntology, |
---|
63 | accession: '10090' |
---|
64 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
65 | println ".adding human term" |
---|
66 | def humanTerm = new Term( |
---|
67 | name: 'Homo sapiens', |
---|
68 | ontology: speciesOntology, |
---|
69 | accession: '9606' |
---|
70 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
71 | def arabTerm = new Term( |
---|
72 | name: 'Arabidopsis thaliana', |
---|
73 | ontology: speciesOntology, |
---|
74 | accession: '3702' |
---|
75 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
76 | |
---|
77 | def bloodTerm = new Term( |
---|
78 | name: 'blood plasma', |
---|
79 | ontology: brendaOntology, |
---|
80 | accession: 'BTO:0000131' |
---|
81 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
82 | |
---|
83 | def c57bl6Term = new Term( |
---|
84 | name: 'C57BL/6 Mouse', |
---|
85 | ontology: nciOntology, |
---|
86 | accession: 'C14424' |
---|
87 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
88 | |
---|
89 | // Create a few persons, roles and Affiliations |
---|
90 | println ".adding persons, roles and affiliations" |
---|
91 | def affiliation1 = new PersonAffiliation( |
---|
92 | name: "Science Institute NYC" |
---|
93 | ).save(); |
---|
94 | def affiliation2 = new PersonAffiliation( |
---|
95 | name: "InfoStats GmbH, Hamburg" |
---|
96 | ).save(); |
---|
97 | def role1 = new PersonRole( |
---|
98 | name: "Principal Investigator" |
---|
99 | ).save(); |
---|
100 | def role2 = new PersonRole( |
---|
101 | name: "Statician" |
---|
102 | ).save(); |
---|
103 | |
---|
104 | // Create 30 roles to test pagination |
---|
105 | def roleCounter = 1; |
---|
106 | 30.times { new PersonRole( name: "Rol #${roleCounter++}" ).save() } |
---|
107 | |
---|
108 | // Create persons |
---|
109 | def person1 = new Person( |
---|
110 | lastName: "Scientist", |
---|
111 | firstName: "John", |
---|
112 | gender: "Male", |
---|
113 | initials: "J.R.", |
---|
114 | email: "john@scienceinstitute.com", |
---|
115 | phone: "1-555-3049", |
---|
116 | address: "First street 2,NYC" |
---|
117 | ) |
---|
118 | .addToAffiliations( affiliation1 ) |
---|
119 | .addToAffiliations( affiliation2 ) |
---|
120 | .save(); |
---|
121 | |
---|
122 | def person2 = new Person( |
---|
123 | lastName: "Statician", |
---|
124 | firstName: "Jane", |
---|
125 | gender: "Female", |
---|
126 | initials: "W.J.", |
---|
127 | email: "jane@statisticalcompany.de", |
---|
128 | phone: "49-555-8291", |
---|
129 | address: "Dritten strasse 38, Hamburg, Germany" |
---|
130 | ) |
---|
131 | .addToAffiliations( affiliation2 ) |
---|
132 | .save(); |
---|
133 | |
---|
134 | // Create 30 persons to test pagination |
---|
135 | def personCounter = 1; |
---|
136 | 30.times { new Person( firstName: "Person #${personCounter}", lastName: "Testperson", email: "email${personCounter++}@testdomain.com" ).save() } |
---|
137 | |
---|
138 | // Create templates |
---|
139 | |
---|
140 | def genderField = new TemplateField( |
---|
141 | name: 'Gender',type: TemplateFieldType.STRINGLIST, |
---|
142 | listEntries: [new TemplateFieldListItem(name:'Male'),new TemplateFieldListItem(name: 'Female')]) |
---|
143 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
144 | |
---|
145 | def ageField = new TemplateField( |
---|
146 | name: 'Age (years)',type: TemplateFieldType.INTEGER,unit: 'years') |
---|
147 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
148 | |
---|
149 | def genotypeField = new TemplateField( |
---|
150 | name: 'Genotype', type: TemplateFieldType.ONTOLOGYTERM) |
---|
151 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
152 | |
---|
153 | def genotypeTypeField = new TemplateField( |
---|
154 | name: 'Genotype type',type: TemplateFieldType.STRINGLIST, |
---|
155 | listEntries: [new TemplateFieldListItem(name:'wildtype'), |
---|
156 | new TemplateFieldListItem(name:'transgenic'), |
---|
157 | new TemplateFieldListItem(name:'knock-out'), |
---|
158 | new TemplateFieldListItem(name:'knock-in')]) |
---|
159 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
160 | |
---|
161 | |
---|
162 | // Nutritional study template |
---|
163 | |
---|
164 | println ".adding academic study template..." |
---|
165 | def studyTemplate = new Template( |
---|
166 | name: 'Academic study', entity: dbnp.studycapturing.Study) |
---|
167 | .addToFields(new TemplateField(name: 'Description',type: TemplateFieldType.TEXT)) |
---|
168 | .addToFields(new TemplateField(name: 'Study code',type: TemplateFieldType.STRING, preferredIdentifier:true)) |
---|
169 | .addToFields(new TemplateField(name: 'Objectives',type: TemplateFieldType.TEXT)) |
---|
170 | .addToFields(new TemplateField(name: 'Consortium',type: TemplateFieldType.STRING)) |
---|
171 | .addToFields(new TemplateField(name: 'Cohort name',type: TemplateFieldType.STRING)) |
---|
172 | .addToFields(new TemplateField(name: 'Time zone',type: TemplateFieldType.STRING)) |
---|
173 | .addToFields(new TemplateField(name: 'Responsible scientist',type: TemplateFieldType.STRING)) |
---|
174 | .addToFields(new TemplateField(name: 'Lab id',type: TemplateFieldType.STRING)) |
---|
175 | .addToFields(new TemplateField(name: 'Institute',type: TemplateFieldType.STRING)) |
---|
176 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
177 | |
---|
178 | // Mouse template |
---|
179 | println ".adding mouse subject template..." |
---|
180 | def mouseTemplate = new Template( |
---|
181 | name: 'Mouse', entity: dbnp.studycapturing.Subject) |
---|
182 | .addToFields(new TemplateField( |
---|
183 | name: 'Strain', type: TemplateFieldType.ONTOLOGYTERM)) |
---|
184 | .addToFields(genotypeField) |
---|
185 | .addToFields(genotypeTypeField) |
---|
186 | .addToFields(genderField) |
---|
187 | .addToFields(new TemplateField( |
---|
188 | name: 'Age (weeks)', type: TemplateFieldType.INTEGER, unit: 'weeks')) |
---|
189 | .addToFields(new TemplateField( |
---|
190 | name: 'Age type',type: TemplateFieldType.STRINGLIST, |
---|
191 | listEntries: [new TemplateFieldListItem(name:'postnatal'),new TemplateFieldListItem(name:'embryonal')])) |
---|
192 | .addToFields(new TemplateField( |
---|
193 | name: 'Cage',type: TemplateFieldType.STRING)) |
---|
194 | .addToFields(new TemplateField( |
---|
195 | name: '#Mice in cage',type: TemplateFieldType.INTEGER)) |
---|
196 | .addToFields(new TemplateField( |
---|
197 | name: 'Litter size',type: TemplateFieldType.INTEGER)) |
---|
198 | .addToFields(new TemplateField( |
---|
199 | name: 'Weight (g)', type: TemplateFieldType.DOUBLE, unit: 'gram')) |
---|
200 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
201 | |
---|
202 | // Human template |
---|
203 | println ".adding human subject template..." |
---|
204 | def humanTemplate = new Template( |
---|
205 | name: 'Human', entity: dbnp.studycapturing.Subject) |
---|
206 | .addToFields(genderField) |
---|
207 | .addToFields(ageField) |
---|
208 | .addToFields(new TemplateField( |
---|
209 | name: 'DOB',type: TemplateFieldType.DATE)) |
---|
210 | .addToFields(new TemplateField( |
---|
211 | name: 'Height',type: TemplateFieldType.DOUBLE, unit: 'm')) |
---|
212 | .addToFields(new TemplateField( |
---|
213 | name: 'Weight (kg)',type: TemplateFieldType.DOUBLE, unit: 'kg')) |
---|
214 | .addToFields(new TemplateField( |
---|
215 | name: 'BMI',type: TemplateFieldType.DOUBLE, unit: 'kg/m2')) |
---|
216 | .addToFields(new TemplateField( |
---|
217 | name: 'Race',type: TemplateFieldType.STRING)) |
---|
218 | .addToFields(new TemplateField( |
---|
219 | name: 'Waist circumference',type: TemplateFieldType.FLOAT, unit: 'cm')) |
---|
220 | .addToFields(new TemplateField( |
---|
221 | name: 'Hip circumference',type: TemplateFieldType.FLOAT, unit: 'cm')) |
---|
222 | .addToFields(new TemplateField( |
---|
223 | name: 'Systolic blood pressure',type: TemplateFieldType.FLOAT, unit: 'mmHg')) |
---|
224 | .addToFields(new TemplateField( |
---|
225 | name: 'Diastolic blood pressure',type: TemplateFieldType.FLOAT, unit: 'mmHg')) |
---|
226 | .addToFields(new TemplateField( |
---|
227 | name: 'Heart rate',type: TemplateFieldType.FLOAT, unit: 'beats/min')) |
---|
228 | .addToFields(new TemplateField( |
---|
229 | name: 'Run-in-food',type: TemplateFieldType.TEXT)) |
---|
230 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
231 | |
---|
232 | |
---|
233 | def sampleDescriptionField = new TemplateField( |
---|
234 | name: 'Description',type: TemplateFieldType.TEXT) |
---|
235 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
236 | def sampleTypeField = new TemplateField( |
---|
237 | name: 'SampleType',type: TemplateFieldType.STRING) |
---|
238 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
239 | def sampleProtocolField = new TemplateField( |
---|
240 | name: 'SampleProtocol',type: TemplateFieldType.STRING) |
---|
241 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
242 | def sampleVialTextField = new TemplateField( |
---|
243 | name: 'Text on vial',type: TemplateFieldType.STRING) |
---|
244 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
245 | |
---|
246 | // Human sample template |
---|
247 | println ".adding human sample template..." |
---|
248 | def humanSampleTemplate = new Template( |
---|
249 | name: 'Human tissue sample', entity: dbnp.studycapturing.Sample) |
---|
250 | .addToFields(sampleDescriptionField) |
---|
251 | .addToFields(sampleTypeField) |
---|
252 | .addToFields(sampleProtocolField) |
---|
253 | .addToFields(sampleVialTextField) |
---|
254 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
255 | |
---|
256 | //Plant template |
---|
257 | println ".adding plant template..." |
---|
258 | def plantTemplate = new Template( |
---|
259 | name: 'Plant template', entity: dbnp.studycapturing.Subject) |
---|
260 | .addToFields(new TemplateField( |
---|
261 | name: 'Variety', type: TemplateFieldType.STRING)) |
---|
262 | .addToFields(new TemplateField( |
---|
263 | name: 'Ecotype', type: TemplateFieldType.STRING)) |
---|
264 | .addToFields(genotypeField) |
---|
265 | .addToFields(genotypeTypeField) |
---|
266 | .addToFields(new TemplateField( |
---|
267 | name: 'Growth location', type: TemplateFieldType.STRINGLIST, |
---|
268 | listEntries: [new TemplateFieldListItem(name:'Greenhouse'),new TemplateFieldListItem(name: 'Field')])) |
---|
269 | .addToFields(new TemplateField( |
---|
270 | name: 'Room', type: TemplateFieldType.STRING, |
---|
271 | comment: 'Chamber number in case of Greenhouse')) |
---|
272 | .addToFields(new TemplateField( |
---|
273 | name: 'Position X', type: TemplateFieldType.FLOAT)) |
---|
274 | .addToFields(new TemplateField( |
---|
275 | name: 'Position Y', type: TemplateFieldType.FLOAT)) |
---|
276 | .addToFields(new TemplateField( |
---|
277 | name: 'Block', type: TemplateFieldType.STRING)) |
---|
278 | .addToFields(new TemplateField( |
---|
279 | name: 'Temperature at day', type: TemplateFieldType.FLOAT)) |
---|
280 | .addToFields(new TemplateField( |
---|
281 | name: 'Temperature at night', type: TemplateFieldType.FLOAT)) |
---|
282 | .addToFields(new TemplateField( |
---|
283 | name: 'Photo period', type: TemplateFieldType.STRING)) |
---|
284 | .addToFields(new TemplateField( |
---|
285 | name: 'Light intensity', type: TemplateFieldType.STRING)) |
---|
286 | .addToFields(new TemplateField( |
---|
287 | name: 'Start date', type: TemplateFieldType.DATE)) |
---|
288 | .addToFields(new TemplateField( |
---|
289 | name: 'Harvest date', type: TemplateFieldType.DATE)) |
---|
290 | .addToFields(new TemplateField( |
---|
291 | name: 'Growth type', type: TemplateFieldType.STRINGLIST, |
---|
292 | listEntries: [new TemplateFieldListItem(name:'Standard'),new TemplateFieldListItem(name: 'Experimental')])) |
---|
293 | .addToFields(new TemplateField( |
---|
294 | name: 'Growth protocol', type: TemplateFieldType.TEXT)) |
---|
295 | .addToFields(new TemplateField( |
---|
296 | name: 'Harvest delay', type: TemplateFieldType.TEXT)) |
---|
297 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
298 | |
---|
299 | println ".adding plant sample template..." |
---|
300 | def plantSampleTemplate = new Template( |
---|
301 | name: 'Plant sample', entity: dbnp.studycapturing.Sample) |
---|
302 | .addToFields(sampleDescriptionField) |
---|
303 | .addToFields(sampleTypeField) |
---|
304 | .addToFields(sampleProtocolField) |
---|
305 | .addToFields(sampleVialTextField) |
---|
306 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
307 | |
---|
308 | |
---|
309 | // Event templates |
---|
310 | def dietTreatmentTemplate = new Template( |
---|
311 | name: 'Diet treatment', entity: dbnp.studycapturing.Event) |
---|
312 | .addToFields(sampleDescriptionField) |
---|
313 | .addToFields(new TemplateField( |
---|
314 | name: 'Diet', type: TemplateFieldType.STRINGLIST, |
---|
315 | listEntries: [new TemplateFieldListItem(name:'10% fat (palm oil)'),new TemplateFieldListItem(name: '45% fat (palm oil)')])) |
---|
316 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
317 | |
---|
318 | def boostTreatmentTemplate = new Template( |
---|
319 | name: 'Boost treatment', entity: dbnp.studycapturing.Event) |
---|
320 | .addToFields(sampleDescriptionField) |
---|
321 | .addToFields(new TemplateField( |
---|
322 | name: 'Compound', type: TemplateFieldType.STRING, |
---|
323 | listEntries: [new TemplateFieldListItem(name:'Vehicle'),new TemplateFieldListItem(name: 'Leptin')])) |
---|
324 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
325 | |
---|
326 | def fastingTreatment = new Template( |
---|
327 | name: 'Fasting treatment', |
---|
328 | description: 'Fasting Protocol NuGO PPSH', |
---|
329 | entity: dbnp.studycapturing.Event) |
---|
330 | .addToFields(new TemplateField( |
---|
331 | name: 'Fasting period', |
---|
332 | type: TemplateFieldType.STRING)) |
---|
333 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
334 | |
---|
335 | // SamplingEvent templates |
---|
336 | |
---|
337 | def liverSamplingEventTemplate = new Template( |
---|
338 | name: 'Liver extraction', |
---|
339 | description: 'Liver sampling for transcriptomics arrays', |
---|
340 | entity: dbnp.studycapturing.SamplingEvent) |
---|
341 | .addToFields(new TemplateField( |
---|
342 | name: 'Sample weight', |
---|
343 | unit: 'mg', |
---|
344 | type: TemplateFieldType.FLOAT)) |
---|
345 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
346 | |
---|
347 | def bloodSamplingEventTemplate = new Template( |
---|
348 | name: 'Blood extraction', |
---|
349 | description: 'Blood extraction targeted at lipid assays', |
---|
350 | entity: dbnp.studycapturing.SamplingEvent) |
---|
351 | .addToFields(new TemplateField( |
---|
352 | name: 'Sample volume', |
---|
353 | unit: 'ml', |
---|
354 | type: TemplateFieldType.FLOAT)) |
---|
355 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
356 | |
---|
357 | |
---|
358 | // Add example studies |
---|
359 | if (!(grails.util.GrailsUtil.environment == GrailsApplication.ENV_TEST)) { |
---|
360 | println ".adding NuGO PPS3 leptin example study..." |
---|
361 | def mouseStudy = new Study( |
---|
362 | template: studyTemplate, |
---|
363 | title:"NuGO PPS3 mouse study leptin module", |
---|
364 | code:"PPS3_leptin_module", |
---|
365 | researchQuestion:"Leptin etc.", |
---|
366 | ecCode:"2007117.c", |
---|
367 | startDate: Date.parse('yyyy-MM-dd','2007-12-11') |
---|
368 | ) |
---|
369 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
370 | |
---|
371 | 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." ) |
---|
372 | mouseStudy.save() |
---|
373 | |
---|
374 | def evLF = new Event( |
---|
375 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
376 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
377 | template: dietTreatmentTemplate |
---|
378 | ) |
---|
379 | .setFieldValue( 'Diet','10% fat (palm oil)') |
---|
380 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
381 | |
---|
382 | def evHF = new Event( |
---|
383 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
384 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
385 | template: dietTreatmentTemplate |
---|
386 | ) |
---|
387 | .setFieldValue( 'Diet','45% fat (palm oil)' ) |
---|
388 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
389 | |
---|
390 | def evBV = new Event( |
---|
391 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
392 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
393 | template: boostTreatmentTemplate |
---|
394 | ) |
---|
395 | .setFieldValue( 'Compound','Vehicle' ) |
---|
396 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
397 | |
---|
398 | def evBL = new Event( |
---|
399 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
400 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
401 | template: boostTreatmentTemplate |
---|
402 | ) |
---|
403 | .setFieldValue( 'Compound','Leptin' ) |
---|
404 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
405 | |
---|
406 | def evLF4 = new Event( |
---|
407 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
408 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
409 | template: dietTreatmentTemplate |
---|
410 | ) |
---|
411 | .setFieldValue( 'Diet','10% fat (palm oil)') |
---|
412 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
413 | |
---|
414 | def evHF4 = new Event( |
---|
415 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
416 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
417 | template: dietTreatmentTemplate |
---|
418 | ) |
---|
419 | .setFieldValue( 'Diet','45% fat (palm oil)' ) |
---|
420 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
421 | |
---|
422 | def evBV4 = new Event( |
---|
423 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
424 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
425 | template: boostTreatmentTemplate |
---|
426 | ) |
---|
427 | .setFieldValue( 'Compound','Vehicle' ) |
---|
428 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
429 | |
---|
430 | def evBL4 = new Event( |
---|
431 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
432 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
433 | template: boostTreatmentTemplate |
---|
434 | ) |
---|
435 | .setFieldValue( 'Compound','Leptin' ) |
---|
436 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
437 | |
---|
438 | def evS = new SamplingEvent( |
---|
439 | startTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
440 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
441 | template: liverSamplingEventTemplate) |
---|
442 | .setFieldValue('Sample weight',5F) |
---|
443 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
444 | |
---|
445 | def evS4 = new SamplingEvent( |
---|
446 | startTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
447 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
448 | template: liverSamplingEventTemplate) |
---|
449 | .setFieldValue('Sample weight',5F) |
---|
450 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
451 | |
---|
452 | // Add events to study |
---|
453 | mouseStudy |
---|
454 | .addToEvents(evLF) |
---|
455 | .addToEvents(evHF) |
---|
456 | .addToEvents(evBV) |
---|
457 | .addToEvents(evBL) |
---|
458 | .addToEvents(evLF4) |
---|
459 | .addToEvents(evHF4) |
---|
460 | .addToEvents(evBV4) |
---|
461 | .addToEvents(evBL4) |
---|
462 | .addToSamplingEvents(evS) |
---|
463 | .addToSamplingEvents(evS4) |
---|
464 | .save() |
---|
465 | |
---|
466 | def LFBV1 = new EventGroup(name:"10% fat + vehicle for 1 week") |
---|
467 | .addToEvents(evLF) |
---|
468 | .addToEvents(evBV) |
---|
469 | .addToEvents(evS) |
---|
470 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
471 | |
---|
472 | def LFBL1 = new EventGroup(name:"10% fat + leptin for 1 week") |
---|
473 | .addToEvents(evLF) |
---|
474 | .addToEvents(evBL) |
---|
475 | .addToEvents(evS) |
---|
476 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
477 | |
---|
478 | def HFBV1 = new EventGroup(name:"45% fat + vehicle for 1 week") |
---|
479 | .addToEvents(evHF) |
---|
480 | .addToEvents(evBV) |
---|
481 | .addToEvents(evS) |
---|
482 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
483 | |
---|
484 | def HFBL1 = new EventGroup(name:"45% fat + leptin for 1 week") |
---|
485 | .addToEvents(evHF) |
---|
486 | .addToEvents(evBL) |
---|
487 | .addToEvents(evS) |
---|
488 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
489 | |
---|
490 | def LFBV4 = new EventGroup(name:"10% fat + vehicle for 4 weeks") |
---|
491 | .addToEvents(evLF4) |
---|
492 | .addToEvents(evBV4) |
---|
493 | .addToEvents(evS4) |
---|
494 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
495 | |
---|
496 | def LFBL4 = new EventGroup(name:"10% fat + leptin for 4 weeks") |
---|
497 | .addToEvents(evLF4) |
---|
498 | .addToEvents(evBL4) |
---|
499 | .addToEvents(evS4) |
---|
500 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
501 | |
---|
502 | def HFBV4 = new EventGroup(name:"45% fat + vehicle for 4 weeks") |
---|
503 | .addToEvents(evHF4) |
---|
504 | .addToEvents(evBV4) |
---|
505 | .addToEvents(evS4) |
---|
506 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
507 | |
---|
508 | def HFBL4 = new EventGroup(name:"45% fat + leptin for 4 weeks") |
---|
509 | .addToEvents(evHF4) |
---|
510 | .addToEvents(evBL4) |
---|
511 | .addToEvents(evS4) |
---|
512 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
513 | |
---|
514 | // Add subjects and samples and compose EventGroups |
---|
515 | def x=1 |
---|
516 | 80.times { |
---|
517 | def currentSubject = new Subject( |
---|
518 | name: "A" + x++, |
---|
519 | species: mouseTerm, |
---|
520 | template: mouseTemplate, |
---|
521 | ) |
---|
522 | .setFieldValue("Gender", "Male") |
---|
523 | .setFieldValue("Genotype", c57bl6Term) |
---|
524 | .setFieldValue("Age (weeks)", 17) |
---|
525 | .setFieldValue("Cage", "" + (int)(x/2)) |
---|
526 | .with { if (!validate()) { errors.each { println it} } else save(flush:true)} |
---|
527 | |
---|
528 | mouseStudy.addToSubjects(currentSubject) |
---|
529 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
530 | |
---|
531 | // Add subject to appropriate EventGroup |
---|
532 | if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } |
---|
533 | else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } |
---|
534 | else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() } |
---|
535 | else if (x > 40) { LFBV4.addToSubjects(currentSubject).save() } |
---|
536 | else if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } |
---|
537 | else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } |
---|
538 | else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } |
---|
539 | else { LFBV1.addToSubjects(currentSubject).save() } |
---|
540 | |
---|
541 | } |
---|
542 | |
---|
543 | // Add EventGroups to study |
---|
544 | mouseStudy |
---|
545 | .addToEventGroups(LFBV1) |
---|
546 | .addToEventGroups(LFBL1) |
---|
547 | .addToEventGroups(HFBV1) |
---|
548 | .addToEventGroups(HFBL1) |
---|
549 | .addToEventGroups(LFBV4) |
---|
550 | .addToEventGroups(LFBL4) |
---|
551 | .addToEventGroups(HFBV4) |
---|
552 | .addToEventGroups(HFBL4) |
---|
553 | |
---|
554 | // Add persons to study |
---|
555 | def studyperson1 = new StudyPerson( person: person1, role: role1 ).save(); |
---|
556 | def studyperson2 = new StudyPerson( person: person2, role: role2 ).save(); |
---|
557 | |
---|
558 | mouseStudy |
---|
559 | .addToPersons( studyperson1 ) |
---|
560 | .addToPersons( studyperson2 ) |
---|
561 | .save() |
---|
562 | |
---|
563 | println ".adding NuGO PPSH example study..." |
---|
564 | |
---|
565 | def humanStudy = new Study( |
---|
566 | template: studyTemplate, |
---|
567 | title:"NuGO PPS human study", |
---|
568 | code:"PPSH", |
---|
569 | researchQuestion:"How much are fasting plasma and urine metabolite levels affected by prolonged fasting ?", |
---|
570 | description:"Human study", |
---|
571 | ecCode:"unknown", |
---|
572 | startDate: Date.parse('yyyy-MM-dd','2008-01-14')) |
---|
573 | .setFieldValue( 'Description', "Human study performed at RRI; centres involved: RRI, IFR, TUM, Maastricht U." ) |
---|
574 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
575 | |
---|
576 | def rootGroup = new EventGroup(name: 'Root group'); |
---|
577 | |
---|
578 | def fastingEvent = new Event( |
---|
579 | startTime: Date.parse('yyyy-MM-dd HH:mm','2008-01-14 22:00'), |
---|
580 | endTime: Date.parse('yyyy-MM-dd HH:mm','2008-01-15 08:00'), |
---|
581 | template: fastingTreatment) |
---|
582 | .setFieldValue('Fasting period','8h'); |
---|
583 | |
---|
584 | |
---|
585 | def bloodSamplingEvent = new SamplingEvent( |
---|
586 | startTime: Date.parse('yyyy-MM-dd HH:mm','2008-01-15 08:00'), |
---|
587 | endTime: Date.parse('yyyy-MM-dd HH:mm','2008-01-15 08:00'), |
---|
588 | template: bloodSamplingEventTemplate) |
---|
589 | .setFieldValue('Sample volume',4.5F); |
---|
590 | |
---|
591 | rootGroup.addToEvents fastingEvent |
---|
592 | rootGroup.addToEvents bloodSamplingEvent |
---|
593 | rootGroup.save() |
---|
594 | |
---|
595 | def y = 1 |
---|
596 | 11.times { |
---|
597 | def currentSubject = new Subject( |
---|
598 | name: "" + y++, |
---|
599 | species: humanTerm, |
---|
600 | template: humanTemplate) |
---|
601 | //.setFieldValue("Gender", ( (boolean) (y / 2) ? "Male" : "Female") ) |
---|
602 | .setFieldValue("DOB", new java.text.SimpleDateFormat("dd-mm-yy").parse("01-02-19" + (10 + (int) (Math.random() * 80)))) |
---|
603 | .setFieldValue("Age (years)", 30) |
---|
604 | .setFieldValue("Height", Math.random() * 2F) |
---|
605 | .setFieldValue("Weight (kg)", Math.random() * 150F) |
---|
606 | .setFieldValue("BMI", 20 + Math.random() * 10F) |
---|
607 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
608 | |
---|
609 | rootGroup.addToSubjects currentSubject |
---|
610 | rootGroup.save() |
---|
611 | |
---|
612 | def currentSample = new Sample( |
---|
613 | name: currentSubject.name + '_B', |
---|
614 | material: bloodTerm, |
---|
615 | parentSubject: currentSubject, |
---|
616 | parentEvent: bloodSamplingEvent); |
---|
617 | |
---|
618 | humanStudy.addToSubjects(currentSubject).addToSamples(currentSample).with { if (!validate()) { errors.each { println it} } else save()} |
---|
619 | } |
---|
620 | |
---|
621 | humanStudy.addToEvents(fastingEvent) |
---|
622 | humanStudy.addToSamplingEvents(bloodSamplingEvent) |
---|
623 | humanStudy.addToEventGroups rootGroup |
---|
624 | humanStudy.save() |
---|
625 | |
---|
626 | /* |
---|
627 | // Add clinical data |
---|
628 | |
---|
629 | def lipidAssay = new dbnp.clinicaldata.ClinicalAssay( |
---|
630 | name: 'Lipid profile', |
---|
631 | approved: true |
---|
632 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
633 | |
---|
634 | def ldlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( |
---|
635 | name: 'LDL', |
---|
636 | unit: 'mg/dL', |
---|
637 | type: dbnp.data.FeatureType.QUANTITATIVE, |
---|
638 | referenceValues: '100 mg/dL', |
---|
639 | detectableLimit: 250, |
---|
640 | isDrug: false, isIntake: true, inSerum: true |
---|
641 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
642 | |
---|
643 | def hdlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( |
---|
644 | name: 'HDL', |
---|
645 | unit: 'mg/dL', |
---|
646 | type: dbnp.data.FeatureType.QUANTITATIVE, |
---|
647 | referenceValues: '50 mg/dL', |
---|
648 | detectableLimit: 100, |
---|
649 | isDrug: false, isIntake: true, inSerum: true |
---|
650 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
651 | |
---|
652 | lipidAssay.addToMeasurements ldlMeasurement |
---|
653 | lipidAssay.addToMeasurements hdlMeasurement |
---|
654 | |
---|
655 | def lipidAssayInstance = new dbnp.clinicaldata.ClinicalAssayInstance( |
---|
656 | assay: lipidAssay |
---|
657 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
658 | |
---|
659 | humanStudy.samples*.each { |
---|
660 | new dbnp.clinicaldata.ClinicalFloatData( |
---|
661 | assay: lipidAssayInstance, |
---|
662 | measurement: ldlMeasurement, |
---|
663 | sample: it.name, |
---|
664 | value: Math.round(Math.random()*ldlMeasurement.detectableLimit) |
---|
665 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
666 | |
---|
667 | new dbnp.clinicaldata.ClinicalFloatData( |
---|
668 | assay: lipidAssayInstance, |
---|
669 | measurement: hdlMeasurement, |
---|
670 | sample: it.name, |
---|
671 | value: Math.round(Math.random()*hdlMeasurement.detectableLimit) |
---|
672 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
673 | } |
---|
674 | |
---|
675 | // Add assay to study capture module |
---|
676 | |
---|
677 | def clinicalModule = new AssayModule( |
---|
678 | name: 'Clinical data', |
---|
679 | type: AssayType.CLINICAL_DATA, |
---|
680 | platform: 'clinical measurements', |
---|
681 | url: 'http://localhost:8080/gscf' |
---|
682 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
683 | |
---|
684 | def lipidAssayRef = new Assay( |
---|
685 | name: 'Lipid profiling', |
---|
686 | module: clinicalModule, |
---|
687 | externalAssayId: lipidAssayInstance.id |
---|
688 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
689 | |
---|
690 | humanStudy.samples*.each { |
---|
691 | lipidAssayRef.addToSamples(it) |
---|
692 | } |
---|
693 | lipidAssayRef.save() |
---|
694 | |
---|
695 | humanStudy.addToAssays(lipidAssayRef); |
---|
696 | humanStudy.save() |
---|
697 | */ |
---|
698 | |
---|
699 | } |
---|
700 | } |
---|
701 | } |
---|
702 | |
---|
703 | def destroy = { |
---|
704 | } |
---|
705 | } |
---|