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: 524 $ |
---|
14 | * $Author: duh $ |
---|
15 | * $Date: 2010-06-04 08:42:28 +0000 (vr, 04 jun 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.STRING, |
---|
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 | //commented out because of bug #84:.addToFields(new TemplateField(name: 'Study protocol',type: TemplateFieldType.FILE,comment:'Optionally attach a file in which the protocol in the study is described')) |
---|
201 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
202 | |
---|
203 | // Mouse template |
---|
204 | println ".adding mouse subject template..." |
---|
205 | def mouseTemplate = new Template( |
---|
206 | name: 'Mouse', entity: dbnp.studycapturing.Subject) |
---|
207 | .addToFields(new TemplateField( |
---|
208 | 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'")) |
---|
209 | .addToFields(genotypeField) |
---|
210 | .addToFields(genotypeTypeField) |
---|
211 | .addToFields(genderField) |
---|
212 | .addToFields(new TemplateField( |
---|
213 | name: 'Age', type: TemplateFieldType.INTEGER, unit: 'weeks', comment: 'Age at start of study')) |
---|
214 | .addToFields(new TemplateField( |
---|
215 | name: 'Age type',type: TemplateFieldType.STRINGLIST, |
---|
216 | listEntries: [new TemplateFieldListItem(name:'postnatal'),new TemplateFieldListItem(name:'embryonal')])) |
---|
217 | .addToFields(new TemplateField( |
---|
218 | name: 'Cage',type: TemplateFieldType.STRING,comment:'Indicate the cage used for housing (type and/or size)')) |
---|
219 | .addToFields(new TemplateField( |
---|
220 | name: '#Mice in cage',type: TemplateFieldType.INTEGER,comment:'If known, indicate the number of mice per cage')) |
---|
221 | .addToFields(new TemplateField( |
---|
222 | name: 'Litter size',type: TemplateFieldType.INTEGER,comment:'If known, indicate the litter size of the litter from which the subject originates')) |
---|
223 | .addToFields(new TemplateField( |
---|
224 | name: 'Weight', type: TemplateFieldType.DOUBLE, unit: 'gram',comment:'If known indicate the weight of the subject in grams at the start of the study')) |
---|
225 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
226 | |
---|
227 | // Human template |
---|
228 | println ".adding human subject template..." |
---|
229 | def humanTemplate = new Template( |
---|
230 | name: 'Human', entity: dbnp.studycapturing.Subject) |
---|
231 | .addToFields(genderField) |
---|
232 | .addToFields(ageField) |
---|
233 | .addToFields(new TemplateField( |
---|
234 | name: 'DOB',type: TemplateFieldType.DATE,comment:'Date of birth')) |
---|
235 | .addToFields(new TemplateField( |
---|
236 | name: 'Height',type: TemplateFieldType.DOUBLE, unit: 'm')) |
---|
237 | .addToFields(new TemplateField( |
---|
238 | name: 'Weight',type: TemplateFieldType.DOUBLE, unit: 'kg')) |
---|
239 | .addToFields(new TemplateField( |
---|
240 | name: 'BMI',type: TemplateFieldType.DOUBLE, unit: 'kg/m2',comment:'Body-mass-index')) |
---|
241 | .addToFields(new TemplateField( |
---|
242 | name: 'Race',type: TemplateFieldType.STRING,comment:'If known and of interest the ethnic group can be indicated')) |
---|
243 | .addToFields(new TemplateField( |
---|
244 | 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.')) |
---|
245 | .addToFields(new TemplateField( |
---|
246 | 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.')) |
---|
247 | .addToFields(new TemplateField( |
---|
248 | name: 'Systolic blood pressure',type: TemplateFieldType.FLOAT, unit: 'mmHg',comment:'Indicate the levels at the start of the study in mmHG')) |
---|
249 | .addToFields(new TemplateField( |
---|
250 | name: 'Diastolic blood pressure',type: TemplateFieldType.FLOAT, unit: 'mmHg',comment:'Indicate the levels at the start of the study in mmHG')) |
---|
251 | .addToFields(new TemplateField( |
---|
252 | name: 'Heart rate',type: TemplateFieldType.FLOAT, unit: 'beats/min',comment:'Indicate the heart rate at the start of in study in beats per minute')) |
---|
253 | .addToFields(new TemplateField( |
---|
254 | name: 'Run-in-food',type: TemplateFieldType.TEXT,comment:'If defined, give a short description of the food used before the measurements')) |
---|
255 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
256 | |
---|
257 | |
---|
258 | def sampleRemarksField = new TemplateField( |
---|
259 | name: 'Remarks',type: TemplateFieldType.TEXT) |
---|
260 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
261 | def sampleVialTextField = new TemplateField( |
---|
262 | name: 'Text on vial',type: TemplateFieldType.STRING) |
---|
263 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
264 | |
---|
265 | // Human tissue sample template |
---|
266 | println ".adding human sample template..." |
---|
267 | def humanSampleTemplate = new Template( |
---|
268 | name: 'Human tissue sample', entity: dbnp.studycapturing.Sample) |
---|
269 | .addToFields(sampleRemarksField) |
---|
270 | .addToFields(sampleVialTextField) |
---|
271 | .addToFields(new TemplateField( |
---|
272 | name: 'Sample measured weight', |
---|
273 | unit: 'mg', |
---|
274 | type: TemplateFieldType.FLOAT)) |
---|
275 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
276 | |
---|
277 | // Human blood sample template |
---|
278 | println ".adding human sample template..." |
---|
279 | def humanBloodSampleTemplate = new Template( |
---|
280 | name: 'Human blood sample', entity: dbnp.studycapturing.Sample) |
---|
281 | .addToFields(sampleRemarksField) |
---|
282 | .addToFields(sampleVialTextField) |
---|
283 | .addToFields(new TemplateField( |
---|
284 | name: 'Sample measured volume', |
---|
285 | unit: 'ml', |
---|
286 | type: TemplateFieldType.FLOAT)) |
---|
287 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
288 | |
---|
289 | //Plant template |
---|
290 | println ".adding plant template..." |
---|
291 | def plantTemplate = new Template( |
---|
292 | name: 'Plant template', entity: dbnp.studycapturing.Subject) |
---|
293 | .addToFields(new TemplateField( |
---|
294 | name: 'Variety', type: TemplateFieldType.STRING)) |
---|
295 | .addToFields(new TemplateField( |
---|
296 | name: 'Ecotype', type: TemplateFieldType.STRING)) |
---|
297 | .addToFields(genotypeField) |
---|
298 | .addToFields(genotypeTypeField) |
---|
299 | .addToFields(new TemplateField( |
---|
300 | name: 'Growth location', type: TemplateFieldType.STRINGLIST, |
---|
301 | listEntries: [new TemplateFieldListItem(name:'Greenhouse'),new TemplateFieldListItem(name: 'Field')])) |
---|
302 | .addToFields(new TemplateField( |
---|
303 | name: 'Room', type: TemplateFieldType.STRING, |
---|
304 | comment: 'Chamber number in case of Greenhouse')) |
---|
305 | .addToFields(new TemplateField( |
---|
306 | name: 'Position X', type: TemplateFieldType.FLOAT)) |
---|
307 | .addToFields(new TemplateField( |
---|
308 | name: 'Position Y', type: TemplateFieldType.FLOAT)) |
---|
309 | .addToFields(new TemplateField( |
---|
310 | name: 'Block', type: TemplateFieldType.STRING)) |
---|
311 | .addToFields(new TemplateField( |
---|
312 | name: 'Temperature at day', type: TemplateFieldType.FLOAT)) |
---|
313 | .addToFields(new TemplateField( |
---|
314 | name: 'Temperature at night', type: TemplateFieldType.FLOAT)) |
---|
315 | .addToFields(new TemplateField( |
---|
316 | name: 'Photo period', type: TemplateFieldType.STRING)) |
---|
317 | .addToFields(new TemplateField( |
---|
318 | name: 'Light intensity', type: TemplateFieldType.STRING)) |
---|
319 | .addToFields(new TemplateField( |
---|
320 | name: 'Start date', type: TemplateFieldType.DATE)) |
---|
321 | .addToFields(new TemplateField( |
---|
322 | name: 'Harvest date', type: TemplateFieldType.DATE)) |
---|
323 | .addToFields(new TemplateField( |
---|
324 | name: 'Growth type', type: TemplateFieldType.STRINGLIST, |
---|
325 | listEntries: [new TemplateFieldListItem(name:'Standard'),new TemplateFieldListItem(name: 'Experimental')])) |
---|
326 | .addToFields(new TemplateField( |
---|
327 | name: 'Growth protocol', type: TemplateFieldType.TEXT)) |
---|
328 | .addToFields(new TemplateField( |
---|
329 | name: 'Harvest delay', type: TemplateFieldType.TEXT)) |
---|
330 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
331 | |
---|
332 | println ".adding plant sample template..." |
---|
333 | def plantSampleTemplate = new Template( |
---|
334 | name: 'Plant sample', entity: dbnp.studycapturing.Sample) |
---|
335 | .addToFields(sampleRemarksField) |
---|
336 | .addToFields(sampleVialTextField) |
---|
337 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
338 | |
---|
339 | def dietTreatmentTemplate = new Template( |
---|
340 | name: 'Diet treatment HF45/LF10', entity: dbnp.studycapturing.Event) |
---|
341 | .addToFields(new TemplateField( |
---|
342 | name: 'Diet', type: TemplateFieldType.STRINGLIST, |
---|
343 | listEntries: [new TemplateFieldListItem(name:'10% fat (palm oil)'),new TemplateFieldListItem(name: '45% fat (palm oil)')])) |
---|
344 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
345 | |
---|
346 | def boostTreatmentTemplate = new Template( |
---|
347 | name: 'Leptin treatment', entity: dbnp.studycapturing.Event) |
---|
348 | .addToFields(new TemplateField( |
---|
349 | name: 'Compound', type: TemplateFieldType.STRINGLIST, |
---|
350 | listEntries: [new TemplateFieldListItem(name:'Vehicle'),new TemplateFieldListItem(name: 'Leptin')])) |
---|
351 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
352 | |
---|
353 | def fastingTreatment = new Template( |
---|
354 | name: 'Fasting treatment', |
---|
355 | description: 'Fasting Protocol NuGO PPSH', |
---|
356 | entity: dbnp.studycapturing.Event) |
---|
357 | .addToFields(new TemplateField( |
---|
358 | name: 'Fasting period', |
---|
359 | type: TemplateFieldType.STRING)) |
---|
360 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
361 | |
---|
362 | // SamplingEvent templates |
---|
363 | |
---|
364 | def samplingProtocolField = new TemplateField( |
---|
365 | name: 'Sample Protocol',type: TemplateFieldType.STRING) |
---|
366 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
367 | |
---|
368 | def liverSamplingEventTemplate = new Template( |
---|
369 | name: 'Liver extraction', |
---|
370 | description: 'Liver sampling for transcriptomics arrays', |
---|
371 | entity: dbnp.studycapturing.SamplingEvent) |
---|
372 | .addToFields(samplingProtocolField) |
---|
373 | .addToFields(new TemplateField( |
---|
374 | name: 'Sample weight', |
---|
375 | unit: 'mg', |
---|
376 | type: TemplateFieldType.FLOAT)) |
---|
377 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
378 | |
---|
379 | def bloodSamplingEventTemplate = new Template( |
---|
380 | name: 'Blood extraction', |
---|
381 | description: 'Blood extraction targeted at lipid assays', |
---|
382 | entity: dbnp.studycapturing.SamplingEvent) |
---|
383 | .addToFields(samplingProtocolField) |
---|
384 | .addToFields(new TemplateField( |
---|
385 | name: 'Sample volume', |
---|
386 | unit: 'ml', |
---|
387 | type: TemplateFieldType.FLOAT)) |
---|
388 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
389 | |
---|
390 | |
---|
391 | // Add example studies |
---|
392 | if (!(grails.util.GrailsUtil.environment == GrailsApplication.ENV_TEST)) { |
---|
393 | println ".adding NuGO PPS3 leptin example study..." |
---|
394 | def mouseStudy = new Study( |
---|
395 | template: studyTemplate, |
---|
396 | title:"NuGO PPS3 mouse study leptin module", |
---|
397 | code:"PPS3_leptin_module", |
---|
398 | researchQuestion:"Leptin etc.", |
---|
399 | ecCode:"2007117.c", |
---|
400 | startDate: Date.parse('yyyy-MM-dd','2008-01-02'), |
---|
401 | externalStudyID: 1 |
---|
402 | ) |
---|
403 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
404 | |
---|
405 | 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." ) |
---|
406 | mouseStudy.save() |
---|
407 | |
---|
408 | def evLF = new Event( |
---|
409 | startTime: 3600, |
---|
410 | endTime: 3600 +7 * 24 * 3600, |
---|
411 | template: dietTreatmentTemplate |
---|
412 | ) |
---|
413 | .setFieldValue( 'Diet','10% fat (palm oil)') |
---|
414 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
415 | |
---|
416 | def evHF = new Event( |
---|
417 | startTime: 3600, |
---|
418 | endTime: 3600 +7 * 24 * 3600, |
---|
419 | template: dietTreatmentTemplate |
---|
420 | ) |
---|
421 | .setFieldValue( 'Diet','45% fat (palm oil)' ) |
---|
422 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
423 | |
---|
424 | def evBV = new Event( |
---|
425 | startTime: 3600, |
---|
426 | endTime: 3600 +7 * 24 * 3600, |
---|
427 | template: boostTreatmentTemplate |
---|
428 | ) |
---|
429 | .setFieldValue( 'Compound','Vehicle' ) |
---|
430 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
431 | |
---|
432 | def evBL = new Event( |
---|
433 | startTime: 3600, |
---|
434 | endTime: 3600 +7 * 24 * 3600, |
---|
435 | template: boostTreatmentTemplate |
---|
436 | ) |
---|
437 | .setFieldValue( 'Compound','Leptin' ) |
---|
438 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
439 | |
---|
440 | def evLF4 = new Event( |
---|
441 | startTime: 3600, |
---|
442 | endTime: 3600 + 4 * 7 * 24 * 3600, |
---|
443 | template: dietTreatmentTemplate |
---|
444 | ) |
---|
445 | .setFieldValue( 'Diet','10% fat (palm oil)') |
---|
446 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
447 | |
---|
448 | def evHF4 = new Event( |
---|
449 | startTime: 3600, |
---|
450 | endTime: 3600 + 4 * 7 * 24 * 3600, |
---|
451 | template: dietTreatmentTemplate |
---|
452 | ) |
---|
453 | .setFieldValue( 'Diet','45% fat (palm oil)' ) |
---|
454 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
455 | |
---|
456 | def evBV4 = new Event( |
---|
457 | startTime: 3600, |
---|
458 | endTime: 3600 + 4 * 7 * 24 * 3600, |
---|
459 | template: boostTreatmentTemplate |
---|
460 | ) |
---|
461 | .setFieldValue( 'Compound','Vehicle' ) |
---|
462 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
463 | |
---|
464 | def evBL4 = new Event( |
---|
465 | startTime: 3600, |
---|
466 | endTime: 3600 + 4 * 7 * 24 * 3600, |
---|
467 | template: boostTreatmentTemplate |
---|
468 | ) |
---|
469 | .setFieldValue( 'Compound','Leptin' ) |
---|
470 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
471 | |
---|
472 | def evS = new SamplingEvent( |
---|
473 | startTime: 3600 +7 * 24 * 3600, |
---|
474 | endTime: 3600 +7 * 24 * 3600, |
---|
475 | template: liverSamplingEventTemplate) |
---|
476 | .setFieldValue('Sample weight',5F) |
---|
477 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
478 | |
---|
479 | def evS4 = new SamplingEvent( |
---|
480 | startTime: 3600 +7 * 24 * 3600, |
---|
481 | endTime: 3600 +7 * 24 * 3600, |
---|
482 | template: liverSamplingEventTemplate) |
---|
483 | .setFieldValue('Sample weight',5F) |
---|
484 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
485 | |
---|
486 | // Add events to study |
---|
487 | mouseStudy |
---|
488 | .addToEvents(evLF) |
---|
489 | .addToEvents(evHF) |
---|
490 | .addToEvents(evBV) |
---|
491 | .addToEvents(evBL) |
---|
492 | .addToEvents(evLF4) |
---|
493 | .addToEvents(evHF4) |
---|
494 | .addToEvents(evBV4) |
---|
495 | .addToEvents(evBL4) |
---|
496 | .addToSamplingEvents(evS) |
---|
497 | .addToSamplingEvents(evS4) |
---|
498 | .save() |
---|
499 | |
---|
500 | def LFBV1 = new EventGroup(name:"10% fat + vehicle for 1 week") |
---|
501 | .addToEvents(evLF) |
---|
502 | .addToEvents(evBV) |
---|
503 | .addToEvents(evS) |
---|
504 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
505 | |
---|
506 | def LFBL1 = new EventGroup(name:"10% fat + leptin for 1 week") |
---|
507 | .addToEvents(evLF) |
---|
508 | .addToEvents(evBL) |
---|
509 | .addToEvents(evS) |
---|
510 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
511 | |
---|
512 | def HFBV1 = new EventGroup(name:"45% fat + vehicle for 1 week") |
---|
513 | .addToEvents(evHF) |
---|
514 | .addToEvents(evBV) |
---|
515 | .addToEvents(evS) |
---|
516 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
517 | |
---|
518 | def HFBL1 = new EventGroup(name:"45% fat + leptin for 1 week") |
---|
519 | .addToEvents(evHF) |
---|
520 | .addToEvents(evBL) |
---|
521 | .addToEvents(evS) |
---|
522 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
523 | |
---|
524 | def LFBV4 = new EventGroup(name:"10% fat + vehicle for 4 weeks") |
---|
525 | .addToEvents(evLF4) |
---|
526 | .addToEvents(evBV4) |
---|
527 | .addToEvents(evS4) |
---|
528 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
529 | |
---|
530 | def LFBL4 = new EventGroup(name:"10% fat + leptin for 4 weeks") |
---|
531 | .addToEvents(evLF4) |
---|
532 | .addToEvents(evBL4) |
---|
533 | .addToEvents(evS4) |
---|
534 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
535 | |
---|
536 | def HFBV4 = new EventGroup(name:"45% fat + vehicle for 4 weeks") |
---|
537 | .addToEvents(evHF4) |
---|
538 | .addToEvents(evBV4) |
---|
539 | .addToEvents(evS4) |
---|
540 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
541 | |
---|
542 | def HFBL4 = new EventGroup(name:"45% fat + leptin for 4 weeks") |
---|
543 | .addToEvents(evHF4) |
---|
544 | .addToEvents(evBL4) |
---|
545 | .addToEvents(evS4) |
---|
546 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
547 | |
---|
548 | // Add subjects and samples and compose EventGroups |
---|
549 | def x=1 |
---|
550 | 20.times { |
---|
551 | def currentSubject = new Subject( |
---|
552 | name: "A" + x++, |
---|
553 | species: mouseTerm, |
---|
554 | template: mouseTemplate, |
---|
555 | ) |
---|
556 | .setFieldValue("Gender", "Male") |
---|
557 | .setFieldValue("Genotype", c57bl6Term) |
---|
558 | .setFieldValue("Age", 17) |
---|
559 | .setFieldValue("Cage", "" + (int)(x/2)) |
---|
560 | .with { if (!validate()) { errors.each { println it} } else save(flush:true)} |
---|
561 | |
---|
562 | mouseStudy.addToSubjects(currentSubject) |
---|
563 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
564 | |
---|
565 | // Add subject to appropriate EventGroup |
---|
566 | if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } |
---|
567 | else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } |
---|
568 | else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() } |
---|
569 | else if (x > 40) { LFBV4.addToSubjects(currentSubject).save() } |
---|
570 | else if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } |
---|
571 | else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } |
---|
572 | else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } |
---|
573 | else { LFBV1.addToSubjects(currentSubject).save() } |
---|
574 | |
---|
575 | } |
---|
576 | |
---|
577 | // Add EventGroups to study |
---|
578 | mouseStudy |
---|
579 | .addToEventGroups(LFBV1) |
---|
580 | .addToEventGroups(LFBL1) |
---|
581 | .addToEventGroups(HFBV1) |
---|
582 | .addToEventGroups(HFBL1) |
---|
583 | .addToEventGroups(LFBV4) |
---|
584 | .addToEventGroups(LFBL4) |
---|
585 | .addToEventGroups(HFBV4) |
---|
586 | .addToEventGroups(HFBL4) |
---|
587 | |
---|
588 | // Add persons and publications to study |
---|
589 | def studyperson1 = new StudyPerson( person: person1, role: role1 ).save(); |
---|
590 | def studyperson2 = new StudyPerson( person: person2, role: role2 ).save(); |
---|
591 | |
---|
592 | mouseStudy |
---|
593 | .addToPersons( studyperson1 ) |
---|
594 | .addToPersons( studyperson2 ) |
---|
595 | .addToPublications( publication1 ) |
---|
596 | .addToPublications( publication2 ) |
---|
597 | .save() |
---|
598 | |
---|
599 | println ".adding NuGO PPSH example study..." |
---|
600 | |
---|
601 | def humanStudy = new Study( |
---|
602 | template: studyTemplate, |
---|
603 | title:"NuGO PPS human study", |
---|
604 | code:"PPSH", |
---|
605 | researchQuestion:"How much are fasting plasma and urine metabolite levels affected by prolonged fasting ?", |
---|
606 | description:"Human study", |
---|
607 | ecCode:"unknown", |
---|
608 | startDate: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
609 | externalStudyID: 2 |
---|
610 | ) |
---|
611 | .setFieldValue( 'Description', "Human study performed at RRI; centres involved: RRI, IFR, TUM, Maastricht U." ) |
---|
612 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
613 | |
---|
614 | def rootGroup = new EventGroup(name: 'Root group'); |
---|
615 | |
---|
616 | def fastingEvent = new Event( |
---|
617 | startTime: 3 * 24 * 3600 + 22 * 3600, |
---|
618 | endTime: 3 * 24 * 3600 + 30 * 3600, |
---|
619 | template: fastingTreatment) |
---|
620 | .setFieldValue('Fasting period','8h'); |
---|
621 | |
---|
622 | |
---|
623 | def bloodSamplingEvent = new SamplingEvent( |
---|
624 | startTime: 3 * 24 * 3600 + 30 * 3600, |
---|
625 | endTime: 3 * 24 * 3600 + 30 * 3600, |
---|
626 | template: bloodSamplingEventTemplate) |
---|
627 | .setFieldValue('Sample volume',4.5F); |
---|
628 | |
---|
629 | rootGroup.addToEvents fastingEvent |
---|
630 | rootGroup.addToEvents bloodSamplingEvent |
---|
631 | rootGroup.save() |
---|
632 | |
---|
633 | def y = 1 |
---|
634 | 11.times { |
---|
635 | def currentSubject = new Subject( |
---|
636 | name: "" + y++, |
---|
637 | species: humanTerm, |
---|
638 | template: humanTemplate) |
---|
639 | .setFieldValue("Gender", (Math.random() > 0.5) ? "Male" : "Female") |
---|
640 | .setFieldValue("DOB", new java.text.SimpleDateFormat("dd-mm-yy").parse("01-02-19" + (10 + (int) (Math.random() * 80)))) |
---|
641 | .setFieldValue("Age", 30) |
---|
642 | .setFieldValue("Height", Math.random() * 2F) |
---|
643 | .setFieldValue("Weight", Math.random() * 150F) |
---|
644 | .setFieldValue("BMI", 20 + Math.random() * 10F) |
---|
645 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
646 | |
---|
647 | rootGroup.addToSubjects currentSubject |
---|
648 | rootGroup.save() |
---|
649 | |
---|
650 | def currentSample = new Sample( |
---|
651 | name: currentSubject.name + '_B', |
---|
652 | material: bloodTerm, |
---|
653 | parentSubject: currentSubject, |
---|
654 | parentEvent: bloodSamplingEvent); |
---|
655 | |
---|
656 | humanStudy.addToSubjects(currentSubject).addToSamples(currentSample).with { if (!validate()) { errors.each { println it} } else save()} |
---|
657 | } |
---|
658 | |
---|
659 | humanStudy.addToEvents(fastingEvent) |
---|
660 | humanStudy.addToSamplingEvents(bloodSamplingEvent) |
---|
661 | humanStudy.addToEventGroups rootGroup |
---|
662 | |
---|
663 | |
---|
664 | // Add persons to study |
---|
665 | def studyperson3 = new StudyPerson( person: person1, role: role2 ).save(); |
---|
666 | |
---|
667 | humanStudy |
---|
668 | .addToPersons( studyperson3 ) |
---|
669 | .addToPublications( publication2 ) |
---|
670 | .save() |
---|
671 | |
---|
672 | /* |
---|
673 | // Add clinical data |
---|
674 | |
---|
675 | def lipidAssay = new dbnp.clinicaldata.ClinicalAssay( |
---|
676 | name: 'Lipid profile', |
---|
677 | approved: true |
---|
678 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
679 | |
---|
680 | def ldlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( |
---|
681 | name: 'LDL', |
---|
682 | unit: 'mg/dL', |
---|
683 | type: dbnp.data.FeatureType.QUANTITATIVE, |
---|
684 | referenceValues: '100 mg/dL', |
---|
685 | detectableLimit: 250, |
---|
686 | isDrug: false, isIntake: true, inSerum: true |
---|
687 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
688 | |
---|
689 | def hdlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( |
---|
690 | name: 'HDL', |
---|
691 | unit: 'mg/dL', |
---|
692 | type: dbnp.data.FeatureType.QUANTITATIVE, |
---|
693 | referenceValues: '50 mg/dL', |
---|
694 | detectableLimit: 100, |
---|
695 | isDrug: false, isIntake: true, inSerum: true |
---|
696 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
697 | |
---|
698 | lipidAssay.addToMeasurements ldlMeasurement |
---|
699 | lipidAssay.addToMeasurements hdlMeasurement |
---|
700 | |
---|
701 | def lipidAssayInstance = new dbnp.clinicaldata.ClinicalAssayInstance( |
---|
702 | assay: lipidAssay |
---|
703 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
704 | |
---|
705 | humanStudy.samples*.each { |
---|
706 | new dbnp.clinicaldata.ClinicalFloatData( |
---|
707 | assay: lipidAssayInstance, |
---|
708 | measurement: ldlMeasurement, |
---|
709 | sample: it.name, |
---|
710 | value: Math.round(Math.random()*ldlMeasurement.detectableLimit) |
---|
711 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
712 | |
---|
713 | new dbnp.clinicaldata.ClinicalFloatData( |
---|
714 | assay: lipidAssayInstance, |
---|
715 | measurement: hdlMeasurement, |
---|
716 | sample: it.name, |
---|
717 | value: Math.round(Math.random()*hdlMeasurement.detectableLimit) |
---|
718 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
719 | } |
---|
720 | */ |
---|
721 | // Add assay to study capture module |
---|
722 | |
---|
723 | def clinicalModule = new AssayModule( |
---|
724 | name: 'Clinical data', |
---|
725 | type: AssayType.CLINICAL_DATA, |
---|
726 | platform: 'clinical measurements', |
---|
727 | url: 'http://localhost:8080/gscf' |
---|
728 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
729 | |
---|
730 | def lipidAssayRef = new Assay( |
---|
731 | name: 'Lipid profiling', |
---|
732 | module: clinicalModule, |
---|
733 | externalAssayId: 0 |
---|
734 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
735 | |
---|
736 | humanStudy.samples*.each { |
---|
737 | lipidAssayRef.addToSamples(it) |
---|
738 | } |
---|
739 | lipidAssayRef.save() |
---|
740 | |
---|
741 | humanStudy.addToAssays(lipidAssayRef); |
---|
742 | humanStudy.save() |
---|
743 | |
---|
744 | mouseStudy.addToAssays(lipidAssayRef); |
---|
745 | mouseStudy.save() |
---|
746 | |
---|
747 | } |
---|
748 | } |
---|
749 | |
---|
750 | // Ontologies must be connected to the templatefields in runtime |
---|
751 | // because the Ontology.findByNcboId is not available otherwise |
---|
752 | TemplateEntity.getField( Subject.domainFields, 'species' ).ontologies = [Ontology.findByNcboId(1132)] |
---|
753 | TemplateEntity.getField( Sample.domainFields, 'material' ).ontologies = [Ontology.findByNcboId(1005)] |
---|
754 | |
---|
755 | } |
---|
756 | |
---|
757 | def destroy = { |
---|
758 | } |
---|
759 | } |
---|