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: 458 $ |
---|
14 | * $Author: roberth $ |
---|
15 | * $Date: 2010-05-25 09:18:21 +0000 (di, 25 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 | institute: "Science Institute NYC", |
---|
93 | department: "Department of Mathematics" |
---|
94 | ).save(); |
---|
95 | def affiliation2 = new PersonAffiliation( |
---|
96 | institute: "InfoStats GmbH, Hamburg", |
---|
97 | department: "Life Sciences" |
---|
98 | ).save(); |
---|
99 | def role1 = new PersonRole( |
---|
100 | name: "Principal Investigator" |
---|
101 | ).save(); |
---|
102 | def role2 = new PersonRole( |
---|
103 | name: "Statician" |
---|
104 | ).save(); |
---|
105 | |
---|
106 | // Create persons |
---|
107 | def person1 = new Person( |
---|
108 | lastName: "Scientist", |
---|
109 | firstName: "John", |
---|
110 | gender: "Male", |
---|
111 | initials: "J.R.", |
---|
112 | email: "john@scienceinstitute.com", |
---|
113 | phone: "1-555-3049", |
---|
114 | address: "First street 2,NYC" |
---|
115 | ) |
---|
116 | .addToAffiliations( affiliation1 ) |
---|
117 | .addToAffiliations( affiliation2 ) |
---|
118 | .save(); |
---|
119 | |
---|
120 | def person2 = new Person( |
---|
121 | lastName: "Statician", |
---|
122 | firstName: "Jane", |
---|
123 | gender: "Female", |
---|
124 | initials: "W.J.", |
---|
125 | email: "jane@statisticalcompany.de", |
---|
126 | phone: "49-555-8291", |
---|
127 | address: "Dritten strasse 38, Hamburg, Germany" |
---|
128 | ) |
---|
129 | .addToAffiliations( affiliation2 ) |
---|
130 | .save(); |
---|
131 | |
---|
132 | // Create 30 persons to test pagination |
---|
133 | def personCounter = 1; |
---|
134 | 30.times { new Person( firstName: "Person #${personCounter}", lastName: "Testperson", email: "email${personCounter++}@testdomain.com" ).save() } |
---|
135 | |
---|
136 | // Create a few publications |
---|
137 | println ".adding publications" |
---|
138 | def publication1 = new Publication( |
---|
139 | title: "Postnatal development of hypothalamic leptin receptors", |
---|
140 | authorsList: "Cottrell EC, Mercer JG, Ozanne SE.", |
---|
141 | pubMedID: "20472140", |
---|
142 | comments: "Not published yet", |
---|
143 | DOI: "unknown" |
---|
144 | ) |
---|
145 | .save(); |
---|
146 | |
---|
147 | def publication2 = new Publication( |
---|
148 | title: "Induction of regulatory T cells decreases adipose inflammation and alleviates insulin resistance in ob/ob mice", |
---|
149 | authorsList: "Ilan Y, Maron R, Tukpah AM, Maioli TU, Murugaiyan G, Yang K, Wu HY, Weiner HL.", |
---|
150 | pubMedID: "20445103", |
---|
151 | comments: "", |
---|
152 | DOI: "" |
---|
153 | ) |
---|
154 | .save(); |
---|
155 | |
---|
156 | // Create templates |
---|
157 | |
---|
158 | def genderField = new TemplateField( |
---|
159 | name: 'Gender',type: TemplateFieldType.STRINGLIST, |
---|
160 | listEntries: [new TemplateFieldListItem(name:'Male'),new TemplateFieldListItem(name: 'Female'),new TemplateFieldListItem(name: 'Unknown')]) |
---|
161 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
162 | |
---|
163 | def ageField = new TemplateField( |
---|
164 | name: 'Age',type: TemplateFieldType.INTEGER,unit: 'years',comment: 'Either include age at the start of the study or date of birth (if known)') |
---|
165 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
166 | |
---|
167 | def genotypeField = new TemplateField( |
---|
168 | name: 'Genotype', type: TemplateFieldType.ONTOLOGYTERM, |
---|
169 | comment: 'If present, indicate the genetic variance of the subject (the gene knock-out/in or transgene)') |
---|
170 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
171 | |
---|
172 | def genotypeTypeField = new TemplateField( |
---|
173 | name: 'Genotype type',type: TemplateFieldType.STRINGLIST, |
---|
174 | listEntries: [new TemplateFieldListItem(name:'wildtype'), |
---|
175 | new TemplateFieldListItem(name:'transgenic'), |
---|
176 | new TemplateFieldListItem(name:'knock-out'), |
---|
177 | new TemplateFieldListItem(name:'knock-in')], |
---|
178 | comment: 'If a genotype was specified, please indicate here the type of the genotype') |
---|
179 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
180 | |
---|
181 | |
---|
182 | // Nutritional study template |
---|
183 | |
---|
184 | println ".adding academic study template..." |
---|
185 | def studyTemplate = new Template( |
---|
186 | name: 'Academic study', entity: dbnp.studycapturing.Study) |
---|
187 | .addToFields(new TemplateField(name: 'Description',type: TemplateFieldType.TEXT,comment:'Describe here the type of subjects and the treatment, challenges and sampling.')) |
---|
188 | .addToFields(new TemplateField( |
---|
189 | name: 'Study code', |
---|
190 | type: TemplateFieldType.STRING, |
---|
191 | preferredIdentifier:true, |
---|
192 | comment: 'Fill out the code by which many people will recognize your study')) |
---|
193 | .addToFields(new TemplateField(name: 'Objectives',type: TemplateFieldType.TEXT,comment:'Fill out the aim or questions of the study')) |
---|
194 | .addToFields(new TemplateField(name: 'Consortium',type: TemplateFieldType.STRING,comment:'If the study was performed within a consortium (e.g. NMC, NuGO), you can indicate this here')) |
---|
195 | .addToFields(new TemplateField(name: 'Cohort name',type: TemplateFieldType.STRING,comment:'If a cohort was used the name or code of the cohort can be define here (define a cohort template)')) |
---|
196 | //.addToFields(new TemplateField(name: 'Time zone',type: TemplateFieldType.STRING,comment:'In the database the local time will be stored. This field is essential to be able to generalize time.')) |
---|
197 | .addToFields(new TemplateField(name: 'Responsible scientist',type: TemplateFieldType.STRING,comment:'Fill out the project leader of principle investigator of the study. (soon to be replaced with persons input)')) |
---|
198 | .addToFields(new TemplateField(name: 'Lab id',type: TemplateFieldType.STRING,comment:'In which lab was the study performed; indicate the roomnumber.')) |
---|
199 | .addToFields(new TemplateField(name: 'Institute',type: TemplateFieldType.STRING,comment:'In which institute was the study performed; indicate the full address information (to be replaced by persons-affiliations?)')) |
---|
200 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
201 | |
---|
202 | // Mouse template |
---|
203 | println ".adding mouse subject template..." |
---|
204 | def mouseTemplate = new Template( |
---|
205 | name: 'Mouse', entity: dbnp.studycapturing.Subject) |
---|
206 | .addToFields(new TemplateField( |
---|
207 | name: 'Strain', type: TemplateFieldType.ONTOLOGYTERM, ontologies: [nciOntology], comment: "This is an ontology term, if the right strain is not in the list please add it with 'add more'")) |
---|
208 | .addToFields(genotypeField) |
---|
209 | .addToFields(genotypeTypeField) |
---|
210 | .addToFields(genderField) |
---|
211 | .addToFields(new TemplateField( |
---|
212 | name: 'Age', type: TemplateFieldType.INTEGER, unit: 'weeks', comment: 'Age at start of study')) |
---|
213 | .addToFields(new TemplateField( |
---|
214 | name: 'Age type',type: TemplateFieldType.STRINGLIST, |
---|
215 | listEntries: [new TemplateFieldListItem(name:'postnatal'),new TemplateFieldListItem(name:'embryonal')])) |
---|
216 | .addToFields(new TemplateField( |
---|
217 | name: 'Cage',type: TemplateFieldType.STRING,comment:'Indicate the cage used for housing (type and/or size)')) |
---|
218 | .addToFields(new TemplateField( |
---|
219 | name: '#Mice in cage',type: TemplateFieldType.INTEGER,comment:'If known, indicate the number of mice per cage')) |
---|
220 | .addToFields(new TemplateField( |
---|
221 | name: 'Litter size',type: TemplateFieldType.INTEGER,comment:'If known, indicate the litter size of the litter from which the subject originates')) |
---|
222 | .addToFields(new TemplateField( |
---|
223 | name: 'Weight', type: TemplateFieldType.DOUBLE, unit: 'gram',comment:'If known indicate the weight of the subject in grams at the start of the study')) |
---|
224 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
225 | |
---|
226 | // Human template |
---|
227 | println ".adding human subject template..." |
---|
228 | def humanTemplate = new Template( |
---|
229 | name: 'Human', entity: dbnp.studycapturing.Subject) |
---|
230 | .addToFields(genderField) |
---|
231 | .addToFields(ageField) |
---|
232 | .addToFields(new TemplateField( |
---|
233 | name: 'DOB',type: TemplateFieldType.DATE,comment:'Date of birth')) |
---|
234 | .addToFields(new TemplateField( |
---|
235 | name: 'Height',type: TemplateFieldType.DOUBLE, unit: 'm')) |
---|
236 | .addToFields(new TemplateField( |
---|
237 | name: 'Weight',type: TemplateFieldType.DOUBLE, unit: 'kg')) |
---|
238 | .addToFields(new TemplateField( |
---|
239 | name: 'BMI',type: TemplateFieldType.DOUBLE, unit: 'kg/m2',comment:'Body-mass-index')) |
---|
240 | .addToFields(new TemplateField( |
---|
241 | name: 'Race',type: TemplateFieldType.STRING,comment:'If known and of interest the ethnic group can be indicated')) |
---|
242 | .addToFields(new TemplateField( |
---|
243 | name: 'Waist circumference',type: TemplateFieldType.FLOAT, unit: 'cm',comment:'The waist circumference is measured just above the hip bone. Indicate the measure at the start of the study.')) |
---|
244 | .addToFields(new TemplateField( |
---|
245 | name: 'Hip circumference',type: TemplateFieldType.FLOAT, unit: 'cm',comment:'The hip circumference is measured at the level of the two bony prominences front of the hips. Indicate the measure at the start of the study.')) |
---|
246 | .addToFields(new TemplateField( |
---|
247 | name: 'Systolic blood pressure',type: TemplateFieldType.FLOAT, unit: 'mmHg',comment:'Indicate the levels at the start of the study in mmHG')) |
---|
248 | .addToFields(new TemplateField( |
---|
249 | name: 'Diastolic blood pressure',type: TemplateFieldType.FLOAT, unit: 'mmHg',comment:'Indicate the levels at the start of the study in mmHG')) |
---|
250 | .addToFields(new TemplateField( |
---|
251 | name: 'Heart rate',type: TemplateFieldType.FLOAT, unit: 'beats/min',comment:'Indicate the heart rate at the start of in study in beats per minute')) |
---|
252 | .addToFields(new TemplateField( |
---|
253 | name: 'Run-in-food',type: TemplateFieldType.TEXT,comment:'If defined, give a short description of the food used before the measurements')) |
---|
254 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
255 | |
---|
256 | |
---|
257 | def sampleDescriptionField = new TemplateField( |
---|
258 | name: 'Description',type: TemplateFieldType.TEXT) |
---|
259 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
260 | def sampleTypeField = new TemplateField( |
---|
261 | name: 'SampleType',type: TemplateFieldType.STRING) |
---|
262 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
263 | def sampleProtocolField = new TemplateField( |
---|
264 | name: 'SampleProtocol',type: TemplateFieldType.STRING) |
---|
265 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
266 | def sampleVialTextField = new TemplateField( |
---|
267 | name: 'Text on vial',type: TemplateFieldType.STRING) |
---|
268 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
269 | |
---|
270 | // Human sample template |
---|
271 | println ".adding human sample template..." |
---|
272 | def humanSampleTemplate = new Template( |
---|
273 | name: 'Human tissue sample', entity: dbnp.studycapturing.Sample) |
---|
274 | .addToFields(sampleDescriptionField) |
---|
275 | .addToFields(sampleTypeField) |
---|
276 | .addToFields(sampleProtocolField) |
---|
277 | .addToFields(sampleVialTextField) |
---|
278 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
279 | |
---|
280 | //Plant template |
---|
281 | println ".adding plant template..." |
---|
282 | def plantTemplate = new Template( |
---|
283 | name: 'Plant template', entity: dbnp.studycapturing.Subject) |
---|
284 | .addToFields(new TemplateField( |
---|
285 | name: 'Variety', type: TemplateFieldType.STRING)) |
---|
286 | .addToFields(new TemplateField( |
---|
287 | name: 'Ecotype', type: TemplateFieldType.STRING)) |
---|
288 | .addToFields(genotypeField) |
---|
289 | .addToFields(genotypeTypeField) |
---|
290 | .addToFields(new TemplateField( |
---|
291 | name: 'Growth location', type: TemplateFieldType.STRINGLIST, |
---|
292 | listEntries: [new TemplateFieldListItem(name:'Greenhouse'),new TemplateFieldListItem(name: 'Field')])) |
---|
293 | .addToFields(new TemplateField( |
---|
294 | name: 'Room', type: TemplateFieldType.STRING, |
---|
295 | comment: 'Chamber number in case of Greenhouse')) |
---|
296 | .addToFields(new TemplateField( |
---|
297 | name: 'Position X', type: TemplateFieldType.FLOAT)) |
---|
298 | .addToFields(new TemplateField( |
---|
299 | name: 'Position Y', type: TemplateFieldType.FLOAT)) |
---|
300 | .addToFields(new TemplateField( |
---|
301 | name: 'Block', type: TemplateFieldType.STRING)) |
---|
302 | .addToFields(new TemplateField( |
---|
303 | name: 'Temperature at day', type: TemplateFieldType.FLOAT)) |
---|
304 | .addToFields(new TemplateField( |
---|
305 | name: 'Temperature at night', type: TemplateFieldType.FLOAT)) |
---|
306 | .addToFields(new TemplateField( |
---|
307 | name: 'Photo period', type: TemplateFieldType.STRING)) |
---|
308 | .addToFields(new TemplateField( |
---|
309 | name: 'Light intensity', type: TemplateFieldType.STRING)) |
---|
310 | .addToFields(new TemplateField( |
---|
311 | name: 'Start date', type: TemplateFieldType.DATE)) |
---|
312 | .addToFields(new TemplateField( |
---|
313 | name: 'Harvest date', type: TemplateFieldType.DATE)) |
---|
314 | .addToFields(new TemplateField( |
---|
315 | name: 'Growth type', type: TemplateFieldType.STRINGLIST, |
---|
316 | listEntries: [new TemplateFieldListItem(name:'Standard'),new TemplateFieldListItem(name: 'Experimental')])) |
---|
317 | .addToFields(new TemplateField( |
---|
318 | name: 'Growth protocol', type: TemplateFieldType.TEXT)) |
---|
319 | .addToFields(new TemplateField( |
---|
320 | name: 'Harvest delay', type: TemplateFieldType.TEXT)) |
---|
321 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
322 | |
---|
323 | println ".adding plant sample template..." |
---|
324 | def plantSampleTemplate = new Template( |
---|
325 | name: 'Plant sample', entity: dbnp.studycapturing.Sample) |
---|
326 | .addToFields(sampleDescriptionField) |
---|
327 | .addToFields(sampleTypeField) |
---|
328 | .addToFields(sampleProtocolField) |
---|
329 | .addToFields(sampleVialTextField) |
---|
330 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
331 | |
---|
332 | |
---|
333 | // Event templates |
---|
334 | def dietTreatmentTemplate = new Template( |
---|
335 | name: 'Diet treatment', entity: dbnp.studycapturing.Event) |
---|
336 | .addToFields(sampleDescriptionField) |
---|
337 | .addToFields(new TemplateField( |
---|
338 | name: 'Diet', type: TemplateFieldType.STRINGLIST, |
---|
339 | listEntries: [new TemplateFieldListItem(name:'10% fat (palm oil)'),new TemplateFieldListItem(name: '45% fat (palm oil)')])) |
---|
340 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
341 | |
---|
342 | def boostTreatmentTemplate = new Template( |
---|
343 | name: 'Boost treatment', entity: dbnp.studycapturing.Event) |
---|
344 | .addToFields(sampleDescriptionField) |
---|
345 | .addToFields(new TemplateField( |
---|
346 | name: 'Compound', type: TemplateFieldType.STRING, |
---|
347 | listEntries: [new TemplateFieldListItem(name:'Vehicle'),new TemplateFieldListItem(name: 'Leptin')])) |
---|
348 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
349 | |
---|
350 | def fastingTreatment = new Template( |
---|
351 | name: 'Fasting treatment', |
---|
352 | description: 'Fasting Protocol NuGO PPSH', |
---|
353 | entity: dbnp.studycapturing.Event) |
---|
354 | .addToFields(new TemplateField( |
---|
355 | name: 'Fasting period', |
---|
356 | type: TemplateFieldType.STRING)) |
---|
357 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
358 | |
---|
359 | // SamplingEvent templates |
---|
360 | |
---|
361 | def liverSamplingEventTemplate = new Template( |
---|
362 | name: 'Liver extraction', |
---|
363 | description: 'Liver sampling for transcriptomics arrays', |
---|
364 | entity: dbnp.studycapturing.SamplingEvent) |
---|
365 | .addToFields(new TemplateField( |
---|
366 | name: 'Sample weight', |
---|
367 | unit: 'mg', |
---|
368 | type: TemplateFieldType.FLOAT)) |
---|
369 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
370 | |
---|
371 | def bloodSamplingEventTemplate = new Template( |
---|
372 | name: 'Blood extraction', |
---|
373 | description: 'Blood extraction targeted at lipid assays', |
---|
374 | entity: dbnp.studycapturing.SamplingEvent) |
---|
375 | .addToFields(new TemplateField( |
---|
376 | name: 'Sample volume', |
---|
377 | unit: 'ml', |
---|
378 | type: TemplateFieldType.FLOAT)) |
---|
379 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
380 | |
---|
381 | |
---|
382 | // Add example studies |
---|
383 | if (!(grails.util.GrailsUtil.environment == GrailsApplication.ENV_TEST)) { |
---|
384 | println ".adding NuGO PPS3 leptin example study..." |
---|
385 | def mouseStudy = new Study( |
---|
386 | template: studyTemplate, |
---|
387 | title:"NuGO PPS3 mouse study leptin module", |
---|
388 | code:"PPS3_leptin_module", |
---|
389 | researchQuestion:"Leptin etc.", |
---|
390 | ecCode:"2007117.c", |
---|
391 | startDate: Date.parse('yyyy-MM-dd','2007-12-11') |
---|
392 | ) |
---|
393 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
394 | |
---|
395 | 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." ) |
---|
396 | mouseStudy.save() |
---|
397 | |
---|
398 | def evLF = new Event( |
---|
399 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
400 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
401 | template: dietTreatmentTemplate |
---|
402 | ) |
---|
403 | .setFieldValue( 'Diet','10% fat (palm oil)') |
---|
404 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
405 | |
---|
406 | def evHF = new Event( |
---|
407 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
408 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
409 | template: dietTreatmentTemplate |
---|
410 | ) |
---|
411 | .setFieldValue( 'Diet','45% fat (palm oil)' ) |
---|
412 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
413 | |
---|
414 | def evBV = new Event( |
---|
415 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
416 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
417 | template: boostTreatmentTemplate |
---|
418 | ) |
---|
419 | .setFieldValue( 'Compound','Vehicle' ) |
---|
420 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
421 | |
---|
422 | def evBL = new Event( |
---|
423 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
424 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
425 | template: boostTreatmentTemplate |
---|
426 | ) |
---|
427 | .setFieldValue( 'Compound','Leptin' ) |
---|
428 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
429 | |
---|
430 | def evLF4 = new Event( |
---|
431 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
432 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
433 | template: dietTreatmentTemplate |
---|
434 | ) |
---|
435 | .setFieldValue( 'Diet','10% fat (palm oil)') |
---|
436 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
437 | |
---|
438 | def evHF4 = new Event( |
---|
439 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
440 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
441 | template: dietTreatmentTemplate |
---|
442 | ) |
---|
443 | .setFieldValue( 'Diet','45% fat (palm oil)' ) |
---|
444 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
445 | |
---|
446 | def evBV4 = new Event( |
---|
447 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
448 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
449 | template: boostTreatmentTemplate |
---|
450 | ) |
---|
451 | .setFieldValue( 'Compound','Vehicle' ) |
---|
452 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
453 | |
---|
454 | def evBL4 = new Event( |
---|
455 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
456 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
457 | template: boostTreatmentTemplate |
---|
458 | ) |
---|
459 | .setFieldValue( 'Compound','Leptin' ) |
---|
460 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
461 | |
---|
462 | def evS = new SamplingEvent( |
---|
463 | startTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
464 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
465 | template: liverSamplingEventTemplate) |
---|
466 | .setFieldValue('Sample weight',5F) |
---|
467 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
468 | |
---|
469 | def evS4 = new SamplingEvent( |
---|
470 | startTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
471 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
472 | template: liverSamplingEventTemplate) |
---|
473 | .setFieldValue('Sample weight',5F) |
---|
474 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
475 | |
---|
476 | // Add events to study |
---|
477 | mouseStudy |
---|
478 | .addToEvents(evLF) |
---|
479 | .addToEvents(evHF) |
---|
480 | .addToEvents(evBV) |
---|
481 | .addToEvents(evBL) |
---|
482 | .addToEvents(evLF4) |
---|
483 | .addToEvents(evHF4) |
---|
484 | .addToEvents(evBV4) |
---|
485 | .addToEvents(evBL4) |
---|
486 | .addToSamplingEvents(evS) |
---|
487 | .addToSamplingEvents(evS4) |
---|
488 | .save() |
---|
489 | |
---|
490 | def LFBV1 = new EventGroup(name:"10% fat + vehicle for 1 week") |
---|
491 | .addToEvents(evLF) |
---|
492 | .addToEvents(evBV) |
---|
493 | .addToEvents(evS) |
---|
494 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
495 | |
---|
496 | def LFBL1 = new EventGroup(name:"10% fat + leptin for 1 week") |
---|
497 | .addToEvents(evLF) |
---|
498 | .addToEvents(evBL) |
---|
499 | .addToEvents(evS) |
---|
500 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
501 | |
---|
502 | def HFBV1 = new EventGroup(name:"45% fat + vehicle for 1 week") |
---|
503 | .addToEvents(evHF) |
---|
504 | .addToEvents(evBV) |
---|
505 | .addToEvents(evS) |
---|
506 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
507 | |
---|
508 | def HFBL1 = new EventGroup(name:"45% fat + leptin for 1 week") |
---|
509 | .addToEvents(evHF) |
---|
510 | .addToEvents(evBL) |
---|
511 | .addToEvents(evS) |
---|
512 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
513 | |
---|
514 | def LFBV4 = new EventGroup(name:"10% fat + vehicle for 4 weeks") |
---|
515 | .addToEvents(evLF4) |
---|
516 | .addToEvents(evBV4) |
---|
517 | .addToEvents(evS4) |
---|
518 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
519 | |
---|
520 | def LFBL4 = new EventGroup(name:"10% fat + leptin for 4 weeks") |
---|
521 | .addToEvents(evLF4) |
---|
522 | .addToEvents(evBL4) |
---|
523 | .addToEvents(evS4) |
---|
524 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
525 | |
---|
526 | def HFBV4 = new EventGroup(name:"45% fat + vehicle for 4 weeks") |
---|
527 | .addToEvents(evHF4) |
---|
528 | .addToEvents(evBV4) |
---|
529 | .addToEvents(evS4) |
---|
530 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
531 | |
---|
532 | def HFBL4 = new EventGroup(name:"45% fat + leptin for 4 weeks") |
---|
533 | .addToEvents(evHF4) |
---|
534 | .addToEvents(evBL4) |
---|
535 | .addToEvents(evS4) |
---|
536 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
537 | |
---|
538 | // Add subjects and samples and compose EventGroups |
---|
539 | def x=1 |
---|
540 | 20.times { |
---|
541 | def currentSubject = new Subject( |
---|
542 | name: "A" + x++, |
---|
543 | species: mouseTerm, |
---|
544 | template: mouseTemplate, |
---|
545 | ) |
---|
546 | .setFieldValue("Gender", "Male") |
---|
547 | .setFieldValue("Genotype", c57bl6Term) |
---|
548 | .setFieldValue("Age", 17) |
---|
549 | .setFieldValue("Cage", "" + (int)(x/2)) |
---|
550 | .with { if (!validate()) { errors.each { println it} } else save(flush:true)} |
---|
551 | |
---|
552 | mouseStudy.addToSubjects(currentSubject) |
---|
553 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
554 | |
---|
555 | // Add subject to appropriate EventGroup |
---|
556 | if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } |
---|
557 | else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } |
---|
558 | else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() } |
---|
559 | else if (x > 40) { LFBV4.addToSubjects(currentSubject).save() } |
---|
560 | else if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } |
---|
561 | else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } |
---|
562 | else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } |
---|
563 | else { LFBV1.addToSubjects(currentSubject).save() } |
---|
564 | |
---|
565 | } |
---|
566 | |
---|
567 | // Add EventGroups to study |
---|
568 | mouseStudy |
---|
569 | .addToEventGroups(LFBV1) |
---|
570 | .addToEventGroups(LFBL1) |
---|
571 | .addToEventGroups(HFBV1) |
---|
572 | .addToEventGroups(HFBL1) |
---|
573 | .addToEventGroups(LFBV4) |
---|
574 | .addToEventGroups(LFBL4) |
---|
575 | .addToEventGroups(HFBV4) |
---|
576 | .addToEventGroups(HFBL4) |
---|
577 | |
---|
578 | // Add persons and publications to study |
---|
579 | def studyperson1 = new StudyPerson( person: person1, role: role1 ).save(); |
---|
580 | def studyperson2 = new StudyPerson( person: person2, role: role2 ).save(); |
---|
581 | |
---|
582 | mouseStudy |
---|
583 | .addToPersons( studyperson1 ) |
---|
584 | .addToPersons( studyperson2 ) |
---|
585 | .addToPublications( publication1 ) |
---|
586 | .addToPublications( publication2 ) |
---|
587 | .save() |
---|
588 | |
---|
589 | println ".adding NuGO PPSH example study..." |
---|
590 | |
---|
591 | def humanStudy = new Study( |
---|
592 | template: studyTemplate, |
---|
593 | title:"NuGO PPS human study", |
---|
594 | code:"PPSH", |
---|
595 | researchQuestion:"How much are fasting plasma and urine metabolite levels affected by prolonged fasting ?", |
---|
596 | description:"Human study", |
---|
597 | ecCode:"unknown", |
---|
598 | startDate: Date.parse('yyyy-MM-dd','2008-01-14')) |
---|
599 | .setFieldValue( 'Description', "Human study performed at RRI; centres involved: RRI, IFR, TUM, Maastricht U." ) |
---|
600 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
601 | |
---|
602 | def rootGroup = new EventGroup(name: 'Root group'); |
---|
603 | |
---|
604 | def fastingEvent = new Event( |
---|
605 | startTime: Date.parse('yyyy-MM-dd HH:mm','2008-01-14 22:00'), |
---|
606 | endTime: Date.parse('yyyy-MM-dd HH:mm','2008-01-15 08:00'), |
---|
607 | template: fastingTreatment) |
---|
608 | .setFieldValue('Fasting period','8h'); |
---|
609 | |
---|
610 | |
---|
611 | def bloodSamplingEvent = new SamplingEvent( |
---|
612 | startTime: Date.parse('yyyy-MM-dd HH:mm','2008-01-15 08:00'), |
---|
613 | endTime: Date.parse('yyyy-MM-dd HH:mm','2008-01-15 08:00'), |
---|
614 | template: bloodSamplingEventTemplate) |
---|
615 | .setFieldValue('Sample volume',4.5F); |
---|
616 | |
---|
617 | rootGroup.addToEvents fastingEvent |
---|
618 | rootGroup.addToEvents bloodSamplingEvent |
---|
619 | rootGroup.save() |
---|
620 | |
---|
621 | def y = 1 |
---|
622 | 11.times { |
---|
623 | def currentSubject = new Subject( |
---|
624 | name: "" + y++, |
---|
625 | species: humanTerm, |
---|
626 | template: humanTemplate) |
---|
627 | .setFieldValue("Gender", (Math.random() > 0.5) ? "Male" : "Female") |
---|
628 | .setFieldValue("DOB", new java.text.SimpleDateFormat("dd-mm-yy").parse("01-02-19" + (10 + (int) (Math.random() * 80)))) |
---|
629 | .setFieldValue("Age", 30) |
---|
630 | .setFieldValue("Height", Math.random() * 2F) |
---|
631 | .setFieldValue("Weight", Math.random() * 150F) |
---|
632 | .setFieldValue("BMI", 20 + Math.random() * 10F) |
---|
633 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
634 | |
---|
635 | rootGroup.addToSubjects currentSubject |
---|
636 | rootGroup.save() |
---|
637 | |
---|
638 | def currentSample = new Sample( |
---|
639 | name: currentSubject.name + '_B', |
---|
640 | material: bloodTerm, |
---|
641 | parentSubject: currentSubject, |
---|
642 | parentEvent: bloodSamplingEvent); |
---|
643 | |
---|
644 | humanStudy.addToSubjects(currentSubject).addToSamples(currentSample).with { if (!validate()) { errors.each { println it} } else save()} |
---|
645 | } |
---|
646 | |
---|
647 | humanStudy.addToEvents(fastingEvent) |
---|
648 | humanStudy.addToSamplingEvents(bloodSamplingEvent) |
---|
649 | humanStudy.addToEventGroups rootGroup |
---|
650 | |
---|
651 | |
---|
652 | // Add persons to study |
---|
653 | def studyperson3 = new StudyPerson( person: person1, role: role2 ).save(); |
---|
654 | |
---|
655 | humanStudy |
---|
656 | .addToPersons( studyperson3 ) |
---|
657 | .addToPublications( publication2 ) |
---|
658 | .save() |
---|
659 | |
---|
660 | /* |
---|
661 | // Add clinical data |
---|
662 | |
---|
663 | def lipidAssay = new dbnp.clinicaldata.ClinicalAssay( |
---|
664 | name: 'Lipid profile', |
---|
665 | approved: true |
---|
666 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
667 | |
---|
668 | def ldlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( |
---|
669 | name: 'LDL', |
---|
670 | unit: 'mg/dL', |
---|
671 | type: dbnp.data.FeatureType.QUANTITATIVE, |
---|
672 | referenceValues: '100 mg/dL', |
---|
673 | detectableLimit: 250, |
---|
674 | isDrug: false, isIntake: true, inSerum: true |
---|
675 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
676 | |
---|
677 | def hdlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( |
---|
678 | name: 'HDL', |
---|
679 | unit: 'mg/dL', |
---|
680 | type: dbnp.data.FeatureType.QUANTITATIVE, |
---|
681 | referenceValues: '50 mg/dL', |
---|
682 | detectableLimit: 100, |
---|
683 | isDrug: false, isIntake: true, inSerum: true |
---|
684 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
685 | |
---|
686 | lipidAssay.addToMeasurements ldlMeasurement |
---|
687 | lipidAssay.addToMeasurements hdlMeasurement |
---|
688 | |
---|
689 | def lipidAssayInstance = new dbnp.clinicaldata.ClinicalAssayInstance( |
---|
690 | assay: lipidAssay |
---|
691 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
692 | |
---|
693 | humanStudy.samples*.each { |
---|
694 | new dbnp.clinicaldata.ClinicalFloatData( |
---|
695 | assay: lipidAssayInstance, |
---|
696 | measurement: ldlMeasurement, |
---|
697 | sample: it.name, |
---|
698 | value: Math.round(Math.random()*ldlMeasurement.detectableLimit) |
---|
699 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
700 | |
---|
701 | new dbnp.clinicaldata.ClinicalFloatData( |
---|
702 | assay: lipidAssayInstance, |
---|
703 | measurement: hdlMeasurement, |
---|
704 | sample: it.name, |
---|
705 | value: Math.round(Math.random()*hdlMeasurement.detectableLimit) |
---|
706 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
707 | } |
---|
708 | */ |
---|
709 | // Add assay to study capture module |
---|
710 | |
---|
711 | def clinicalModule = new AssayModule( |
---|
712 | name: 'Clinical data', |
---|
713 | type: AssayType.CLINICAL_DATA, |
---|
714 | platform: 'clinical measurements', |
---|
715 | url: 'http://localhost:8080/gscf' |
---|
716 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
717 | |
---|
718 | def lipidAssayRef = new Assay( |
---|
719 | name: 'Lipid profiling', |
---|
720 | module: clinicalModule, |
---|
721 | externalAssayId: 0 |
---|
722 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
723 | |
---|
724 | humanStudy.samples*.each { |
---|
725 | lipidAssayRef.addToSamples(it) |
---|
726 | } |
---|
727 | lipidAssayRef.save() |
---|
728 | |
---|
729 | humanStudy.addToAssays(lipidAssayRef); |
---|
730 | humanStudy.save() |
---|
731 | |
---|
732 | mouseStudy.addToAssays(lipidAssayRef); |
---|
733 | mouseStudy.save() |
---|
734 | |
---|
735 | } |
---|
736 | } |
---|
737 | |
---|
738 | // Ontologies must be connected to the templatefields in runtime |
---|
739 | // because the Ontology.findByNcboId is not available otherwise |
---|
740 | TemplateEntity.getField( Subject.domainFields, 'species' ).ontologies = [Ontology.findByNcboId(1132)] |
---|
741 | TemplateEntity.getField( Sample.domainFields, 'material' ).ontologies = [Ontology.findByNcboId(1005)] |
---|
742 | |
---|
743 | } |
---|
744 | |
---|
745 | def destroy = { |
---|
746 | } |
---|
747 | } |
---|