1 | /** |
---|
2 | * @Author kees |
---|
3 | * @Since Jun 25, 2010 |
---|
4 | * |
---|
5 | * Revision information: |
---|
6 | * $Rev: 836 $ |
---|
7 | * $Author: keesvb $ |
---|
8 | * $Date: 2010-08-25 07:44:58 +0000 (wo, 25 aug 2010) $ |
---|
9 | */ |
---|
10 | |
---|
11 | import dbnp.studycapturing.* |
---|
12 | import dbnp.data.Term |
---|
13 | import dbnp.data.Ontology |
---|
14 | |
---|
15 | class BootStrapStudies { |
---|
16 | |
---|
17 | /** |
---|
18 | * Add example studies. This function is meant to be called only in development mode |
---|
19 | */ |
---|
20 | |
---|
21 | public static void addExampleStudies(dbnp.user.User owner) { |
---|
22 | |
---|
23 | // Look up the used ontologies which should be in the database by now |
---|
24 | def speciesOntology = Ontology.getOrCreateOntologyByNcboId(1132) |
---|
25 | def brendaOntology = Ontology.getOrCreateOntologyByNcboId(1005) |
---|
26 | def nciOntology = Ontology.getOrCreateOntologyByNcboId(1032) |
---|
27 | def chebiOntology = Ontology.getOrCreateOntologyByNcboId(1007) |
---|
28 | |
---|
29 | // Look up the used templates which should also be in the database by now |
---|
30 | def studyTemplate = Template.findByName("Academic study") |
---|
31 | def mouseTemplate = Template.findByName("Mouse") |
---|
32 | def humanTemplate = Template.findByName("Human") |
---|
33 | def dietTreatmentTemplate = Template.findByName("Diet treatment") |
---|
34 | def boostTreatmentTemplate = Template.findByName("Compound challenge") |
---|
35 | def liverSamplingEventTemplate = Template.findByName("Liver extraction") |
---|
36 | def fastingTreatmentTemplate = Template.findByName("Fasting treatment") |
---|
37 | def bloodSamplingEventTemplate = Template.findByName("Blood extraction") |
---|
38 | def humanTissueSampleTemplate = Template.findByName("Human tissue sample") |
---|
39 | def humanBloodSampleTemplate = Template.findByName("Human blood sample") |
---|
40 | def ccAssayTemplate = Template.findByName("Clinical chemistry assay") |
---|
41 | def metAssayTemplate = Template.findByName("Metabolomics assay") |
---|
42 | |
---|
43 | // Add terms manually, to avoid having to do many HTTP requests to the BioPortal website |
---|
44 | println ".adding terms" |
---|
45 | |
---|
46 | |
---|
47 | def mouseTerm = new Term( |
---|
48 | name: 'Mus musculus', |
---|
49 | ontology: speciesOntology, |
---|
50 | accession: '10090' |
---|
51 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
52 | |
---|
53 | def humanTerm = new Term( |
---|
54 | name: 'Homo sapiens', |
---|
55 | ontology: speciesOntology, |
---|
56 | accession: '9606' |
---|
57 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
58 | |
---|
59 | def arabTerm = new Term( |
---|
60 | name: 'Arabidopsis thaliana', |
---|
61 | ontology: speciesOntology, |
---|
62 | accession: '3702' |
---|
63 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
64 | |
---|
65 | def tomatoTerm = new Term( |
---|
66 | name: 'Solanum lycopersicum', |
---|
67 | ontology: speciesOntology, |
---|
68 | accession: '4081' |
---|
69 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
70 | |
---|
71 | def potatoTerm = new Term( |
---|
72 | name: 'Solanum tuberosum', |
---|
73 | ontology: speciesOntology, |
---|
74 | accession: '0000' |
---|
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 | def glucoseTerm = new Term( |
---|
90 | name: 'Glucose', |
---|
91 | ontology: chebiOntology, |
---|
92 | accession: 'CHEBI:17234' |
---|
93 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
94 | |
---|
95 | // Create a few persons, roles and Affiliations |
---|
96 | println ".adding persons, roles and affiliations" |
---|
97 | def affiliation1 = new PersonAffiliation( |
---|
98 | institute: "Science Institute NYC", |
---|
99 | department: "Department of Mathematics" |
---|
100 | ).save(); |
---|
101 | def affiliation2 = new PersonAffiliation( |
---|
102 | institute: "InfoStats GmbH, Hamburg", |
---|
103 | department: "Life Sciences" |
---|
104 | ).save(); |
---|
105 | def role1 = new PersonRole( |
---|
106 | name: "Principal Investigator" |
---|
107 | ).save(); |
---|
108 | def role2 = new PersonRole( |
---|
109 | name: "Statician" |
---|
110 | ).save(); |
---|
111 | |
---|
112 | // Create persons |
---|
113 | def person1 = new Person( |
---|
114 | lastName: "Scientist", |
---|
115 | firstName: "John", |
---|
116 | gender: "Male", |
---|
117 | initials: "J.R.", |
---|
118 | email: "john@scienceinstitute.com", |
---|
119 | phone: "1-555-3049", |
---|
120 | address: "First street 2,NYC" |
---|
121 | ) |
---|
122 | .addToAffiliations( affiliation1 ) |
---|
123 | .addToAffiliations( affiliation2 ) |
---|
124 | .save(); |
---|
125 | |
---|
126 | def person2 = new Person( |
---|
127 | lastName: "Statician", |
---|
128 | firstName: "Jane", |
---|
129 | gender: "Female", |
---|
130 | initials: "W.J.", |
---|
131 | email: "jane@statisticalcompany.de", |
---|
132 | phone: "49-555-8291", |
---|
133 | address: "Dritten strasse 38, Hamburg, Germany" |
---|
134 | ) |
---|
135 | .addToAffiliations( affiliation2 ) |
---|
136 | .save(); |
---|
137 | |
---|
138 | // Create 30 persons to test pagination |
---|
139 | def personCounter = 1; |
---|
140 | 30.times { new Person( firstName: "Person #${personCounter}", lastName: "Testperson", email: "email${personCounter++}@testdomain.com" ).save() } |
---|
141 | |
---|
142 | // Create a few publications |
---|
143 | println ".adding publications" |
---|
144 | def publication1 = new Publication( |
---|
145 | title: "Postnatal development of hypothalamic leptin receptors", |
---|
146 | authorsList: "Cottrell EC, Mercer JG, Ozanne SE.", |
---|
147 | pubMedID: "20472140", |
---|
148 | comments: "Not published yet", |
---|
149 | DOI: "unknown" |
---|
150 | ) |
---|
151 | .save(); |
---|
152 | |
---|
153 | def publication2 = new Publication( |
---|
154 | title: "Induction of regulatory T cells decreases adipose inflammation and alleviates insulin resistance in ob/ob mice", |
---|
155 | authorsList: "Ilan Y, Maron R, Tukpah AM, Maioli TU, Murugaiyan G, Yang K, Wu HY, Weiner HL.", |
---|
156 | pubMedID: "20445103", |
---|
157 | comments: "", |
---|
158 | DOI: "" |
---|
159 | ) |
---|
160 | .save(); |
---|
161 | |
---|
162 | // Add example mouse study |
---|
163 | println ".adding NuGO PPS3 leptin example study..." |
---|
164 | def mouseStudy = new Study( |
---|
165 | template: studyTemplate, |
---|
166 | title:"NuGO PPS3 mouse study leptin module", |
---|
167 | code:"PPS3_leptin_module", |
---|
168 | researchQuestion:"Leptin etc.", |
---|
169 | ecCode:"2007117.c", |
---|
170 | startDate: Date.parse('yyyy-MM-dd','2008-01-02'), |
---|
171 | owner: owner |
---|
172 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
173 | |
---|
174 | 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." ) |
---|
175 | mouseStudy.save() |
---|
176 | |
---|
177 | def evLF = new Event( |
---|
178 | startTime: 3600, |
---|
179 | endTime: 3600 +7 * 24 * 3600, |
---|
180 | template: dietTreatmentTemplate |
---|
181 | ) |
---|
182 | .setFieldValue( 'Diet','low fat') |
---|
183 | |
---|
184 | def evHF = new Event( |
---|
185 | startTime: 3600, |
---|
186 | endTime: 3600 +7 * 24 * 3600, |
---|
187 | template: dietTreatmentTemplate |
---|
188 | ) |
---|
189 | .setFieldValue( 'Diet','high fat' ) |
---|
190 | |
---|
191 | def evBV = new Event( |
---|
192 | startTime: 3600, |
---|
193 | endTime: 3600 +7 * 24 * 3600, |
---|
194 | template: boostTreatmentTemplate |
---|
195 | ) |
---|
196 | .setFieldValue( 'Control','true' ) |
---|
197 | |
---|
198 | def evBL = new Event( |
---|
199 | startTime: 3600, |
---|
200 | endTime: 3600 +7 * 24 * 3600, |
---|
201 | template: boostTreatmentTemplate |
---|
202 | ) |
---|
203 | .setFieldValue( 'Control','false' ) |
---|
204 | |
---|
205 | def evLF4 = new Event( |
---|
206 | startTime: 3600, |
---|
207 | endTime: 3600 + 4 * 7 * 24 * 3600, |
---|
208 | template: dietTreatmentTemplate |
---|
209 | ) |
---|
210 | .setFieldValue( 'Diet','low fat') |
---|
211 | |
---|
212 | def evHF4 = new Event( |
---|
213 | startTime: 3600, |
---|
214 | endTime: 3600 + 4 * 7 * 24 * 3600, |
---|
215 | template: dietTreatmentTemplate |
---|
216 | ) |
---|
217 | .setFieldValue( 'Diet','high fat' ) |
---|
218 | |
---|
219 | def evBV4 = new Event( |
---|
220 | startTime: 3600, |
---|
221 | endTime: 3600 + 4 * 7 * 24 * 3600, |
---|
222 | template: boostTreatmentTemplate |
---|
223 | ) |
---|
224 | .setFieldValue( 'Control','true' ) |
---|
225 | |
---|
226 | def evBL4 = new Event( |
---|
227 | startTime: 3600, |
---|
228 | endTime: 3600 + 4 * 7 * 24 * 3600, |
---|
229 | template: boostTreatmentTemplate |
---|
230 | ) |
---|
231 | .setFieldValue( 'Control','false' ) |
---|
232 | |
---|
233 | def evS = new SamplingEvent( |
---|
234 | startTime: 3600 +7 * 24 * 3600, |
---|
235 | template: liverSamplingEventTemplate, |
---|
236 | sampleTemplate: humanTissueSampleTemplate) |
---|
237 | .setFieldValue('Sample weight',5F) |
---|
238 | |
---|
239 | def evS4 = new SamplingEvent( |
---|
240 | startTime: 3600 +7 * 24 * 3600, |
---|
241 | template: liverSamplingEventTemplate, |
---|
242 | sampleTemplate: humanTissueSampleTemplate) |
---|
243 | .setFieldValue('Sample weight',5F) |
---|
244 | |
---|
245 | // Add events to study |
---|
246 | mouseStudy |
---|
247 | .addToEvents(evLF) |
---|
248 | .addToEvents(evHF) |
---|
249 | .addToEvents(evBV) |
---|
250 | .addToEvents(evBL) |
---|
251 | .addToEvents(evLF4) |
---|
252 | .addToEvents(evHF4) |
---|
253 | .addToEvents(evBV4) |
---|
254 | .addToEvents(evBL4) |
---|
255 | .addToSamplingEvents(evS) |
---|
256 | .addToSamplingEvents(evS4) |
---|
257 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
258 | |
---|
259 | // Extra check if the SamplingEvents are saved correctly |
---|
260 | evS.with { if (!validate()) { errors.each { println it} } else save()} |
---|
261 | evS4.with { if (!validate()) { errors.each { println it} } else save()} |
---|
262 | |
---|
263 | def LFBV1 = new EventGroup(name:"10% fat + vehicle for 1 week") |
---|
264 | .addToEvents(evLF) |
---|
265 | .addToEvents(evBV) |
---|
266 | .addToSamplingEvents(evS) |
---|
267 | |
---|
268 | def LFBL1 = new EventGroup(name:"10% fat + leptin for 1 week") |
---|
269 | .addToEvents(evLF) |
---|
270 | .addToEvents(evBL) |
---|
271 | .addToSamplingEvents(evS) |
---|
272 | |
---|
273 | def HFBV1 = new EventGroup(name:"45% fat + vehicle for 1 week") |
---|
274 | .addToEvents(evHF) |
---|
275 | .addToEvents(evBV) |
---|
276 | .addToSamplingEvents(evS) |
---|
277 | |
---|
278 | def HFBL1 = new EventGroup(name:"45% fat + leptin for 1 week") |
---|
279 | .addToEvents(evHF) |
---|
280 | .addToEvents(evBL) |
---|
281 | .addToSamplingEvents(evS) |
---|
282 | |
---|
283 | def LFBV4 = new EventGroup(name:"10% fat + vehicle for 4 weeks") |
---|
284 | .addToEvents(evLF4) |
---|
285 | .addToEvents(evBV4) |
---|
286 | .addToSamplingEvents(evS4) |
---|
287 | |
---|
288 | def LFBL4 = new EventGroup(name:"10% fat + leptin for 4 weeks") |
---|
289 | .addToEvents(evLF4) |
---|
290 | .addToEvents(evBL4) |
---|
291 | .addToSamplingEvents(evS4) |
---|
292 | |
---|
293 | def HFBV4 = new EventGroup(name:"45% fat + vehicle for 4 weeks") |
---|
294 | .addToEvents(evHF4) |
---|
295 | .addToEvents(evBV4) |
---|
296 | .addToSamplingEvents(evS4) |
---|
297 | |
---|
298 | def HFBL4 = new EventGroup(name:"45% fat + leptin for 4 weeks") |
---|
299 | .addToEvents(evHF4) |
---|
300 | .addToEvents(evBL4) |
---|
301 | .addToSamplingEvents(evS4) |
---|
302 | |
---|
303 | // Add subjects and samples and compose EventGroups |
---|
304 | def x=1 |
---|
305 | 80.times { |
---|
306 | def currentSubject = new Subject( |
---|
307 | name: "A" + x++, |
---|
308 | species: mouseTerm, |
---|
309 | template: mouseTemplate, |
---|
310 | ) |
---|
311 | .setFieldValue("Gender", "Male") |
---|
312 | .setFieldValue("Genotype", c57bl6Term) |
---|
313 | .setFieldValue("Age", 17) |
---|
314 | .setFieldValue("Cage", "" + (int)(x/2)) |
---|
315 | |
---|
316 | // We have to save the subject first, otherwise the parentEvent property of the sample cannot be set |
---|
317 | // (this is possibly a Grails or Hibernate bug) |
---|
318 | mouseStudy.addToSubjects(currentSubject) |
---|
319 | currentSubject.with { if (!validate()) { errors.each { println it} } else save()} |
---|
320 | |
---|
321 | // Add subject to appropriate EventGroup |
---|
322 | if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } |
---|
323 | else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } |
---|
324 | else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() } |
---|
325 | else if (x > 40) { LFBV4.addToSubjects(currentSubject).save() } |
---|
326 | else if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } |
---|
327 | else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } |
---|
328 | else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } |
---|
329 | else { LFBV1.addToSubjects(currentSubject).save() } |
---|
330 | |
---|
331 | // Create sample |
---|
332 | def currentSample = new Sample( |
---|
333 | name: currentSubject.name + '_B', |
---|
334 | material: bloodTerm, |
---|
335 | template: humanBloodSampleTemplate, |
---|
336 | parentSubject: currentSubject, |
---|
337 | parentEvent: evS //x > 40 ? evS4 : evS |
---|
338 | ); |
---|
339 | mouseStudy.addToSamples(currentSample) |
---|
340 | currentSample.with { if (!validate()) { errors.each { println it} } else save()} |
---|
341 | currentSample.setFieldValue( "Text on vial", "T" + (Math.random() * 100L) ) |
---|
342 | } |
---|
343 | |
---|
344 | // Add EventGroups to study |
---|
345 | mouseStudy |
---|
346 | .addToEventGroups(LFBV1) |
---|
347 | .addToEventGroups(LFBL1) |
---|
348 | .addToEventGroups(HFBV1) |
---|
349 | .addToEventGroups(HFBL1) |
---|
350 | .addToEventGroups(LFBV4) |
---|
351 | .addToEventGroups(LFBL4) |
---|
352 | .addToEventGroups(HFBV4) |
---|
353 | .addToEventGroups(HFBL4) |
---|
354 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
355 | |
---|
356 | // Add persons and publications to study |
---|
357 | def studyperson1 = new StudyPerson( person: person1, role: role1 ) |
---|
358 | def studyperson2 = new StudyPerson( person: person2, role: role2 ) |
---|
359 | |
---|
360 | mouseStudy |
---|
361 | .addToPersons( studyperson1 ) |
---|
362 | .addToPersons( studyperson2 ) |
---|
363 | .addToPublications( publication1 ) |
---|
364 | .addToPublications( publication2 ) |
---|
365 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
366 | |
---|
367 | // Add example human study |
---|
368 | println ".adding NuGO PPSH example study..." |
---|
369 | |
---|
370 | def humanStudy = new Study( |
---|
371 | template: studyTemplate, |
---|
372 | title:"NuGO PPS human study", |
---|
373 | code:"PPSH", |
---|
374 | researchQuestion:"How much are fasting plasma and urine metabolite levels affected by prolonged fasting ?", |
---|
375 | description:"Human study", |
---|
376 | ecCode:"unknown", |
---|
377 | startDate: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
378 | owner: owner |
---|
379 | ) |
---|
380 | .setFieldValue( 'Description', "Human study performed at RRI; centres involved: RRI, IFR, TUM, Maastricht U." ) |
---|
381 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
382 | |
---|
383 | def rootGroup = new EventGroup(name: 'Root group'); |
---|
384 | |
---|
385 | def fastingEvent = new Event( |
---|
386 | startTime: 3 * 24 * 3600 + 22 * 3600, |
---|
387 | endTime: 3 * 24 * 3600 + 30 * 3600, |
---|
388 | template: fastingTreatmentTemplate) |
---|
389 | .setFieldValue('Fasting period','8h'); |
---|
390 | |
---|
391 | def bloodSamplingEventBefore = new SamplingEvent( |
---|
392 | startTime: 0, |
---|
393 | template: bloodSamplingEventTemplate, |
---|
394 | sampleTemplate: humanBloodSampleTemplate) |
---|
395 | .setFieldValue('Sample volume',4.5F); |
---|
396 | |
---|
397 | def bloodSamplingEventAfter = new SamplingEvent( |
---|
398 | startTime: 3 * 24 * 3600 + 30 * 3600, |
---|
399 | template: bloodSamplingEventTemplate, |
---|
400 | sampleTemplate: humanBloodSampleTemplate) |
---|
401 | .setFieldValue('Sample volume',4.5F); |
---|
402 | |
---|
403 | rootGroup.addToEvents fastingEvent |
---|
404 | rootGroup.addToSamplingEvents bloodSamplingEventBefore |
---|
405 | rootGroup.addToSamplingEvents bloodSamplingEventAfter |
---|
406 | rootGroup.save() |
---|
407 | |
---|
408 | def y = 1 |
---|
409 | 11.times { |
---|
410 | def currentSubject = new Subject( |
---|
411 | name: "" + y++, |
---|
412 | species: humanTerm, |
---|
413 | template: humanTemplate |
---|
414 | ) |
---|
415 | .setFieldValue("Gender", (Math.random() > 0.5) ? "Male" : "Female") |
---|
416 | .setFieldValue("DOB", new java.text.SimpleDateFormat("dd-mm-yy").parse("01-02-19" + (10 + (int) (Math.random() * 80)))) |
---|
417 | .setFieldValue("Age", 30) |
---|
418 | .setFieldValue("Height", Math.random() * 2F) |
---|
419 | .setFieldValue("Weight", Math.random() * 150F) |
---|
420 | .setFieldValue("BMI", 20 + Math.random() * 10F) |
---|
421 | |
---|
422 | humanStudy.addToSubjects(currentSubject) |
---|
423 | currentSubject.with { if (!validate()) { errors.each { println it} } else save()} |
---|
424 | |
---|
425 | rootGroup.addToSubjects currentSubject |
---|
426 | rootGroup.save() |
---|
427 | |
---|
428 | def currentSample = new Sample( |
---|
429 | name: currentSubject.name + '_B', |
---|
430 | material: bloodTerm, |
---|
431 | template: humanBloodSampleTemplate, |
---|
432 | parentSubject: currentSubject, |
---|
433 | parentEvent: bloodSamplingEventBefore |
---|
434 | ); |
---|
435 | |
---|
436 | humanStudy.addToSamples(currentSample) |
---|
437 | currentSample.with { if (!validate()) { errors.each { println it} } else save()} |
---|
438 | currentSample.setFieldValue( "Text on vial", "T" + (Math.random() * 100L) ) |
---|
439 | |
---|
440 | currentSample = new Sample( |
---|
441 | name: currentSubject.name + '_A', |
---|
442 | material: bloodTerm, |
---|
443 | template: humanBloodSampleTemplate, |
---|
444 | parentSubject: currentSubject, |
---|
445 | parentEvent: bloodSamplingEventAfter |
---|
446 | ); |
---|
447 | |
---|
448 | humanStudy.addToSamples(currentSample) |
---|
449 | currentSample.with { if (!validate()) { errors.each { println it} } else save()} |
---|
450 | currentSample.setFieldValue( "Text on vial", "T" + (Math.random() * 100L) ) |
---|
451 | } |
---|
452 | |
---|
453 | humanStudy.addToEvents(fastingEvent) |
---|
454 | humanStudy.addToSamplingEvents(bloodSamplingEventBefore) |
---|
455 | humanStudy.addToSamplingEvents(bloodSamplingEventAfter) |
---|
456 | humanStudy.addToEventGroups rootGroup |
---|
457 | |
---|
458 | println ".adding persons and saving PPSH study..." |
---|
459 | // Add persons to study |
---|
460 | def studyperson3 = new StudyPerson( person: person1, role: role2 ) |
---|
461 | humanStudy |
---|
462 | .addToPersons( studyperson3 ) |
---|
463 | .addToPublications( publication2 ) |
---|
464 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
465 | |
---|
466 | println ".adding assay references to mouse example study..." |
---|
467 | |
---|
468 | // Add SAM assay reference |
---|
469 | def clinicalModule = new AssayModule( |
---|
470 | name: 'SAM module for clinical data', |
---|
471 | platform: 'clinical measurements', |
---|
472 | url: 'http://localhost:8182/sam' |
---|
473 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
474 | |
---|
475 | // Add metabolomics assay reference |
---|
476 | def metabolomicsModule = new AssayModule( |
---|
477 | name: 'Metabolomics module', |
---|
478 | platform: 'GCMS/LCMS', |
---|
479 | url: 'http://localhost:8080/nmcdsp' |
---|
480 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
481 | |
---|
482 | def lipidAssayRef = new Assay( |
---|
483 | name: 'Lipid profiling', |
---|
484 | template: ccAssayTemplate, |
---|
485 | module: clinicalModule, |
---|
486 | externalAssayID: 'PPS3_SAM' |
---|
487 | ) |
---|
488 | |
---|
489 | def metAssayRef = new Assay( |
---|
490 | name: 'Lipidomics profile', |
---|
491 | template: metAssayTemplate, |
---|
492 | module: metabolomicsModule, |
---|
493 | externalAssayID: 'PPS3_Lipidomics' |
---|
494 | ) |
---|
495 | .setFieldValue('Spectrometry technique','LC/MS') |
---|
496 | |
---|
497 | mouseStudy.samples*.each { |
---|
498 | lipidAssayRef.addToSamples(it) |
---|
499 | metAssayRef.addToSamples(it) |
---|
500 | } |
---|
501 | |
---|
502 | mouseStudy.addToAssays(lipidAssayRef); |
---|
503 | mouseStudy.addToAssays(metAssayRef); |
---|
504 | mouseStudy.save(flush:true) |
---|
505 | |
---|
506 | println ".adding assay references to human example study..." |
---|
507 | |
---|
508 | def glucoseAssayBRef = new Assay( |
---|
509 | name: 'Glucose assay before', |
---|
510 | template: ccAssayTemplate, |
---|
511 | module: clinicalModule, |
---|
512 | externalAssayID: 'PPSH-Glu-B' |
---|
513 | ) |
---|
514 | |
---|
515 | def glucoseAssayARef = new Assay( |
---|
516 | name: 'Glucose assay after', |
---|
517 | template: ccAssayTemplate, |
---|
518 | module: clinicalModule, |
---|
519 | externalAssayID: 'PPSH-Glu-A' |
---|
520 | ) |
---|
521 | |
---|
522 | def metAssayRefB = new Assay( |
---|
523 | name: 'Lipidomics profile before', |
---|
524 | template: metAssayTemplate, |
---|
525 | module: metabolomicsModule, |
---|
526 | externalAssayID: 'PPSH_Lipidomics_start' |
---|
527 | ) |
---|
528 | .setFieldValue('Spectrometry technique','GC/MS') |
---|
529 | |
---|
530 | def metAssayRefA = new Assay( |
---|
531 | name: 'Lipidomics profile after', |
---|
532 | template: metAssayTemplate, |
---|
533 | module: metabolomicsModule, |
---|
534 | externalAssayID: 'PPSH_Lipidomics_end' |
---|
535 | ) |
---|
536 | .setFieldValue('Spectrometry technique','GC/MS') |
---|
537 | |
---|
538 | humanStudy.samples*.each { |
---|
539 | if (it.parentEvent.startTime == 0) { |
---|
540 | glucoseAssayBRef.addToSamples(it) |
---|
541 | metAssayRefB.addToSamples(it) |
---|
542 | } |
---|
543 | else { |
---|
544 | glucoseAssayARef.addToSamples(it) |
---|
545 | metAssayRefA.addToSamples(it) |
---|
546 | } |
---|
547 | } |
---|
548 | |
---|
549 | |
---|
550 | humanStudy.addToAssays(glucoseAssayARef) |
---|
551 | humanStudy.addToAssays(glucoseAssayBRef) |
---|
552 | humanStudy.addToAssays(metAssayRefA) |
---|
553 | humanStudy.addToAssays(metAssayRefB) |
---|
554 | humanStudy.save(flush:true) |
---|
555 | |
---|
556 | } |
---|
557 | |
---|
558 | } |
---|