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