1 | /** |
---|
2 | * @Author kees |
---|
3 | * @Since Jun 25, 2010 |
---|
4 | * |
---|
5 | * Revision information: |
---|
6 | * $Rev: 1509 $ |
---|
7 | * $Author: work@osx.eu $ |
---|
8 | * $Date: 2011-02-09 15:33:23 +0000 (wo, 09 feb 2011) $ |
---|
9 | */ |
---|
10 | |
---|
11 | import dbnp.studycapturing.* |
---|
12 | import org.dbnp.gdt.* |
---|
13 | import org.dbnp.bgdt.* |
---|
14 | import org.codehaus.groovy.grails.commons.GrailsApplication |
---|
15 | |
---|
16 | class BootStrapTemplates { |
---|
17 | |
---|
18 | /** |
---|
19 | * Add the ontologies that are necessary for the templates below manually |
---|
20 | * This function can be called to avoid the HTTP requests to BioPortal each time |
---|
21 | * (e.g. in development or automated test environments) |
---|
22 | */ |
---|
23 | public static void initTemplateOntologies() { |
---|
24 | "inserting initial ontologies".grom() |
---|
25 | |
---|
26 | // If running in development or test mode, add ontologies manually to speed up development and allow running offline |
---|
27 | if (grails.util.GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT || grails.util.GrailsUtil.environment == GrailsApplication.ENV_TEST) { |
---|
28 | |
---|
29 | // add Species ontology which is used for a.o. the Subject domain field 'species' |
---|
30 | def speciesOntology = new Ontology( |
---|
31 | name: 'NCBI organismal classification', |
---|
32 | description: 'A taxonomic classification of living organisms and associated artifacts for their controlled description within the context of databases.', |
---|
33 | url: 'http://www.ncbi.nlm.nih.gov/Taxonomy/taxonomyhome.html/', |
---|
34 | versionNumber: '1.2', |
---|
35 | ncboId: '1132', |
---|
36 | ncboVersionedId: '38802' |
---|
37 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
38 | |
---|
39 | // add Sample>material ontology |
---|
40 | def brendaOntology = new Ontology( |
---|
41 | name: 'BRENDA tissue / enzyme source', |
---|
42 | 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.', |
---|
43 | url: 'http://www.brenda-enzymes.info', |
---|
44 | versionNumber: '1.3', |
---|
45 | ncboId: '1005', |
---|
46 | ncboVersionedId: '40643' |
---|
47 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
48 | |
---|
49 | // add NCI ontology which is used in Mouse genotype template field |
---|
50 | def nciOntology = new Ontology( |
---|
51 | name: 'NCI Thesaurus', |
---|
52 | description: 'A vocabulary for clinical care, translational and basic research, and public information and administrative activities.', |
---|
53 | url: 'http://ncicb.nci.nih.gov/core/EVS', |
---|
54 | versionNumber: '10.03', |
---|
55 | ncboId: '1032', |
---|
56 | ncboVersionedId: '42838' |
---|
57 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
58 | |
---|
59 | // add CHEBI ontology which is used for describing chemicals in e.g. events |
---|
60 | def chebiOntology = new Ontology( |
---|
61 | name: 'Chemical entities of biological interest', |
---|
62 | description: 'A structured classification of chemical compounds of biological relevance.', |
---|
63 | url: 'http://www.ebi.ac.uk/chebi', |
---|
64 | versionNumber: '1.73', |
---|
65 | ncboId: '1007', |
---|
66 | ncboVersionedId: '44746' |
---|
67 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
68 | |
---|
69 | } |
---|
70 | // otherwise, this may be a production demo instance, so initialize the ontologies dynamically from BioPortal |
---|
71 | else { |
---|
72 | |
---|
73 | def speciesOntology = Ontology.getOrCreateOntologyByNcboId(1132) |
---|
74 | def brendaOntology = Ontology.getOrCreateOntologyByNcboId(1005) |
---|
75 | def nciOntology = Ontology.getOrCreateOntologyByNcboId(1032) |
---|
76 | def chebiOntology = Ontology.getOrCreateOntologyByNcboId(1007) |
---|
77 | } |
---|
78 | } |
---|
79 | |
---|
80 | |
---|
81 | /** |
---|
82 | * Add example templates, this function would normally be called on an empty database |
---|
83 | */ |
---|
84 | public static void initTemplates() { |
---|
85 | "inserting initial templates".grom() |
---|
86 | |
---|
87 | def genderField = new TemplateField( |
---|
88 | name: 'Gender',type: TemplateFieldType.STRINGLIST, entity: Subject, |
---|
89 | listEntries: [new TemplateFieldListItem(name:'Male'),new TemplateFieldListItem(name: 'Female'),new TemplateFieldListItem(name: 'Unknown')]) |
---|
90 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
91 | |
---|
92 | def ageField = new TemplateField( |
---|
93 | name: 'Age',type: TemplateFieldType.LONG,entity: Subject,unit: 'years',comment: 'Either include age at the start of the study or date of birth (if known)') |
---|
94 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
95 | |
---|
96 | def genotypeField = new TemplateField( |
---|
97 | name: 'Genotype', type: TemplateFieldType.ONTOLOGYTERM,entity: Subject, |
---|
98 | comment: 'If present, indicate the genetic variance of the subject (e.g., mutagenized populations,knock-out/in,transgene etc)') |
---|
99 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
100 | |
---|
101 | def genotypeTypeField = new TemplateField( |
---|
102 | name: 'Genotype type',type: TemplateFieldType.STRINGLIST,entity: Subject, |
---|
103 | listEntries: [new TemplateFieldListItem(name:'wildtype'), |
---|
104 | new TemplateFieldListItem(name:'transgenic'), |
---|
105 | new TemplateFieldListItem(name:'knock-out'), |
---|
106 | new TemplateFieldListItem(name:'knock-in')], |
---|
107 | comment: 'If a genotype was specified, please indicate here the type of the genotype') |
---|
108 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
109 | |
---|
110 | def varietyField = new TemplateField( |
---|
111 | name: 'Variety', type: TemplateFieldType.STRING,entity: Subject, |
---|
112 | comment: 'taxonomic category consisting of members of a species that differ from others of the same species in minor but heritable characteristics') |
---|
113 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
114 | |
---|
115 | def ecotypeField = new TemplateField( |
---|
116 | name: 'Ecotype', type: TemplateFieldType.STRING,entity: Subject, |
---|
117 | comment: 'a type or subspecies of life that is especially well adapted to a certain environment' |
---|
118 | ) |
---|
119 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
120 | |
---|
121 | // Nutritional study template |
---|
122 | def studyTemplate = new Template( |
---|
123 | name: 'Academic study', |
---|
124 | entity: dbnp.studycapturing.Study |
---|
125 | ) |
---|
126 | .addToFields(new TemplateField(name: 'Objectives',type: TemplateFieldType.TEXT,entity: Study,comment:'Fill out the aim or questions of the study')) |
---|
127 | .addToFields(new TemplateField(name: 'Consortium',type: TemplateFieldType.STRING,entity: Study,comment:'If the study was performed within a consortium (e.g. NMC, NuGO), you can indicate this here')) |
---|
128 | .addToFields(new TemplateField(name: 'Cohort name',type: TemplateFieldType.STRING,entity: Study,comment:'If a cohort was used the name or code of the cohort can be define here (define a cohort template)')) |
---|
129 | .addToFields(new TemplateField(name: 'Lab id',type: TemplateFieldType.STRING,entity: Study,comment:'In which lab was the study performed; indicate the roomnumber.')) |
---|
130 | .addToFields(new TemplateField(name: 'Institute',type: TemplateFieldType.STRING,entity: Study,comment:'In which institute was the study performed; indicate the full address information (to be replaced by persons-affiliations?)')) |
---|
131 | .addToFields(new TemplateField(name: 'Study protocol',type: TemplateFieldType.FILE,entity: Study,comment:'Optionally attach a file in which the protocol in the study is described')) |
---|
132 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
133 | |
---|
134 | // Mouse template |
---|
135 | def mouseTemplate = new Template( |
---|
136 | name: 'Mouse', entity: dbnp.studycapturing.Subject) |
---|
137 | .addToFields(new TemplateField( |
---|
138 | name: 'Strain', type: TemplateFieldType.ONTOLOGYTERM, ontologies: [Ontology.getOrCreateOntologyByNcboId(1032)], entity: Subject, comment: "This is an ontology term, if the right strain is not in the list please add it with 'add more'")) |
---|
139 | .addToFields(genotypeField) |
---|
140 | .addToFields(genotypeTypeField) |
---|
141 | .addToFields(genderField) |
---|
142 | .addToFields(new TemplateField( |
---|
143 | name: 'Age', type: TemplateFieldType.LONG, entity: Subject, unit: 'weeks', comment: 'Age at start of study')) |
---|
144 | .addToFields(new TemplateField( |
---|
145 | name: 'Age type',type: TemplateFieldType.STRINGLIST,entity: Subject, |
---|
146 | listEntries: [new TemplateFieldListItem(name:'postnatal'),new TemplateFieldListItem(name:'embryonal')])) |
---|
147 | .addToFields(new TemplateField( |
---|
148 | name: 'Cage',type: TemplateFieldType.STRING,entity: Subject,comment:'Indicate the cage used for housing (type and/or size)')) |
---|
149 | .addToFields(new TemplateField( |
---|
150 | name: '#Mice in cage',type: TemplateFieldType.LONG,entity: Subject,comment:'If known, indicate the number of mice per cage')) |
---|
151 | .addToFields(new TemplateField( |
---|
152 | name: 'Litter size',type: TemplateFieldType.LONG,entity: Subject,comment:'If known, indicate the litter size of the litter from which the subject originates')) |
---|
153 | .addToFields(new TemplateField( |
---|
154 | name: 'Weight', type: TemplateFieldType.DOUBLE, unit: 'gram',entity: Subject,comment:'If known indicate the weight of the subject in grams at the start of the study')) |
---|
155 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
156 | |
---|
157 | // Human template |
---|
158 | def humanTemplate = new Template( |
---|
159 | name: 'Human', entity: dbnp.studycapturing.Subject) |
---|
160 | .addToFields(genderField) |
---|
161 | .addToFields(ageField) |
---|
162 | .addToFields(new TemplateField( |
---|
163 | name: 'DOB',type: TemplateFieldType.DATE,entity: Subject,comment:'Date of birth')) |
---|
164 | .addToFields(new TemplateField( |
---|
165 | name: 'Height',type: TemplateFieldType.DOUBLE, entity: Subject, unit: 'm')) |
---|
166 | .addToFields(new TemplateField( |
---|
167 | name: 'Weight',type: TemplateFieldType.DOUBLE, entity: Subject, unit: 'kg')) |
---|
168 | .addToFields(new TemplateField( |
---|
169 | name: 'BMI',type: TemplateFieldType.DOUBLE, entity: Subject, unit: 'kg/m2',comment:'Body-mass-index')) |
---|
170 | .addToFields(new TemplateField( |
---|
171 | name: 'Race',type: TemplateFieldType.STRING,entity: Subject, comment:'If known and of interest the ethnic group can be indicated')) |
---|
172 | .addToFields(new TemplateField( |
---|
173 | name: 'Waist circumference',type: TemplateFieldType.DOUBLE, unit: 'cm',entity: Subject, comment:'The waist circumference is measured just above the hip bone. Indicate the measure at the start of the study.')) |
---|
174 | .addToFields(new TemplateField( |
---|
175 | name: 'Hip circumference',type: TemplateFieldType.DOUBLE, unit: 'cm',entity: Subject, 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.')) |
---|
176 | .addToFields(new TemplateField( |
---|
177 | name: 'Systolic blood pressure',type: TemplateFieldType.DOUBLE, unit: 'mmHg',entity: Subject, comment:'Indicate the levels at the start of the study in mmHG')) |
---|
178 | .addToFields(new TemplateField( |
---|
179 | name: 'Diastolic blood pressure',type: TemplateFieldType.DOUBLE, unit: 'mmHg',entity: Subject, comment:'Indicate the levels at the start of the study in mmHG')) |
---|
180 | .addToFields(new TemplateField( |
---|
181 | name: 'Heart rate',type: TemplateFieldType.DOUBLE, unit: 'beats/min',entity: Subject, comment:'Indicate the heart rate at the start of in study in beats per minute')) |
---|
182 | .addToFields(new TemplateField( |
---|
183 | name: 'Run-in-food',type: TemplateFieldType.TEXT,entity: Subject, comment:'If defined, give a short description of the food used before the measurements')) |
---|
184 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
185 | |
---|
186 | def sampleRemarksField = new TemplateField( |
---|
187 | name: 'Remarks', |
---|
188 | type: TemplateFieldType.TEXT, |
---|
189 | entity: Sample |
---|
190 | ) |
---|
191 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
192 | |
---|
193 | def sampleVialTextField = new TemplateField( |
---|
194 | name: 'Text on vial', |
---|
195 | type: TemplateFieldType.STRING, |
---|
196 | entity: Sample |
---|
197 | ) |
---|
198 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
199 | |
---|
200 | // Human tissue sample template |
---|
201 | def humanSampleTemplate = new Template( |
---|
202 | name: 'Human tissue sample', |
---|
203 | entity: dbnp.studycapturing.Sample |
---|
204 | ) |
---|
205 | .addToFields(sampleRemarksField) |
---|
206 | .addToFields(sampleVialTextField) |
---|
207 | .addToFields( |
---|
208 | new TemplateField( |
---|
209 | name: 'Sample measured weight', |
---|
210 | unit: 'mg', |
---|
211 | type: TemplateFieldType.DOUBLE, |
---|
212 | entity: Sample |
---|
213 | ) |
---|
214 | ) |
---|
215 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
216 | |
---|
217 | // Human blood sample template |
---|
218 | def humanBloodSampleTemplate = new Template( |
---|
219 | name: 'Human blood sample', |
---|
220 | entity: dbnp.studycapturing.Sample |
---|
221 | ) |
---|
222 | .addToFields(sampleRemarksField) |
---|
223 | .addToFields(sampleVialTextField) |
---|
224 | .addToFields( |
---|
225 | new TemplateField( |
---|
226 | name: 'Sample measured volume', |
---|
227 | unit: 'ml', |
---|
228 | type: TemplateFieldType.DOUBLE, |
---|
229 | entity: Sample |
---|
230 | ) |
---|
231 | ) |
---|
232 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
233 | |
---|
234 | |
---|
235 | /* |
---|
236 | * Add NMC - DCL Sample Mapping Template |
---|
237 | * by Michael van Vliet |
---|
238 | * |
---|
239 | * For the Pilot running in Leiden (NOV2010) |
---|
240 | */ |
---|
241 | def sampleDCLTextField = new TemplateField( |
---|
242 | name: 'DCL Sample Reference', |
---|
243 | type: TemplateFieldType.STRING, |
---|
244 | entity: Sample |
---|
245 | ) |
---|
246 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
247 | |
---|
248 | // Human tissue sample template |
---|
249 | def dclSampleTemplate = new Template( |
---|
250 | name: 'DCL Sample information', |
---|
251 | entity: dbnp.studycapturing.Sample |
---|
252 | ) |
---|
253 | .addToFields(sampleDCLTextField) |
---|
254 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
255 | // EO DCL Sample Mapping Template********************************** |
---|
256 | |
---|
257 | |
---|
258 | /* |
---|
259 | def GrowthTreatmentTemplate = new Template( |
---|
260 | name: 'Growth treatment', |
---|
261 | entity: dbnp.studycapturing.Event |
---|
262 | ) |
---|
263 | .addToFields(sampleDescriptionField) |
---|
264 | .addToFields(new TemplateField(name: 'position X',type: TemplateFieldType.STRING)) |
---|
265 | .addToFields(new TemplateField(name: 'position Y',type: TemplateFieldType.STRING)) |
---|
266 | .addToFields(new TemplateField(name: 'Block',type: TemplateFieldType.STRING)) |
---|
267 | .addToFields(new TemplateField(name: 'Temparature Day',type: TemplateFieldType.STRING)) |
---|
268 | .addToFields(new TemplateField(name: 'Temparature Night',type: TemplateFieldType.STRING)) |
---|
269 | .addToFields(new TemplateField(name: 'Light Intensity',type: TemplateFieldType.STRING)) |
---|
270 | .addToFields(new TemplateField(name: 'Harvest Delay',type: TemplateFieldType.STRING)) |
---|
271 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
272 | */ |
---|
273 | |
---|
274 | //Plant template |
---|
275 | def greenHouseTemplate = new Template( |
---|
276 | name: 'Plant-green house ', |
---|
277 | entity: dbnp.studycapturing.Subject |
---|
278 | ) |
---|
279 | .addToFields(varietyField) |
---|
280 | .addToFields(ecotypeField) |
---|
281 | .addToFields(genotypeField) |
---|
282 | /* |
---|
283 | .addToFields(genotypeTypeField) |
---|
284 | .addToFields( |
---|
285 | new TemplateField( |
---|
286 | name: 'Growth location', type: TemplateFieldType.STRINGLIST, |
---|
287 | listEntries: [ |
---|
288 | new TemplateFieldListItem(name:'Greenhouse'), |
---|
289 | new TemplateFieldListItem(name: 'Field') |
---|
290 | ] |
---|
291 | ) |
---|
292 | ) |
---|
293 | .addToFields( |
---|
294 | new TemplateField( |
---|
295 | name: 'Room', type: TemplateFieldType.STRING, |
---|
296 | comment: 'Chamber number in case of Greenhouse' |
---|
297 | ) |
---|
298 | ) |
---|
299 | */ |
---|
300 | .addToFields( |
---|
301 | new TemplateField( |
---|
302 | name: 'Chamber no.', |
---|
303 | type: TemplateFieldType.STRING, |
---|
304 | entity: Subject, |
---|
305 | comment: 'Chamber number in the Greenhouse' |
---|
306 | ) |
---|
307 | ) |
---|
308 | .addToFields( |
---|
309 | new TemplateField( |
---|
310 | name: 'Growth type', |
---|
311 | entity: Subject, |
---|
312 | type: TemplateFieldType.STRINGLIST, |
---|
313 | listEntries: [ |
---|
314 | new TemplateFieldListItem(name:'Standard'), |
---|
315 | new TemplateFieldListItem(name: 'Experimental'), |
---|
316 | new TemplateFieldListItem(name: 'Unknown') |
---|
317 | ] |
---|
318 | ) |
---|
319 | ) |
---|
320 | .addToFields(new TemplateField( |
---|
321 | name: 'Growth protocol', entity: Subject, type: TemplateFieldType.TEXT)) |
---|
322 | .addToFields(new TemplateField( |
---|
323 | name: 'Position X', entity: Subject, type: TemplateFieldType.DOUBLE)) |
---|
324 | .addToFields(new TemplateField( |
---|
325 | name: 'Position Y', entity: Subject, type: TemplateFieldType.DOUBLE)) |
---|
326 | .addToFields(new TemplateField( |
---|
327 | name: 'Block', entity: Subject, type: TemplateFieldType.STRING)) |
---|
328 | .addToFields(new TemplateField( |
---|
329 | name: 'Temperature at day', entity: Subject, type: TemplateFieldType.DOUBLE)) |
---|
330 | .addToFields(new TemplateField( |
---|
331 | name: 'Temperature at night', entity: Subject, type: TemplateFieldType.DOUBLE)) |
---|
332 | .addToFields(new TemplateField( |
---|
333 | name: 'Photo period', entity: Subject, type: TemplateFieldType.STRING)) |
---|
334 | .addToFields(new TemplateField( |
---|
335 | name: 'Light intensity', entity: Subject, type: TemplateFieldType.STRING)) |
---|
336 | .addToFields(new TemplateField( |
---|
337 | name: 'Start date', entity: Subject, type: TemplateFieldType.DATE)) |
---|
338 | .addToFields(new TemplateField( |
---|
339 | name: 'Harvest date', entity: Subject, type: TemplateFieldType.DATE)) |
---|
340 | .addToFields(new TemplateField( |
---|
341 | name: 'Harvest delay', entity: Subject, type: TemplateFieldType.TEXT)) |
---|
342 | .addToFields(new TemplateField( |
---|
343 | name: 'Additional info', entity: Subject, type: TemplateFieldType.TEXT)) |
---|
344 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
345 | |
---|
346 | def FieldTemplate = new Template( |
---|
347 | name: 'Plant-open field', |
---|
348 | entity: dbnp.studycapturing.Subject |
---|
349 | ) |
---|
350 | .addToFields(varietyField) |
---|
351 | .addToFields(ecotypeField) |
---|
352 | .addToFields(genotypeField) |
---|
353 | .addToFields(new TemplateField( |
---|
354 | name: 'Start date', entity: Subject, type: TemplateFieldType.DATE)) |
---|
355 | .addToFields(new TemplateField( |
---|
356 | name: 'Harvest date', entity: Subject, type: TemplateFieldType.DATE)) |
---|
357 | .addToFields(new TemplateField( |
---|
358 | name: 'Growth type', entity: Subject, type: TemplateFieldType.STRINGLIST, |
---|
359 | listEntries: [new TemplateFieldListItem(name:'Standard'),new TemplateFieldListItem(name: 'Experimental')])) |
---|
360 | .addToFields(new TemplateField( |
---|
361 | name: 'Growth protocol', entity: Subject, type: TemplateFieldType.TEXT)) |
---|
362 | .addToFields(new TemplateField( |
---|
363 | name: 'Harvest delay', entity: Subject, type: TemplateFieldType.TEXT)) |
---|
364 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
365 | |
---|
366 | //Plant template |
---|
367 | def chamberTemplate = new Template( |
---|
368 | name: 'Plant-chamber', |
---|
369 | entity: dbnp.studycapturing.Subject |
---|
370 | ) |
---|
371 | .addToFields(varietyField) |
---|
372 | .addToFields(ecotypeField) |
---|
373 | .addToFields(genotypeField) |
---|
374 | /* |
---|
375 | .addToFields(genotypeTypeField) |
---|
376 | .addToFields( |
---|
377 | new TemplateField( |
---|
378 | name: 'Growth location', |
---|
379 | type: TemplateFieldType.STRINGLIST, |
---|
380 | listEntries: [ |
---|
381 | new TemplateFieldListItem(name:'Greenhouse'), |
---|
382 | new TemplateFieldListItem(name: 'Field') |
---|
383 | ] |
---|
384 | ) |
---|
385 | ) |
---|
386 | */ |
---|
387 | .addToFields(new TemplateField( |
---|
388 | name: 'Room', type: TemplateFieldType.STRING, entity: Subject, |
---|
389 | comment: 'room number')) |
---|
390 | .addToFields(new TemplateField( |
---|
391 | name: 'Chamber no.', type: TemplateFieldType.STRING, entity: Subject, |
---|
392 | comment: 'Chamber number')) |
---|
393 | .addToFields(new TemplateField( |
---|
394 | name: 'Block', type: TemplateFieldType.STRING, entity: Subject)) |
---|
395 | .addToFields(new TemplateField( |
---|
396 | name: 'Position X', type: TemplateFieldType.DOUBLE, entity: Subject)) |
---|
397 | .addToFields(new TemplateField( |
---|
398 | name: 'Position Y', type: TemplateFieldType.DOUBLE, entity: Subject)) |
---|
399 | .addToFields(new TemplateField( |
---|
400 | name: 'Temperature at day', type: TemplateFieldType.DOUBLE, entity: Subject)) |
---|
401 | .addToFields(new TemplateField( |
---|
402 | name: 'Temperature at night', type: TemplateFieldType.DOUBLE, entity: Subject)) |
---|
403 | .addToFields(new TemplateField( |
---|
404 | name: 'Photo period', type: TemplateFieldType.STRING, entity: Subject)) |
---|
405 | .addToFields(new TemplateField( |
---|
406 | name: 'Light intensity', type: TemplateFieldType.STRING, entity: Subject)) |
---|
407 | .addToFields(new TemplateField( |
---|
408 | name: 'Start date', type: TemplateFieldType.DATE, entity: Subject)) |
---|
409 | .addToFields(new TemplateField( |
---|
410 | name: 'Harvest date', type: TemplateFieldType.DATE, entity: Subject)) |
---|
411 | .addToFields(new TemplateField( |
---|
412 | name: 'Growth type', type: TemplateFieldType.STRINGLIST, entity: Subject, |
---|
413 | listEntries: [new TemplateFieldListItem(name:'Standard'),new TemplateFieldListItem(name: 'Experimental')])) |
---|
414 | .addToFields(new TemplateField( |
---|
415 | name: 'Growth protocol', type: TemplateFieldType.TEXT, entity: Subject)) |
---|
416 | .addToFields(new TemplateField( |
---|
417 | name: 'Harvest delay', type: TemplateFieldType.TEXT, entity: Subject)) |
---|
418 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
419 | |
---|
420 | def plantSampleTemplate = new Template( |
---|
421 | name: 'Plant sample', |
---|
422 | entity: dbnp.studycapturing.Sample |
---|
423 | ) |
---|
424 | .addToFields(sampleRemarksField) |
---|
425 | .addToFields(sampleVialTextField) |
---|
426 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
427 | |
---|
428 | def materialPrepTemplate = new Template( |
---|
429 | name: 'Plant-material preparation', |
---|
430 | description: 'material preparation', |
---|
431 | entity: dbnp.studycapturing.Event |
---|
432 | ) |
---|
433 | .addToFields(new TemplateField( |
---|
434 | name: 'Tissue', |
---|
435 | type: TemplateFieldType.STRING, |
---|
436 | entity: Event, |
---|
437 | comment: 'organ/ fraction of culture/ plant part') |
---|
438 | ) |
---|
439 | .addToFields( |
---|
440 | new TemplateField( |
---|
441 | name: 'Grinding', |
---|
442 | type: TemplateFieldType.STRINGLIST, |
---|
443 | entity: Event, |
---|
444 | listEntries: [ |
---|
445 | new TemplateFieldListItem(name:'yes'), |
---|
446 | new TemplateFieldListItem(name: 'no'), |
---|
447 | new TemplateFieldListItem(name: 'unknown') |
---|
448 | ] |
---|
449 | ) |
---|
450 | ) |
---|
451 | .addToFields( |
---|
452 | new TemplateField( |
---|
453 | name: 'Storage location', |
---|
454 | type: TemplateFieldType.STRING, |
---|
455 | entity: Event |
---|
456 | ) |
---|
457 | ) |
---|
458 | .addToFields( |
---|
459 | new TemplateField( |
---|
460 | name: 'protocol reference', |
---|
461 | type: TemplateFieldType.STRING, |
---|
462 | entity: Event |
---|
463 | ) |
---|
464 | ) |
---|
465 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
466 | |
---|
467 | def protocolField = new TemplateField( |
---|
468 | name: 'Protocol', |
---|
469 | type: TemplateFieldType.FILE, |
---|
470 | entity: Event, |
---|
471 | comment: 'You can upload a protocol here which describes the procedure which was used when carrying out the event' |
---|
472 | ) |
---|
473 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
474 | |
---|
475 | // diet treatment template |
---|
476 | def dietTreatmentTemplate = new Template( |
---|
477 | name: 'Diet treatment', |
---|
478 | entity: dbnp.studycapturing.Event |
---|
479 | ) |
---|
480 | .addToFields( |
---|
481 | new TemplateField( |
---|
482 | name: 'Diet', |
---|
483 | type: TemplateFieldType.STRINGLIST, |
---|
484 | entity: Event, |
---|
485 | listEntries: [ |
---|
486 | new TemplateFieldListItem(name:'low fat'), |
---|
487 | new TemplateFieldListItem(name: 'high fat') |
---|
488 | ] |
---|
489 | ) |
---|
490 | ) |
---|
491 | .addToFields(protocolField) |
---|
492 | .with { if (!validate()) { errors.each { println it} } else save(flush:true)} |
---|
493 | dietTreatmentTemplate.refresh() |
---|
494 | |
---|
495 | // boost treatment template |
---|
496 | def boostTreatmentTemplate = new Template( |
---|
497 | name: 'Compound challenge', |
---|
498 | entity: dbnp.studycapturing.Event |
---|
499 | ) |
---|
500 | .addToFields( |
---|
501 | new TemplateField( |
---|
502 | name: 'Compound', |
---|
503 | type: TemplateFieldType.ONTOLOGYTERM, |
---|
504 | entity: Event, |
---|
505 | ontologies: [Ontology.getOrCreateOntologyByNcboId(1007)] |
---|
506 | ) |
---|
507 | ) |
---|
508 | .addToFields( |
---|
509 | new TemplateField( |
---|
510 | name: 'Control', |
---|
511 | type: TemplateFieldType.BOOLEAN, |
---|
512 | entity: Event |
---|
513 | ) |
---|
514 | ) |
---|
515 | .addToFields(protocolField) |
---|
516 | .with { if (!validate()) { errors.each { println it} } else save(flush:true)} |
---|
517 | boostTreatmentTemplate.refresh() |
---|
518 | |
---|
519 | // fasting treatment template |
---|
520 | def fastingTreatment = new Template( |
---|
521 | name: 'Fasting treatment', |
---|
522 | description: 'Fasting for a specific amount of time', |
---|
523 | entity: dbnp.studycapturing.Event |
---|
524 | ) |
---|
525 | .addToFields( |
---|
526 | new TemplateField( |
---|
527 | name: 'Fasting period', |
---|
528 | type: TemplateFieldType.RELTIME, |
---|
529 | entity: Event |
---|
530 | ) |
---|
531 | ) |
---|
532 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
533 | |
---|
534 | // SamplingEvent templates |
---|
535 | def samplingProtocolField = new TemplateField( |
---|
536 | name: 'Sample Protocol', |
---|
537 | entity: SamplingEvent, |
---|
538 | type: TemplateFieldType.FILE, |
---|
539 | comment: 'You can upload a protocol here which describes the procedure which was used when carrying out the sampling event' |
---|
540 | ) |
---|
541 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
542 | |
---|
543 | // liver sampling event template |
---|
544 | def liverSamplingEventTemplate = new Template( |
---|
545 | name: 'Liver extraction', |
---|
546 | description: 'Liver sampling for transcriptomics arrays', |
---|
547 | entity: dbnp.studycapturing.SamplingEvent |
---|
548 | ) |
---|
549 | .addToFields(samplingProtocolField) |
---|
550 | .addToFields( |
---|
551 | new TemplateField( |
---|
552 | name: 'Sample weight', |
---|
553 | unit: 'mg', |
---|
554 | entity: SamplingEvent, |
---|
555 | type: TemplateFieldType.DOUBLE |
---|
556 | ) |
---|
557 | ) |
---|
558 | .with { if (!validate()) { errors.each { println it} } else save(flush:true)} |
---|
559 | liverSamplingEventTemplate.refresh() |
---|
560 | |
---|
561 | // blood sampling |
---|
562 | def bloodSamplingEventTemplate = new Template( |
---|
563 | name: 'Blood extraction', |
---|
564 | description: 'Blood extraction targeted at lipid assays', |
---|
565 | entity: dbnp.studycapturing.SamplingEvent |
---|
566 | ) |
---|
567 | .addToFields(samplingProtocolField) |
---|
568 | .addToFields( |
---|
569 | new TemplateField( |
---|
570 | name: 'Sample volume', |
---|
571 | entity: SamplingEvent, |
---|
572 | unit: 'ml', |
---|
573 | type: TemplateFieldType.DOUBLE |
---|
574 | ) |
---|
575 | ) |
---|
576 | .with { if (!validate()) { errors.each { println it} } else save(flush:true)} |
---|
577 | bloodSamplingEventTemplate.refresh() |
---|
578 | |
---|
579 | // plant sample extraction event template |
---|
580 | def plantSamplingExtractEventTemplate = new Template( |
---|
581 | name: 'Plant sample extraction', |
---|
582 | description: 'sample extraction', |
---|
583 | entity: dbnp.studycapturing.SamplingEvent, |
---|
584 | sampleTemplates: [plantSampleTemplate] |
---|
585 | ) |
---|
586 | .addToFields(samplingProtocolField) |
---|
587 | .addToFields( |
---|
588 | new TemplateField( |
---|
589 | name: 'Sample weight', |
---|
590 | unit: 'ul', |
---|
591 | entity: SamplingEvent, |
---|
592 | type: TemplateFieldType.DOUBLE |
---|
593 | ) |
---|
594 | ) |
---|
595 | .addToFields( |
---|
596 | new TemplateField( |
---|
597 | name: 'Sample when measured', |
---|
598 | type: TemplateFieldType.STRINGLIST, |
---|
599 | entity: SamplingEvent, |
---|
600 | listEntries: [ |
---|
601 | new TemplateFieldListItem(name:'Dried'), |
---|
602 | new TemplateFieldListItem(name: 'Fresh'), |
---|
603 | new TemplateFieldListItem(name: 'Unknown') |
---|
604 | ] |
---|
605 | ) |
---|
606 | ) |
---|
607 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
608 | |
---|
609 | // plant sampling event template |
---|
610 | def plantSamplingEventTemplate = new Template( |
---|
611 | name: 'Plant-sample', |
---|
612 | description: 'plant sample ', |
---|
613 | entity: dbnp.studycapturing.SamplingEvent, |
---|
614 | sampleTemplates: [plantSampleTemplate] |
---|
615 | ) |
---|
616 | //.addToFields(samplingProtocolField) |
---|
617 | .addToFields( |
---|
618 | new TemplateField( |
---|
619 | name: 'material', |
---|
620 | comment: 'physical charecteristic. e.g, grounded powder of tomato seed or liquid', |
---|
621 | entity: SamplingEvent, |
---|
622 | type: TemplateFieldType.STRING |
---|
623 | ) |
---|
624 | ) |
---|
625 | .addToFields( |
---|
626 | new TemplateField( |
---|
627 | name: 'Description', |
---|
628 | type: TemplateFieldType.STRING, |
---|
629 | entity: SamplingEvent |
---|
630 | ) |
---|
631 | ) |
---|
632 | .addToFields( |
---|
633 | new TemplateField( |
---|
634 | name: 'extracted material', |
---|
635 | comment: 'substance to be extracted. e.g., lipids, volatiles, primary metabolites etc', |
---|
636 | type: TemplateFieldType.STRING, |
---|
637 | entity: SamplingEvent |
---|
638 | ) |
---|
639 | ) |
---|
640 | .addToFields( |
---|
641 | new TemplateField( |
---|
642 | name: 'Text on vial', |
---|
643 | entity: SamplingEvent, |
---|
644 | type: TemplateFieldType.STRING |
---|
645 | ) |
---|
646 | ) |
---|
647 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
648 | |
---|
649 | |
---|
650 | // assay templates |
---|
651 | def assayDescriptionField = new TemplateField( |
---|
652 | name: 'Description', |
---|
653 | comment: 'add general assay information here', |
---|
654 | entity: Assay, |
---|
655 | type: TemplateFieldType.STRING |
---|
656 | ); |
---|
657 | assayDescriptionField.with { if (!validate()) { errors.each { println it} } else save()} |
---|
658 | |
---|
659 | def ccAssayTemplate = new Template( |
---|
660 | name: 'Clinical chemistry assay', |
---|
661 | description: 'Clinical chemistry assay stored in a SAM module', |
---|
662 | entity: dbnp.studycapturing.Assay |
---|
663 | ) |
---|
664 | .addToFields(assayDescriptionField) |
---|
665 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
666 | |
---|
667 | def metAssayTemplate = new Template( |
---|
668 | name: 'Metabolomics assay', |
---|
669 | description: 'Metabolomics assay stored in a metabolomics module', |
---|
670 | entity: dbnp.studycapturing.Assay |
---|
671 | ) |
---|
672 | .addToFields(assayDescriptionField) |
---|
673 | .addToFields( |
---|
674 | new TemplateField( |
---|
675 | name: 'Spectrometry technique', |
---|
676 | comment: 'Select the used metabolomics technique', |
---|
677 | entity: Assay, |
---|
678 | type: TemplateFieldType.STRINGLIST, |
---|
679 | listEntries: [ |
---|
680 | new TemplateFieldListItem(name: 'GC/MS'), |
---|
681 | new TemplateFieldListItem(name: 'LC/MS'), |
---|
682 | new TemplateFieldListItem(name: 'NMR'), |
---|
683 | new TemplateFieldListItem(name: 'HPLC') |
---|
684 | ]) |
---|
685 | ) |
---|
686 | .with { if (!validate()) { errors.each { println it} } else save(flush:true)} |
---|
687 | metAssayTemplate.refresh() |
---|
688 | } |
---|
689 | |
---|
690 | } |
---|