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