[92] | 1 | import dbnp.studycapturing.* |
---|
[15] | 2 | |
---|
[106] | 3 | import dbnp.data.Ontology |
---|
| 4 | import dbnp.data.Term |
---|
| 5 | |
---|
[15] | 6 | /** |
---|
| 7 | * Application Bootstrapper |
---|
[92] | 8 | * @Author Jeroen Wesbeek |
---|
| 9 | * @Since 20091021 |
---|
[15] | 10 | * |
---|
| 11 | * Revision information: |
---|
| 12 | * $Rev: 383 $ |
---|
| 13 | * $Author: duh $ |
---|
| 14 | * $Date: 2010-04-26 16:36:49 +0000 (ma, 26 apr 2010) $ |
---|
| 15 | */ |
---|
[4] | 16 | class BootStrap { |
---|
[92] | 17 | def init = {servletContext -> |
---|
[138] | 18 | // define timezone |
---|
[246] | 19 | System.setProperty('user.timezone', 'CET') |
---|
[95] | 20 | |
---|
[266] | 21 | // we could also check if we are in development by GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT |
---|
| 22 | if (Study.count() == 0) { |
---|
[360] | 23 | println ".development bootstrapping..."; |
---|
[347] | 24 | |
---|
[353] | 25 | // add NCBI species ontology |
---|
| 26 | println ".adding NCBI species ontology" |
---|
| 27 | def speciesOntology = new Ontology( |
---|
| 28 | name: 'NCBI organismal classification', |
---|
| 29 | description: 'A taxonomic classification of living organisms and associated artifacts for their controlled description within the context of databases.', |
---|
| 30 | url: 'http://www.ncbi.nlm.nih.gov/Taxonomy/taxonomyhome.html/', |
---|
| 31 | versionNumber: '1.2', |
---|
| 32 | ncboId: '1132', |
---|
| 33 | ncboVersionedId: '38802' |
---|
| 34 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
[349] | 35 | |
---|
[353] | 36 | // add TERMS |
---|
| 37 | println ".adding mouse term" |
---|
| 38 | def mouseTerm = new Term( |
---|
| 39 | name: 'Mus musculus', |
---|
| 40 | ontology: speciesOntology, |
---|
| 41 | accession: '10090' |
---|
| 42 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 43 | println ".adding human term" |
---|
| 44 | def humanTerm = new Term( |
---|
| 45 | name: 'Homo sapiens', |
---|
| 46 | ontology: speciesOntology, |
---|
| 47 | accession: '9606' |
---|
| 48 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
[349] | 49 | |
---|
[370] | 50 | // Create a few persons, roles and Affiliations |
---|
| 51 | println ".adding persons, roles and affiliations" |
---|
| 52 | def affiliation1 = new PersonAffiliation( |
---|
| 53 | name: "Science Institute NYC" |
---|
| 54 | ).save(); |
---|
| 55 | def affiliation2 = new PersonAffiliation( |
---|
| 56 | name: "InfoStats GmbH, Hamburg" |
---|
| 57 | ).save(); |
---|
| 58 | def role1 = new PersonRole( |
---|
| 59 | name: "Principal Investigator" |
---|
| 60 | ).save(); |
---|
| 61 | def role2 = new PersonRole( |
---|
| 62 | name: "Statician" |
---|
| 63 | ).save(); |
---|
[379] | 64 | |
---|
| 65 | // Create 30 roles to test pagination |
---|
| 66 | def roleCounter = 1; |
---|
| 67 | 30.times { new PersonRole( name: "Rol #${roleCounter++}" ).save() } |
---|
| 68 | |
---|
| 69 | // Create persons |
---|
[370] | 70 | def person1 = new Person( |
---|
| 71 | lastName: "Scientist", |
---|
| 72 | firstName: "John", |
---|
[382] | 73 | gender: "Male", |
---|
| 74 | initials: "J.R.", |
---|
[370] | 75 | email: "john@scienceinstitute.com", |
---|
| 76 | phone: "1-555-3049", |
---|
| 77 | address: "First street 2,NYC" |
---|
| 78 | ) |
---|
| 79 | .addToAffiliations( affiliation1 ) |
---|
| 80 | .addToAffiliations( affiliation2 ) |
---|
| 81 | .save(); |
---|
| 82 | |
---|
| 83 | def person2 = new Person( |
---|
| 84 | lastName: "Statician", |
---|
| 85 | firstName: "Jane", |
---|
[382] | 86 | gender: "Female", |
---|
| 87 | initials: "W.J.", |
---|
[370] | 88 | email: "jane@statisticalcompany.de", |
---|
| 89 | phone: "49-555-8291", |
---|
| 90 | address: "Dritten strasse 38, Hamburg, Germany" |
---|
| 91 | ) |
---|
| 92 | .addToAffiliations( affiliation2 ) |
---|
| 93 | .save(); |
---|
[353] | 94 | |
---|
[379] | 95 | // Create 30 persons to test pagination |
---|
| 96 | def personCounter = 1; |
---|
[382] | 97 | 30.times { new Person( firstName: "Person #${personCounter}", lastName: "Testperson", email: "email${personCounter++}@testdomain.com" ).save() } |
---|
[379] | 98 | |
---|
[347] | 99 | /* COMMENTED OUT BECAUSE IT BREAKS EVERYTHING AFTER REFACTORING THE DATAMODEL |
---|
| 100 | |
---|
[92] | 101 | // ontologies |
---|
| 102 | def speciesOntology = new Ontology( |
---|
[136] | 103 | name: 'NCBI Taxonomy', |
---|
| 104 | shortName: 'Taxon', |
---|
[92] | 105 | url: 'http://www.obofoundry.org/cgi-bin/detail.cgi?id=ncbi_taxonomy' |
---|
[139] | 106 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
[92] | 107 | |
---|
[186] | 108 | def humanBodyOntology = new Ontology( |
---|
| 109 | name: 'Foundational Model of Anatomy', |
---|
| 110 | shortName: 'HumanBody', |
---|
| 111 | url: 'http://bioportal.bioontology.org/ontologies/39966' |
---|
| 112 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 113 | |
---|
[339] | 114 | def nciOntology = new Ontology( |
---|
| 115 | name: 'NCI Thesaurus', |
---|
| 116 | shortName: 'NCI', |
---|
| 117 | url: 'http://bioportal.bioontology.org/ontologies/42331' |
---|
| 118 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 119 | |
---|
[92] | 120 | // terms |
---|
| 121 | def mouseTerm = new Term( |
---|
| 122 | name: 'Mus musculus', |
---|
| 123 | ontology: speciesOntology, |
---|
| 124 | accession: '10090' |
---|
[139] | 125 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
[92] | 126 | def humanTerm = new Term( |
---|
| 127 | name: 'Homo sapiens', |
---|
| 128 | ontology: speciesOntology, |
---|
| 129 | accession: '9606' |
---|
[139] | 130 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
[339] | 131 | def arabTerm = new Term( |
---|
| 132 | name: 'Arabidopsis thaliana', |
---|
| 133 | ontology: speciesOntology, |
---|
| 134 | accession: '3702' |
---|
| 135 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 136 | |
---|
[186] | 137 | def bloodTerm = new Term( |
---|
| 138 | name: 'Portion of blood', |
---|
| 139 | ontology: humanBodyOntology, |
---|
| 140 | accession: '9670' |
---|
| 141 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 142 | |
---|
[339] | 143 | def c57bl6Term = new Term( |
---|
| 144 | name: 'C57BL/6 Mouse', |
---|
| 145 | ontology: nciOntology, |
---|
| 146 | accession: 'C14424' |
---|
| 147 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 148 | |
---|
[139] | 149 | def madmaxOntology = new Ontology( |
---|
| 150 | name: 'Madmax ontology', |
---|
| 151 | shortName: 'MDMX', |
---|
| 152 | url: 'madmax.bioinformatics.nl' |
---|
| 153 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 154 | |
---|
| 155 | def treatmentTerm = new Term( |
---|
| 156 | name: 'ExperimentalProtocol', |
---|
| 157 | ontology: madmaxOntology, |
---|
| 158 | accession: 'P-MDMXGE-264' |
---|
| 159 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 160 | |
---|
[232] | 161 | def dietProtocol = new Protocol( |
---|
| 162 | name: 'Diet treatment Protocol NuGO PPS3 leptin module', |
---|
[139] | 163 | reference: treatmentTerm |
---|
| 164 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 165 | |
---|
[232] | 166 | def boostProtocol = new Protocol( |
---|
| 167 | name: 'Boost treatment Protocol NuGO PPS3 leptin module', |
---|
| 168 | reference: treatmentTerm |
---|
| 169 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 170 | |
---|
[212] | 171 | def fastingProtocol = new Protocol( |
---|
| 172 | name: 'Fasting', |
---|
[149] | 173 | reference: treatmentTerm |
---|
| 174 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 175 | |
---|
[235] | 176 | |
---|
| 177 | // ParameterStringListItems |
---|
| 178 | def oil10= new ParameterStringListItem( |
---|
| 179 | name: '10% fat (palm oil)' |
---|
| 180 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 181 | def oil45= new ParameterStringListItem( |
---|
| 182 | name: '45% fat (palm oil)' |
---|
| 183 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 184 | def vehicle= new ParameterStringListItem( |
---|
| 185 | name: 'Vehicle' |
---|
| 186 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 187 | def leptin= new ParameterStringListItem( |
---|
| 188 | name: 'Leptin' |
---|
| 189 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 190 | |
---|
| 191 | |
---|
[232] | 192 | dietProtocol |
---|
[139] | 193 | .addToParameters(new ProtocolParameter( |
---|
| 194 | name: 'Diet', |
---|
| 195 | type: ProtocolParameterType.STRINGLIST, |
---|
[235] | 196 | listEntries: [oil10,oil45])) |
---|
[232] | 197 | .save() |
---|
| 198 | |
---|
| 199 | boostProtocol |
---|
[139] | 200 | .addToParameters(new ProtocolParameter( |
---|
| 201 | name: 'Compound', |
---|
| 202 | type: ProtocolParameterType.STRINGLIST, |
---|
[235] | 203 | listEntries: [vehicle,leptin])) |
---|
[139] | 204 | .save() |
---|
| 205 | |
---|
[212] | 206 | fastingProtocol |
---|
[149] | 207 | .addToParameters(new ProtocolParameter( |
---|
[212] | 208 | name: 'Fasting period', |
---|
[149] | 209 | type: ProtocolParameterType.STRING)) |
---|
| 210 | .save() |
---|
| 211 | |
---|
[235] | 212 | |
---|
[186] | 213 | // sampling event protocols |
---|
[149] | 214 | |
---|
[186] | 215 | def liverSamplingProtocol = new Protocol( |
---|
| 216 | name: 'Liver sampling' |
---|
| 217 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
[149] | 218 | |
---|
[186] | 219 | liverSamplingProtocol |
---|
| 220 | .addToParameters(new ProtocolParameter( |
---|
| 221 | name: 'Sample weight', |
---|
| 222 | unit: 'mg', |
---|
| 223 | type: ProtocolParameterType.FLOAT)) |
---|
| 224 | .save() |
---|
| 225 | |
---|
| 226 | def bloodSamplingProtocol = new Protocol( |
---|
[246] | 227 | name: 'Blood sampling' |
---|
[186] | 228 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 229 | |
---|
| 230 | bloodSamplingProtocol |
---|
| 231 | .addToParameters(new ProtocolParameter( |
---|
| 232 | name: 'Sample volume', |
---|
| 233 | unit: 'ml', |
---|
| 234 | type: ProtocolParameterType.FLOAT)) |
---|
| 235 | .save() |
---|
[346] | 236 | */ |
---|
[92] | 237 | // create system user |
---|
[224] | 238 | |
---|
| 239 | /*def systemUser = userService.createUser(InstanceGenerator.user( |
---|
[92] | 240 | username: 'system', |
---|
| 241 | pass: 'system', |
---|
| 242 | passConfirm: 'system', |
---|
| 243 | enabled: true |
---|
[224] | 244 | ))*/ |
---|
[92] | 245 | |
---|
[364] | 246 | |
---|
[224] | 247 | def genderField = new TemplateField( |
---|
[186] | 248 | name: 'Gender',type: TemplateFieldType.STRINGLIST, |
---|
[232] | 249 | listEntries: [new TemplateFieldListItem(name:'Male'),new TemplateFieldListItem(name: 'Female')]) |
---|
[186] | 250 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
[253] | 251 | |
---|
[224] | 252 | def ageField = new TemplateField( |
---|
[269] | 253 | name: 'Age (years)',type: TemplateFieldType.INTEGER,unit: 'years') |
---|
[212] | 254 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
[186] | 255 | |
---|
[339] | 256 | def genotypeField = new TemplateField( |
---|
| 257 | name: 'Genotype', type: TemplateFieldType.ONTOLOGYTERM) |
---|
| 258 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 259 | |
---|
| 260 | def genotypeTypeField = new TemplateField( |
---|
| 261 | name: 'Genotype type',type: TemplateFieldType.STRINGLIST, |
---|
[375] | 262 | listEntries: [new TemplateFieldListItem(name:'wildtype'), |
---|
| 263 | new TemplateFieldListItem(name:'transgenic'), |
---|
[339] | 264 | new TemplateFieldListItem(name:'knock-out'), |
---|
| 265 | new TemplateFieldListItem(name:'knock-in')]) |
---|
| 266 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 267 | |
---|
| 268 | |
---|
[232] | 269 | // Nutritional study template |
---|
| 270 | |
---|
[364] | 271 | println ".adding academic study template..." |
---|
[232] | 272 | def studyTemplate = new Template( |
---|
[269] | 273 | name: 'Academic study', entity: dbnp.studycapturing.Study) |
---|
[375] | 274 | .addToFields(new TemplateField(name: 'Description',type: TemplateFieldType.TEXT)) |
---|
[366] | 275 | .addToFields(new TemplateField(name: 'Study code',type: TemplateFieldType.STRING)) |
---|
| 276 | .addToFields(new TemplateField(name: 'Objectives',type: TemplateFieldType.TEXT)) |
---|
[331] | 277 | .addToFields(new TemplateField(name: 'Consortium',type: TemplateFieldType.STRING)) |
---|
| 278 | .addToFields(new TemplateField(name: 'Cohort name',type: TemplateFieldType.STRING)) |
---|
| 279 | .addToFields(new TemplateField(name: 'Time zone',type: TemplateFieldType.STRING)) |
---|
| 280 | .addToFields(new TemplateField(name: 'Responsible scientist',type: TemplateFieldType.STRING)) |
---|
[366] | 281 | .addToFields(new TemplateField(name: 'Lab id',type: TemplateFieldType.STRING)) |
---|
[331] | 282 | .addToFields(new TemplateField(name: 'Institute',type: TemplateFieldType.STRING)) |
---|
[269] | 283 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
[232] | 284 | |
---|
[92] | 285 | // Mouse template |
---|
[364] | 286 | println ".adding mouse subject template..." |
---|
[92] | 287 | def mouseTemplate = new Template( |
---|
[269] | 288 | name: 'Mouse', entity: dbnp.studycapturing.Subject) |
---|
| 289 | .addToFields(new TemplateField( |
---|
| 290 | name: 'Strain', type: TemplateFieldType.ONTOLOGYTERM)) |
---|
[339] | 291 | .addToFields(genotypeField) |
---|
| 292 | .addToFields(genotypeTypeField) |
---|
[224] | 293 | .addToFields(genderField) |
---|
| 294 | .addToFields(new TemplateField( |
---|
[269] | 295 | name: 'Age (weeks)', type: TemplateFieldType.INTEGER, unit: 'weeks')) |
---|
[224] | 296 | .addToFields(new TemplateField( |
---|
[269] | 297 | name: 'Age type',type: TemplateFieldType.STRINGLIST, |
---|
| 298 | listEntries: [new TemplateFieldListItem(name:'postnatal'),new TemplateFieldListItem(name:'embryonal')])) |
---|
[224] | 299 | .addToFields(new TemplateField( |
---|
[269] | 300 | name: 'Cage',type: TemplateFieldType.STRING)) |
---|
| 301 | .addToFields(new TemplateField( |
---|
| 302 | name: '#Mice in cage',type: TemplateFieldType.INTEGER)) |
---|
| 303 | .addToFields(new TemplateField( |
---|
[290] | 304 | name: 'Litter size',type: TemplateFieldType.INTEGER)) |
---|
[269] | 305 | .addToFields(new TemplateField( |
---|
| 306 | name: 'Weight (g)', type: TemplateFieldType.DOUBLE, unit: 'gram')) |
---|
[139] | 307 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
[97] | 308 | |
---|
[186] | 309 | // Human template |
---|
[364] | 310 | println ".adding human subject template..." |
---|
[186] | 311 | def humanTemplate = new Template( |
---|
[224] | 312 | name: 'Human', entity: dbnp.studycapturing.Subject) |
---|
| 313 | .addToFields(genderField) |
---|
| 314 | .addToFields(ageField) |
---|
| 315 | .addToFields(new TemplateField( |
---|
[212] | 316 | name: 'DOB',type: TemplateFieldType.DATE)) |
---|
[224] | 317 | .addToFields(new TemplateField( |
---|
[269] | 318 | name: 'Height',type: TemplateFieldType.DOUBLE, unit: 'm')) |
---|
[224] | 319 | .addToFields(new TemplateField( |
---|
[269] | 320 | name: 'Weight (kg)',type: TemplateFieldType.DOUBLE, unit: 'kg')) |
---|
[224] | 321 | .addToFields(new TemplateField( |
---|
[269] | 322 | name: 'BMI',type: TemplateFieldType.DOUBLE, unit: 'kg/m2')) |
---|
| 323 | .addToFields(new TemplateField( |
---|
| 324 | name: 'Race',type: TemplateFieldType.STRING)) |
---|
| 325 | .addToFields(new TemplateField( |
---|
[339] | 326 | name: 'Waist circumference',type: TemplateFieldType.FLOAT, unit: 'cm')) |
---|
[269] | 327 | .addToFields(new TemplateField( |
---|
[339] | 328 | name: 'Hip circumference',type: TemplateFieldType.FLOAT, unit: 'cm')) |
---|
[269] | 329 | .addToFields(new TemplateField( |
---|
| 330 | name: 'Systolic blood pressure',type: TemplateFieldType.FLOAT, unit: 'mmHg')) |
---|
| 331 | .addToFields(new TemplateField( |
---|
| 332 | name: 'Diastolic blood pressure',type: TemplateFieldType.FLOAT, unit: 'mmHg')) |
---|
| 333 | .addToFields(new TemplateField( |
---|
| 334 | name: 'Heart rate',type: TemplateFieldType.FLOAT, unit: 'beats/min')) |
---|
| 335 | .addToFields(new TemplateField( |
---|
| 336 | name: 'Run-in-food',type: TemplateFieldType.TEXT)) |
---|
[186] | 337 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
[139] | 338 | |
---|
[269] | 339 | |
---|
[339] | 340 | def sampleDescriptionField = new TemplateField( |
---|
| 341 | name: 'Description',type: TemplateFieldType.TEXT) |
---|
| 342 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 343 | def sampleTypeField = new TemplateField( |
---|
| 344 | name: 'SampleType',type: TemplateFieldType.STRING) |
---|
| 345 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 346 | def sampleProtocolField = new TemplateField( |
---|
| 347 | name: 'SampleProtocol',type: TemplateFieldType.STRING) |
---|
| 348 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 349 | def sampleVialTextField = new TemplateField( |
---|
| 350 | name: 'Text on vial',type: TemplateFieldType.STRING) |
---|
| 351 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 352 | |
---|
[269] | 353 | // Human sample template |
---|
[375] | 354 | println ".adding human sample template..." |
---|
[269] | 355 | def humanSampleTemplate = new Template( |
---|
| 356 | name: 'Human tissue sample', entity: dbnp.studycapturing.Sample) |
---|
[339] | 357 | .addToFields(sampleDescriptionField) |
---|
| 358 | .addToFields(sampleTypeField) |
---|
| 359 | .addToFields(sampleProtocolField) |
---|
| 360 | .addToFields(sampleVialTextField) |
---|
| 361 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 362 | |
---|
| 363 | //Plant template |
---|
[375] | 364 | println ".adding plant template..." |
---|
[339] | 365 | def plantTemplate = new Template( |
---|
| 366 | name: 'Plant template', entity: dbnp.studycapturing.Subject) |
---|
[269] | 367 | .addToFields(new TemplateField( |
---|
[339] | 368 | name: 'Variety', type: TemplateFieldType.STRING)) |
---|
[269] | 369 | .addToFields(new TemplateField( |
---|
[339] | 370 | name: 'Ecotype', type: TemplateFieldType.STRING)) |
---|
| 371 | .addToFields(genotypeField) |
---|
| 372 | .addToFields(genotypeTypeField) |
---|
[269] | 373 | .addToFields(new TemplateField( |
---|
[339] | 374 | name: 'Growth location', type: TemplateFieldType.STRINGLIST, |
---|
| 375 | listEntries: [new TemplateFieldListItem(name:'Greenhouse'),new TemplateFieldListItem(name: 'Field')])) |
---|
[269] | 376 | .addToFields(new TemplateField( |
---|
[339] | 377 | name: 'Room', type: TemplateFieldType.STRING, |
---|
| 378 | comment: 'Chamber number in case of Greenhouse')) |
---|
| 379 | .addToFields(new TemplateField( |
---|
| 380 | name: 'Position X', type: TemplateFieldType.FLOAT)) |
---|
| 381 | .addToFields(new TemplateField( |
---|
| 382 | name: 'Position Y', type: TemplateFieldType.FLOAT)) |
---|
| 383 | .addToFields(new TemplateField( |
---|
| 384 | name: 'Block', type: TemplateFieldType.STRING)) |
---|
| 385 | .addToFields(new TemplateField( |
---|
| 386 | name: 'Temperature at day', type: TemplateFieldType.FLOAT)) |
---|
| 387 | .addToFields(new TemplateField( |
---|
| 388 | name: 'Temperature at night', type: TemplateFieldType.FLOAT)) |
---|
| 389 | .addToFields(new TemplateField( |
---|
| 390 | name: 'Photo period', type: TemplateFieldType.STRING)) |
---|
| 391 | .addToFields(new TemplateField( |
---|
| 392 | name: 'Light intensity', type: TemplateFieldType.STRING)) |
---|
| 393 | .addToFields(new TemplateField( |
---|
| 394 | name: 'Start date', type: TemplateFieldType.DATE)) |
---|
| 395 | .addToFields(new TemplateField( |
---|
| 396 | name: 'Harvest date', type: TemplateFieldType.DATE)) |
---|
| 397 | .addToFields(new TemplateField( |
---|
| 398 | name: 'Growth type', type: TemplateFieldType.STRINGLIST, |
---|
| 399 | listEntries: [new TemplateFieldListItem(name:'Standard'),new TemplateFieldListItem(name: 'Experimental')])) |
---|
| 400 | .addToFields(new TemplateField( |
---|
| 401 | name: 'Growth protocol', type: TemplateFieldType.TEXT)) |
---|
| 402 | .addToFields(new TemplateField( |
---|
| 403 | name: 'Harvest delay', type: TemplateFieldType.TEXT)) |
---|
[269] | 404 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 405 | |
---|
[375] | 406 | println ".adding plant sample template..." |
---|
[339] | 407 | def plantSampleTemplate = new Template( |
---|
| 408 | name: 'Plant sample', entity: dbnp.studycapturing.Sample) |
---|
| 409 | .addToFields(sampleDescriptionField) |
---|
| 410 | .addToFields(sampleTypeField) |
---|
| 411 | .addToFields(sampleProtocolField) |
---|
| 412 | .addToFields(sampleVialTextField) |
---|
| 413 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 414 | |
---|
| 415 | |
---|
[375] | 416 | // Event templates |
---|
| 417 | println ".adding event templates..." |
---|
[370] | 418 | def dietTreatmentTemplate = new Template( |
---|
[383] | 419 | name: 'Diet treatment', entity: dbnp.studycapturing.Event) |
---|
[370] | 420 | .addToFields(sampleDescriptionField) |
---|
| 421 | .addToFields(new TemplateField( |
---|
[375] | 422 | name: 'Diet', type: TemplateFieldType.STRINGLIST, |
---|
| 423 | listEntries: [new TemplateFieldListItem(name:'10% fat (palm oil)'),new TemplateFieldListItem(name: '45% fat (palm oil)')])) |
---|
[370] | 424 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 425 | |
---|
| 426 | def boostTreatmentTemplate = new Template( |
---|
[383] | 427 | name: 'Boost treatment', entity: dbnp.studycapturing.Event) |
---|
[370] | 428 | .addToFields(sampleDescriptionField) |
---|
| 429 | .addToFields(new TemplateField( |
---|
[375] | 430 | name: 'Compound', type: TemplateFieldType.STRING, |
---|
| 431 | listEntries: [new TemplateFieldListItem(name:'Vehicle'),new TemplateFieldListItem(name: 'Leptin')])) |
---|
[370] | 432 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 433 | |
---|
| 434 | /* |
---|
[139] | 435 | //events |
---|
[232] | 436 | def eventDiet = new EventDescription( |
---|
| 437 | name: 'Diet treatment', |
---|
| 438 | description: 'Diet treatment (fat percentage)', |
---|
[139] | 439 | classification: treatmentTerm, |
---|
[232] | 440 | protocol: dietProtocol, |
---|
[186] | 441 | isSamplingEvent: false |
---|
[139] | 442 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 443 | |
---|
[232] | 444 | def eventBoost = new EventDescription( |
---|
| 445 | name: 'Boost treatment', |
---|
| 446 | description: 'Boost treatment (leptin or vehicle)', |
---|
| 447 | classification: treatmentTerm, |
---|
| 448 | protocol: boostProtocol, |
---|
| 449 | isSamplingEvent: false |
---|
| 450 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 451 | |
---|
[186] | 452 | def samplingEvent = new EventDescription( |
---|
| 453 | name: 'Liver extraction', |
---|
| 454 | description: 'Liver sampling for transcriptomics arrays', |
---|
| 455 | protocol: liverSamplingProtocol, |
---|
| 456 | isSamplingEvent: true |
---|
| 457 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 458 | |
---|
[232] | 459 | def bloodSamplingEventDescription = new EventDescription( |
---|
[186] | 460 | name: 'Blood extraction', |
---|
| 461 | description: 'Blood extraction targeted at lipid assays', |
---|
| 462 | protocol: bloodSamplingProtocol, |
---|
| 463 | isSamplingEvent: true |
---|
| 464 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 465 | |
---|
| 466 | |
---|
[253] | 467 | def fastingTreatment = new EventDescription( |
---|
[212] | 468 | name: 'Fasting treatment', |
---|
| 469 | description: 'Fasting Protocol NuGO PPSH', |
---|
| 470 | protocol: fastingProtocol, |
---|
[186] | 471 | isSamplingEvent: false |
---|
[165] | 472 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
[149] | 473 | |
---|
[186] | 474 | println('Adding PPS3 study...') |
---|
[370] | 475 | */ |
---|
[97] | 476 | // studies |
---|
[375] | 477 | println ".adding NuGO PPS3 leptin example study..." |
---|
[136] | 478 | def exampleStudy = new Study( |
---|
[232] | 479 | template: studyTemplate, |
---|
[136] | 480 | title:"NuGO PPS3 mouse study leptin module", |
---|
| 481 | code:"PPS3_leptin_module", |
---|
| 482 | researchQuestion:"Leptin etc.", |
---|
| 483 | ecCode:"2007117.c", |
---|
[230] | 484 | startDate: Date.parse('yyyy-MM-dd','2007-12-11') |
---|
[370] | 485 | ) |
---|
| 486 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
[139] | 487 | |
---|
[375] | 488 | exampleStudy.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." ) |
---|
| 489 | exampleStudy.save() |
---|
| 490 | |
---|
| 491 | println ".adding NuGO PPSH example study..." |
---|
[329] | 492 | def exampleHumanStudy = new Study( |
---|
[375] | 493 | template: studyTemplate, |
---|
[329] | 494 | title:"Human example template", |
---|
| 495 | code:"Human example code", |
---|
| 496 | researchQuestion:"Leptin etc.", |
---|
| 497 | ecCode:"2007117.c", |
---|
| 498 | startDate: Date.parse('yyyy-MM-dd','2007-12-11') |
---|
[370] | 499 | ) |
---|
| 500 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
[329] | 501 | |
---|
[375] | 502 | exampleHumanStudy.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." ) |
---|
| 503 | exampleHumanStudy.save() |
---|
| 504 | |
---|
[367] | 505 | def evLF = new Event( |
---|
[232] | 506 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
| 507 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
[370] | 508 | template: dietTreatmentTemplate |
---|
| 509 | ) |
---|
| 510 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
[375] | 511 | evLF.setFieldValue( 'Diet','10% fat (palm oil)' ) |
---|
| 512 | evLF.save(flush:true) |
---|
| 513 | // TODO: find out why Diet is not set and Compound is |
---|
[232] | 514 | |
---|
| 515 | def evHF = new Event( |
---|
| 516 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
| 517 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
[370] | 518 | template: dietTreatmentTemplate |
---|
| 519 | ) |
---|
| 520 | .setFieldValue( 'Diet','45% fat (palm oil)' ) |
---|
| 521 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
[232] | 522 | |
---|
| 523 | def evBV = new Event( |
---|
| 524 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
| 525 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
[370] | 526 | template: boostTreatmentTemplate |
---|
| 527 | ) |
---|
| 528 | .setFieldValue( 'Compound','Vehicle' ) |
---|
| 529 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
[232] | 530 | |
---|
| 531 | def evBL = new Event( |
---|
| 532 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
| 533 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
[370] | 534 | template: boostTreatmentTemplate |
---|
| 535 | ) |
---|
| 536 | .setFieldValue( 'Compound','Leptin' ) |
---|
| 537 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
[232] | 538 | |
---|
[370] | 539 | /* |
---|
[232] | 540 | def evLF4 = new Event( |
---|
| 541 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
| 542 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
| 543 | eventDescription: eventDiet, |
---|
| 544 | parameterStringValues: ['Diet':'10% fat (palm oil)'] |
---|
| 545 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 546 | |
---|
| 547 | def evHF4 = new Event( |
---|
| 548 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
| 549 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
| 550 | eventDescription: eventDiet, |
---|
| 551 | parameterStringValues: ['Diet':'45% fat (palm oil)'] |
---|
| 552 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 553 | |
---|
| 554 | def evBV4 = new Event( |
---|
| 555 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
| 556 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
| 557 | eventDescription: eventBoost, |
---|
| 558 | parameterStringValues: ['Compound':'Vehicle'] |
---|
| 559 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 560 | |
---|
| 561 | def evBL4 = new Event( |
---|
| 562 | startTime: Date.parse('yyyy-MM-dd','2008-01-07'), |
---|
| 563 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
| 564 | eventDescription: eventBoost, |
---|
| 565 | parameterStringValues: ['Compound':'Leptin'] |
---|
| 566 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 567 | |
---|
| 568 | def evS = new SamplingEvent( |
---|
| 569 | startTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
| 570 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
| 571 | eventDescription: samplingEvent, |
---|
| 572 | parameterFloatValues: ['Sample weight':5F] |
---|
| 573 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 574 | |
---|
| 575 | def evS4 = new SamplingEvent( |
---|
| 576 | startTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
| 577 | endTime: Date.parse('yyyy-MM-dd','2008-02-04'), |
---|
| 578 | eventDescription: samplingEvent, |
---|
| 579 | parameterFloatValues: ['Sample weight':5F] |
---|
| 580 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
[370] | 581 | */ |
---|
[232] | 582 | |
---|
| 583 | // Add events to study |
---|
| 584 | exampleStudy |
---|
| 585 | .addToEvents(evLF) |
---|
| 586 | .addToEvents(evHF) |
---|
| 587 | .addToEvents(evBV) |
---|
| 588 | .addToEvents(evBL) |
---|
[370] | 589 | /* |
---|
| 590 | .addToEvents(evLF4) |
---|
[232] | 591 | .addToEvents(evHF4) |
---|
| 592 | .addToEvents(evBV4) |
---|
| 593 | .addToEvents(evBL4) |
---|
| 594 | .addToSamplingEvents(evS) |
---|
| 595 | .addToSamplingEvents(evS4) |
---|
[370] | 596 | */ |
---|
[232] | 597 | .save() |
---|
| 598 | |
---|
| 599 | def LFBV1 = new EventGroup(name:"10% fat + vehicle for 1 week") |
---|
| 600 | .addToEvents(evLF) |
---|
| 601 | .addToEvents(evBV) |
---|
| 602 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 603 | |
---|
| 604 | def LFBL1 = new EventGroup(name:"10% fat + leptin for 1 week") |
---|
| 605 | .addToEvents(evLF) |
---|
| 606 | .addToEvents(evBL) |
---|
| 607 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 608 | |
---|
| 609 | def HFBV1 = new EventGroup(name:"45% fat + vehicle for 1 week") |
---|
| 610 | .addToEvents(evHF) |
---|
| 611 | .addToEvents(evBV) |
---|
| 612 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 613 | |
---|
| 614 | def HFBL1 = new EventGroup(name:"45% fat + leptin for 1 week") |
---|
| 615 | .addToEvents(evHF) |
---|
| 616 | .addToEvents(evBL) |
---|
| 617 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 618 | |
---|
[370] | 619 | /* |
---|
[232] | 620 | def LFBV4 = new EventGroup(name:"10% fat + vehicle for 4 weeks") |
---|
| 621 | .addToEvents(evLF4) |
---|
| 622 | .addToEvents(evBV4) |
---|
| 623 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 624 | |
---|
| 625 | def LFBL4 = new EventGroup(name:"10% fat + leptin for 4 weeks") |
---|
| 626 | .addToEvents(evLF4) |
---|
| 627 | .addToEvents(evBL4) |
---|
| 628 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 629 | |
---|
| 630 | def HFBV4 = new EventGroup(name:"45% fat + vehicle for 4 weeks") |
---|
| 631 | .addToEvents(evHF4) |
---|
| 632 | .addToEvents(evBV4) |
---|
| 633 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 634 | |
---|
| 635 | def HFBL4 = new EventGroup(name:"45% fat + leptin for 4 weeks") |
---|
| 636 | .addToEvents(evHF4) |
---|
| 637 | .addToEvents(evBL4) |
---|
| 638 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
[370] | 639 | */ |
---|
[232] | 640 | |
---|
[253] | 641 | // Add subjects and samples and compose EventGroups |
---|
[232] | 642 | |
---|
[136] | 643 | def x=1 |
---|
[370] | 644 | 40.times { |
---|
[139] | 645 | def currentSubject = new Subject( |
---|
[136] | 646 | name: "A" + x++, |
---|
| 647 | species: mouseTerm, |
---|
[146] | 648 | template: mouseTemplate, |
---|
[239] | 649 | ) |
---|
| 650 | .setFieldValue("Gender", "Male") |
---|
[370] | 651 | //.setFieldValue("Genotype", c57bl6Term) |
---|
[269] | 652 | .setFieldValue("Age (weeks)", 17) |
---|
| 653 | .setFieldValue("Cage", "" + (int)(x/2)) |
---|
[375] | 654 | .with { if (!validate()) { errors.each { println it} } else save(flush:true)} |
---|
[136] | 655 | |
---|
[139] | 656 | exampleStudy.addToSubjects(currentSubject) |
---|
[186] | 657 | .with { if (!validate()) { errors.each { println it} } else save()} |
---|
[232] | 658 | |
---|
| 659 | // Add subject to appropriate EventGroup |
---|
[370] | 660 | /* |
---|
| 661 | if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } |
---|
[232] | 662 | else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } |
---|
| 663 | else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() } |
---|
| 664 | else if (x > 40) { LFBV4.addToSubjects(currentSubject).save() } |
---|
| 665 | else if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } |
---|
| 666 | else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } |
---|
| 667 | else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } |
---|
| 668 | else { LFBV1.addToSubjects(currentSubject).save() } |
---|
[370] | 669 | */ |
---|
[232] | 670 | |
---|
[370] | 671 | if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } |
---|
| 672 | else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } |
---|
| 673 | else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } |
---|
| 674 | else { LFBV1.addToSubjects(currentSubject).save() } |
---|
[139] | 675 | |
---|
[370] | 676 | } |
---|
| 677 | |
---|
[236] | 678 | // Add EventGroups to study |
---|
| 679 | exampleStudy |
---|
| 680 | .addToEventGroups(LFBV1) |
---|
| 681 | .addToEventGroups(LFBL1) |
---|
| 682 | .addToEventGroups(HFBV1) |
---|
| 683 | .addToEventGroups(HFBL1) |
---|
[370] | 684 | //.addToEventGroups(LFBV4) |
---|
| 685 | //.addToEventGroups(LFBL4) |
---|
| 686 | //.addToEventGroups(HFBV4) |
---|
| 687 | //.addToEventGroups(HFBL4) |
---|
[236] | 688 | |
---|
[370] | 689 | // Add persons to study |
---|
| 690 | def studyperson1 = new StudyPerson( person: person1, role: role1 ).save(); |
---|
| 691 | def studyperson2 = new StudyPerson( person: person2, role: role2 ).save(); |
---|
[211] | 692 | |
---|
[370] | 693 | exampleStudy |
---|
| 694 | .addToPersons( studyperson1 ) |
---|
| 695 | .addToPersons( studyperson2 ) |
---|
| 696 | .save() |
---|
[382] | 697 | |
---|
[370] | 698 | /* |
---|
| 699 | println 'Adding PPSH study' |
---|
| 700 | |
---|
[224] | 701 | def humanStudy = new Study( |
---|
[232] | 702 | template: studyTemplate, |
---|
[186] | 703 | title:"NuGO PPS human study", |
---|
| 704 | code:"PPSH", |
---|
[212] | 705 | researchQuestion:"How much are fasting plasma and urine metabolite levels affected by prolonged fasting ?", |
---|
[186] | 706 | description:"Human study", |
---|
| 707 | ecCode:"unknown", |
---|
[230] | 708 | startDate: Date.parse('yyyy-MM-dd','2009-01-01') |
---|
[148] | 709 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 710 | |
---|
[232] | 711 | def fastingEvent = new Event( |
---|
| 712 | startTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
| 713 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
| 714 | eventDescription: fastingTreatment, |
---|
| 715 | parameterStringValues: ['Fasting period':'8h']); |
---|
| 716 | |
---|
| 717 | def bloodSamplingEvent = new SamplingEvent( |
---|
| 718 | startTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
| 719 | endTime: Date.parse('yyyy-MM-dd','2008-01-14'), |
---|
| 720 | eventDescription: bloodSamplingEventDescription, |
---|
| 721 | parameterFloatValues: ['Sample volume':4.5F]); |
---|
| 722 | |
---|
| 723 | def rootGroup = new EventGroup(name: 'Root group'); |
---|
| 724 | rootGroup.addToEvents fastingEvent |
---|
| 725 | rootGroup.addToEvents bloodSamplingEvent |
---|
| 726 | rootGroup.save() |
---|
| 727 | |
---|
[253] | 728 | def y = 1 |
---|
| 729 | 11.times { |
---|
| 730 | def currentSubject = new Subject( |
---|
| 731 | name: "" + y++, |
---|
| 732 | species: humanTerm, |
---|
[269] | 733 | template: humanTemplate).setFieldValue("Gender", (boolean) (x / 2) ? "Male" : "Female").setFieldValue("DOB", new java.text.SimpleDateFormat("dd-mm-yy").parse("01-02-19" + (10 + (int) (Math.random() * 80)))).setFieldValue("Age (years)", 30).setFieldValue("Height", Math.random() * 2F).setFieldValue("Weight (kg)", Math.random() * 150F).setFieldValue("BMI", 20 + Math.random() * 10F).with { if (!validate()) { errors.each { println it} } else save()} |
---|
[148] | 734 | |
---|
[253] | 735 | rootGroup.addToSubjects currentSubject |
---|
| 736 | rootGroup.save() |
---|
[232] | 737 | |
---|
[253] | 738 | def currentSample = new Sample( |
---|
| 739 | name: currentSubject.name + '_B', |
---|
| 740 | material: bloodTerm, |
---|
| 741 | parentSubject: currentSubject, |
---|
| 742 | parentEvent: bloodSamplingEvent); |
---|
[232] | 743 | |
---|
[148] | 744 | |
---|
[253] | 745 | humanStudy.addToSubjects(currentSubject).addToSamples(currentSample).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 746 | } |
---|
[236] | 747 | |
---|
[290] | 748 | humanStudy.addToEvents(fastingEvent) |
---|
| 749 | humanStudy.addToSamplingEvents(bloodSamplingEvent) |
---|
| 750 | humanStudy.addToEventGroups rootGroup |
---|
[253] | 751 | humanStudy.save() |
---|
[186] | 752 | |
---|
| 753 | // Add clinical data |
---|
| 754 | |
---|
| 755 | def lipidAssay = new dbnp.clinicaldata.ClinicalAssay( |
---|
| 756 | name: 'Lipid profile', |
---|
| 757 | approved: true |
---|
| 758 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 759 | |
---|
| 760 | def ldlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( |
---|
| 761 | name: 'LDL', |
---|
| 762 | unit: 'mg/dL', |
---|
[187] | 763 | type: dbnp.data.FeatureType.QUANTITATIVE, |
---|
[186] | 764 | referenceValues: '100 mg/dL', |
---|
| 765 | detectableLimit: 250, |
---|
| 766 | isDrug: false, isIntake: true, inSerum: true |
---|
| 767 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 768 | |
---|
| 769 | def hdlMeasurement = new dbnp.clinicaldata.ClinicalMeasurement( |
---|
| 770 | name: 'HDL', |
---|
| 771 | unit: 'mg/dL', |
---|
[187] | 772 | type: dbnp.data.FeatureType.QUANTITATIVE, |
---|
[186] | 773 | referenceValues: '50 mg/dL', |
---|
| 774 | detectableLimit: 100, |
---|
| 775 | isDrug: false, isIntake: true, inSerum: true |
---|
| 776 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 777 | |
---|
| 778 | lipidAssay.addToMeasurements ldlMeasurement |
---|
| 779 | lipidAssay.addToMeasurements hdlMeasurement |
---|
| 780 | |
---|
| 781 | def lipidAssayInstance = new dbnp.clinicaldata.ClinicalAssayInstance( |
---|
| 782 | assay: lipidAssay |
---|
| 783 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 784 | |
---|
[224] | 785 | humanStudy.samples*.each { |
---|
[186] | 786 | new dbnp.clinicaldata.ClinicalFloatData( |
---|
| 787 | assay: lipidAssayInstance, |
---|
| 788 | measurement: ldlMeasurement, |
---|
| 789 | sample: it.name, |
---|
| 790 | value: Math.round(Math.random()*ldlMeasurement.detectableLimit) |
---|
| 791 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 792 | |
---|
| 793 | new dbnp.clinicaldata.ClinicalFloatData( |
---|
| 794 | assay: lipidAssayInstance, |
---|
| 795 | measurement: hdlMeasurement, |
---|
| 796 | sample: it.name, |
---|
| 797 | value: Math.round(Math.random()*hdlMeasurement.detectableLimit) |
---|
| 798 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 799 | } |
---|
| 800 | |
---|
| 801 | // Add assay to study capture module |
---|
| 802 | |
---|
| 803 | def clinicalModule = new AssayModule( |
---|
| 804 | name: 'Clinical data', |
---|
| 805 | type: AssayType.CLINICAL_DATA, |
---|
| 806 | platform: 'clinical measurements', |
---|
| 807 | url: 'http://localhost:8080/gscf' |
---|
| 808 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 809 | |
---|
| 810 | def lipidAssayRef = new Assay( |
---|
| 811 | name: 'Lipid profiling', |
---|
| 812 | module: clinicalModule, |
---|
| 813 | externalAssayId: lipidAssayInstance.id |
---|
| 814 | ).with { if (!validate()) { errors.each { println it} } else save()} |
---|
| 815 | |
---|
[224] | 816 | humanStudy.samples*.each { |
---|
[186] | 817 | lipidAssayRef.addToSamples(it) |
---|
| 818 | } |
---|
| 819 | lipidAssayRef.save() |
---|
| 820 | |
---|
[188] | 821 | humanStudy.addToAssays(lipidAssayRef); |
---|
| 822 | humanStudy.save() |
---|
[346] | 823 | */ |
---|
[186] | 824 | } |
---|
[92] | 825 | } |
---|
| 826 | |
---|
| 827 | def destroy = { |
---|
| 828 | } |
---|
[366] | 829 | } |
---|