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