- Timestamp:
- Mar 4, 2011, 12:30:52 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/dbnp/configuration/ExampleStudies.groovy
r1581 r1588 55 55 ontology : speciesOntology, 56 56 accession : '10090' 57 ). with { if (!validate()) { errors.each { println it} } else save()}57 ).save(failOnError:true) 58 58 59 59 def humanTerm = new Term( … … 61 61 ontology : speciesOntology, 62 62 accession : '9606' 63 ). with { if (!validate()) { errors.each { println it} } else save()}63 ).save(failOnError:true) 64 64 65 65 def arabTerm = new Term( … … 67 67 ontology : speciesOntology, 68 68 accession : '3702' 69 ).with { if (!validate()) { errors.each { println it} } else save()} 69 ).save(failOnError:true) 70 70 71 71 def tomatoTerm = new Term( … … 73 73 ontology : speciesOntology, 74 74 accession : '4081' 75 ).with { if (!validate()) { errors.each { println it} } else save()} 75 ).save(failOnError:true) 76 76 77 77 def potatoTerm = new Term( … … 79 79 ontology : speciesOntology, 80 80 accession : '0000' 81 ).with { if (!validate()) { errors.each { println it} } else save()} 81 ).save(failOnError:true) 82 82 83 83 def bloodTerm = new Term( … … 85 85 ontology : brendaOntology, 86 86 accession : 'BTO:0000131' 87 ).with { if (!validate()) { errors.each { println it} } else save()} 87 ).save(failOnError:true) 88 88 89 89 def c57bl6Term = new Term( … … 91 91 ontology : nciOntology, 92 92 accession : 'C14424' 93 ).with { if (!validate()) { errors.each { println it} } else save()} 93 ).save(failOnError:true) 94 94 95 95 def glucoseTerm = new Term( … … 97 97 ontology : chebiOntology, 98 98 accession : 'CHEBI:17234' 99 ).with { if (!validate()) { errors.each { println it} } else save()} 99 ).save(failOnError:true) 100 100 101 101 // Create a few persons, roles and Affiliations … … 103 103 institute : "Science Institute NYC", 104 104 department : "Department of Mathematics" 105 ).save(); 105 ).save(failOnError:true) 106 106 107 def affiliation2 = new PersonAffiliation( 107 108 institute : "InfoStats GmbH, Hamburg", 108 109 department : "Life Sciences" 109 ).save(); 110 ).save(failOnError:true) 111 110 112 def role1 = new PersonRole( 111 113 name : "Principal Investigator" 112 ).save(); 114 ).save(failOnError:true) 115 113 116 def role2 = new PersonRole( 114 117 name : "Statician" 115 ).save(); 118 ).save(failOnError:true) 116 119 117 120 // Create persons … … 124 127 phone : "1-555-3049", 125 128 address : "First street 2,NYC" 126 ).addToAffiliations(affiliation1).addToAffiliations(affiliation2).save( );129 ).addToAffiliations(affiliation1).addToAffiliations(affiliation2).save(failOnError:true) 127 130 128 131 def person2 = new Person( … … 134 137 phone : "49-555-8291", 135 138 address : "Dritten strasse 38, Hamburg, Germany" 136 ).addToAffiliations(affiliation2).save( );139 ).addToAffiliations(affiliation2).save(failOnError:true) 137 140 138 141 // Create 30 persons to test pagination 139 def personCounter = 1 ;142 def personCounter = 1 140 143 30.times { 141 144 new Person( … … 143 146 lastName : "Testperson", 144 147 email : "email${personCounter++}@testdomain.com" 145 ).save( )148 ).save(failOnError:true) 146 149 } 147 150 … … 153 156 comments : "Not published yet", 154 157 DOI : "unknown" 155 ).save( );158 ).save(failOnError:true) 156 159 157 160 def publication2 = new Publication( … … 161 164 comments : "", 162 165 DOI : "" 163 ).save( );166 ).save(failOnError:true) 164 167 165 168 // Add example mouse study … … 174 177 owner : owner, 175 178 readers : [otherUser] 176 ).with { if (!validate()) { errors.each { println it} } else save()} 179 ).save(failOnError:true) 177 180 178 181 def evLF = new Event( … … 235 238 236 239 // Add events to study 237 mouseStudy.addToEvents(evLF).addToEvents(evHF).addToEvents(evBV).addToEvents(evBL).addToEvents(evLF4).addToEvents(evHF4).addToEvents(evBV4).addToEvents(evBL4).addToSamplingEvents(evS).addToSamplingEvents(evS4). with { if (!validate()) { errors.each { println it} } else save()}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) 238 241 239 242 // Extra check if the SamplingEvents are saved correctly 240 evS. with { if (!validate()) { errors.each { println it} } else save()}241 evS4. with { if (!validate()) { errors.each { println it} } else save()}243 evS.save(failOnError:true) 244 evS4.save(failOnError:true) 242 245 243 246 def LFBV1 = new EventGroup(name: "10% fat + vehicle for 1 week").addToEvents(evLF).addToEvents(evBV).addToSamplingEvents(evS) … … 269 272 // (this is possibly a Grails or Hibernate bug) 270 273 mouseStudy.addToSubjects(currentSubject) 271 currentSubject.with { if (!validate()) { errors.each { println it} } else save()} 274 275 currentSubject.save(failOnError:true) 272 276 273 277 // Add subject to appropriate EventGroup 274 if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } 275 else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } 276 else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() } 277 else if (x > 40) { LFBV4.addToSubjects(currentSubject).save() } 278 else if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } 279 else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } 280 else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } 281 else { LFBV1.addToSubjects(currentSubject).save() } 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 } 287 288 tmpEventGroup.addToSubjects(currentSubject) 282 289 283 290 // Create sample … … 288 295 parentSubject: currentSubject, 289 296 parentEvent: evS //x > 40 ? evS4 : evS 290 ); 297 ) 298 291 299 mouseStudy.addToSamples(currentSample) 292 currentSample.with { if (!validate()) { errors.each { println it} } else save()} 293 currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L))294 300 currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L)) 301 currentSample.save(failOnError:true) 302 } 295 303 296 304 // Add EventGroups to study 297 mouseStudy.addToEventGroups(LFBV1).addToEventGroups(LFBL1).addToEventGroups(HFBV1).addToEventGroups(HFBL1).addToEventGroups(LFBV4).addToEventGroups(LFBL4).addToEventGroups(HFBV4).addToEventGroups(HFBL4). with { if (!validate()) { errors.each { println it} } else save()}305 mouseStudy.addToEventGroups(LFBV1).addToEventGroups(LFBL1).addToEventGroups(HFBV1).addToEventGroups(HFBL1).addToEventGroups(LFBV4).addToEventGroups(LFBL4).addToEventGroups(HFBV4).addToEventGroups(HFBL4).save(failOnError:true) 298 306 299 307 // Add persons and publications to study … … 301 309 def studyperson2 = new StudyPerson(person: person2, role: role2) 302 310 303 mouseStudy.addToPersons(studyperson1).addToPersons(studyperson2).addToPublications(publication1).addToPublications(publication2). with { if (!validate()) { errors.each { println it} } else save()}311 mouseStudy.addToPersons(studyperson1).addToPersons(studyperson2).addToPublications(publication1).addToPublications(publication2).save(failOnError:true) 304 312 305 313 def humanStudy = new Study( … … 311 319 ecCode : "unknown", 312 320 startDate : Date.parse('yyyy-MM-dd', '2008-01-14'), 313 owner : owner, 314 writers : [otherUser] 315 ).with { if (!validate()) { errors.each { println it} } else save()} 316 317 def rootGroup = new EventGroup(name: 'Root group'); 321 owner : owner 322 ).addToWriters(otherUser).save(failOnError:true) 323 324 def rootGroup = new EventGroup(name: 'Root group') 318 325 319 326 def fastingEvent = new Event( 320 327 startTime : 3 * 24 * 3600 + 22 * 3600, 321 328 endTime : 3 * 24 * 3600 + 30 * 3600, 322 template : fastingTreatmentTemplate).setFieldValue('Fasting period', '8h') ;329 template : fastingTreatmentTemplate).setFieldValue('Fasting period', '8h') 323 330 324 331 def bloodSamplingEventBefore = new SamplingEvent( 325 332 startTime : 0, 326 333 template : bloodSamplingEventTemplate, 327 sampleTemplate : humanBloodSampleTemplate).setFieldValue('Sample volume', 4.5F) ;334 sampleTemplate : humanBloodSampleTemplate).setFieldValue('Sample volume', 4.5F) 328 335 329 336 def bloodSamplingEventAfter = new SamplingEvent( 330 337 startTime : 3 * 24 * 3600 + 30 * 3600, 331 338 template : bloodSamplingEventTemplate, 332 sampleTemplate : humanBloodSampleTemplate).setFieldValue('Sample volume', 4.5F) ;339 sampleTemplate : humanBloodSampleTemplate).setFieldValue('Sample volume', 4.5F) 333 340 334 341 rootGroup.addToEvents fastingEvent 335 342 rootGroup.addToSamplingEvents bloodSamplingEventBefore 336 343 rootGroup.addToSamplingEvents bloodSamplingEventAfter 337 rootGroup.save()338 344 339 345 humanStudy.addToEvents(fastingEvent) … … 342 348 humanStudy.addToEventGroups rootGroup 343 349 344 humanStudy.save( )350 humanStudy.save(failOnError:true) 345 351 346 352 def y = 1 … … 354 360 355 361 humanStudy.addToSubjects(currentSubject) 356 currentSubject. with { if (!validate()) { errors.each { println it} } else save()}362 currentSubject.save(failOnError:true) 357 363 358 364 rootGroup.addToSubjects currentSubject 359 rootGroup.save( )365 rootGroup.save(failOnError:true) 360 366 361 367 def currentSample = new Sample( … … 365 371 parentSubject: currentSubject, 366 372 parentEvent : bloodSamplingEventBefore 367 ) ;373 ) 368 374 369 375 humanStudy.addToSamples(currentSample) 370 currentSample.with { if (!validate()) { errors.each { println it} } else save()} 371 currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L))376 currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L)) 377 currentSample.save(failOnError:true) 372 378 373 379 currentSample = new Sample( … … 377 383 parentSubject: currentSubject, 378 384 parentEvent : bloodSamplingEventAfter 379 ) ;385 ) 380 386 381 387 humanStudy.addToSamples(currentSample) 382 currentSample.with { if (!validate()) { errors.each { println it} } else save()} 383 currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L))384 388 currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L)) 389 currentSample.save(failOnError:true) 390 } 385 391 386 392 // Add persons to study 387 393 def studyperson3 = new StudyPerson(person: person1, role: role2) 388 humanStudy.addToPersons(studyperson3).addToPublications(publication2). with { if (!validate()) { errors.each { println it} } else save()}394 humanStudy.addToPersons(studyperson3).addToPublications(publication2).save(failOnError:true) 389 395 390 396 // Add SAM assay reference … … 393 399 platform: 'clinical measurements', 394 400 url: config.modules.sam.url.toString() 395 ). with { if (!validate()) { errors.each { println it} } else save()}401 ).save(failOnError:true) 396 402 397 403 // Add metabolomics assay reference … … 400 406 platform: 'GCMS/LCMS', 401 407 url: config.modules.metabolomics.url.toString() 402 ). with { if (!validate()) { errors.each { println it} } else save()}403 408 ).save(failOnError:true) 409 404 410 // Add metabolomics assay reference 405 411 def metagenomicsModule = new AssayModule( … … 407 413 platform: 'High throughput sequencing', 408 414 url: config.modules.metagenomics.url.toString() 409 ). with { if (!validate()) { errors.each { println it} } else save()}410 415 ).save(failOnError:true) 416 411 417 def lipidAssayRef = new Assay( 412 418 name: 'Lipid profiling', … … 430 436 mouseStudy.addToAssays(lipidAssayRef); 431 437 mouseStudy.addToAssays(metAssayRef); 432 mouseStudy.save( )438 mouseStudy.save(failOnError:true) 433 439 434 440 def glucoseAssayBRef = new Assay( … … 460 466 ).setFieldValue('Spectrometry technique', 'GC/MS') 461 467 462 468 463 469 // Add sequencing (metagenomics) assays 464 470 def sequencingAssay16SRef = new Assay( … … 468 474 externalAssayID: 'PPSH-SEQ-16S' 469 475 ) 470 476 471 477 // Add sequencing (metagenomics) assays 472 478 def sequencingAssay18SRef = new Assay( … … 476 482 externalAssayID: 'PPSH-SEQ-18S' 477 483 ) 478 484 479 485 humanStudy.samples*.each { 480 486 if (it.parentEvent.startTime == 0) { … … 489 495 } 490 496 } 491 497 492 498 humanStudy.addToAssays(sequencingAssay16SRef) 493 499 humanStudy.addToAssays(sequencingAssay18SRef) … … 496 502 humanStudy.addToAssays(metAssayRefA) 497 503 humanStudy.addToAssays(metAssayRefB) 498 humanStudy.save( )504 humanStudy.save(failOnError:true) 499 505 } 506 507 /** 508 * Add test studies. This function is meant to be called only in test mode 509 */ 510 static addTestStudies() { 511 512 final String testStudyName = "Test study" 513 final String testStudyTemplateName = "Academic study" 514 final String testStudyCode = "AAA-Test" 515 final String testStudyDescription = "Description of Test Study" 516 final Date testStudyStartDate = Date.parse('yyyy-MM-dd','2007-12-11') 517 518 def studyTemplate = Template.findByName(testStudyTemplateName) 519 assert studyTemplate 520 521 def study = new Study( 522 title: testStudyName, 523 template: studyTemplate, 524 startDate: testStudyStartDate, 525 code: testStudyCode, 526 description: testStudyDescription 527 ) 528 529 study.save(failOnError: true) 530 531 } 500 532 } 533 534 //package dbnp.configuration 535 // 536 ///** 537 // * @Author kees 538 // * @Since Jun 25, 2010 539 // * 540 // * Revision information: 541 // * $Rev$ 542 // * $Author$ 543 // * $Date$ 544 // */ 545 // 546 //import dbnp.studycapturing.* 547 //import org.dbnp.gdt.* 548 //import org.codehaus.groovy.grails.commons.GrailsApplication 549 //import grails.util.GrailsUtil 550 //import dbnp.rest.common.CommunicationManager 551 //import org.codehaus.groovy.grails.commons.* 552 // 553 // 554 //class ExampleStudies { 555 // 556 // /** 557 // * Add example studies. This function is meant to be called only in development mode 558 // */ 559 // public static void addExampleStudies(dbnp.authentication.SecUser owner, dbnp.authentication.SecUser otherUser) { 560 // "inserting initial studies".grom() 561 // 562 // // get configuration 563 // def config = ConfigurationHolder.config 564 // 565 // // Look up the used ontologies which should be in the database by now 566 // def speciesOntology = Ontology.getOrCreateOntologyByNcboId(1132) 567 // def brendaOntology = Ontology.getOrCreateOntologyByNcboId(1005) 568 // def nciOntology = Ontology.getOrCreateOntologyByNcboId(1032) 569 // def chebiOntology = Ontology.getOrCreateOntologyByNcboId(1007) 570 // 571 // // Look up the used templates which should also be in the database by now 572 // def studyTemplate = Template.findByName("Academic study") 573 // def mouseTemplate = Template.findByName("Mouse") 574 // def humanTemplate = Template.findByName("Human") 575 // def dietTreatmentTemplate = Template.findByName("Diet treatment") 576 // def boostTreatmentTemplate = Template.findByName("Compound challenge") 577 // def liverSamplingEventTemplate = Template.findByName("Liver extraction") 578 // def fastingTreatmentTemplate = Template.findByName("Fasting treatment") 579 // def bloodSamplingEventTemplate = Template.findByName("Blood extraction") 580 // def humanTissueSampleTemplate = Template.findByName("Human tissue sample") 581 // def humanBloodSampleTemplate = Template.findByName("Human blood sample") 582 // def ccAssayTemplate = Template.findByName("Clinical chemistry assay") 583 // def metAssayTemplate = Template.findByName("Metabolomics assay") 584 // 585 // // Add terms manually, to avoid having to do many HTTP requests to the BioPortal website 586 // def mouseTerm = new Term( 587 // name : 'Mus musculus', 588 // ontology : speciesOntology, 589 // accession : '10090' 590 // ).with { if (!validate()) { errors.each { println it} } else save()} 591 // 592 // def humanTerm = new Term( 593 // name : 'Homo sapiens', 594 // ontology : speciesOntology, 595 // accession : '9606' 596 // ).with { if (!validate()) { errors.each { println it} } else save()} 597 // 598 // def arabTerm = new Term( 599 // name : 'Arabidopsis thaliana', 600 // ontology : speciesOntology, 601 // accession : '3702' 602 // ).with { if (!validate()) { errors.each { println it} } else save()} 603 // 604 // def tomatoTerm = new Term( 605 // name : 'Solanum lycopersicum', 606 // ontology : speciesOntology, 607 // accession : '4081' 608 // ).with { if (!validate()) { errors.each { println it} } else save()} 609 // 610 // def potatoTerm = new Term( 611 // name : 'Solanum tuberosum', 612 // ontology : speciesOntology, 613 // accession : '0000' 614 // ).with { if (!validate()) { errors.each { println it} } else save()} 615 // 616 // def bloodTerm = new Term( 617 // name : 'blood plasma', 618 // ontology : brendaOntology, 619 // accession : 'BTO:0000131' 620 // ).with { if (!validate()) { errors.each { println it} } else save()} 621 // 622 // def c57bl6Term = new Term( 623 // name : 'C57BL/6 Mouse', 624 // ontology : nciOntology, 625 // accession : 'C14424' 626 // ).with { if (!validate()) { errors.each { println it} } else save()} 627 // 628 // def glucoseTerm = new Term( 629 // name : 'glucose', 630 // ontology : chebiOntology, 631 // accession : 'CHEBI:17234' 632 // ).with { if (!validate()) { errors.each { println it} } else save()} 633 // 634 // // Create a few persons, roles and Affiliations 635 // def affiliation1 = new PersonAffiliation( 636 // institute : "Science Institute NYC", 637 // department : "Department of Mathematics" 638 // ).save(); 639 // def affiliation2 = new PersonAffiliation( 640 // institute : "InfoStats GmbH, Hamburg", 641 // department : "Life Sciences" 642 // ).save(); 643 // def role1 = new PersonRole( 644 // name : "Principal Investigator" 645 // ).save(); 646 // def role2 = new PersonRole( 647 // name : "Statician" 648 // ).save(); 649 // 650 // // Create persons 651 // def person1 = new Person( 652 // lastName : "Scientist", 653 // firstName : "John", 654 // gender : "Male", 655 // initials : "J.R.", 656 // email : "john@scienceinstitute.com", 657 // phone : "1-555-3049", 658 // address : "First street 2,NYC" 659 // ).addToAffiliations(affiliation1).addToAffiliations(affiliation2).save(); 660 // 661 // def person2 = new Person( 662 // lastName : "Statician", 663 // firstName : "Jane", 664 // gender : "Female", 665 // initials : "W.J.", 666 // email : "jane@statisticalcompany.de", 667 // phone : "49-555-8291", 668 // address : "Dritten strasse 38, Hamburg, Germany" 669 // ).addToAffiliations(affiliation2).save(); 670 // 671 // // Create 30 persons to test pagination 672 // def personCounter = 1; 673 // 30.times { 674 // new Person( 675 // firstName : "Person #${personCounter}", 676 // lastName : "Testperson", 677 // email : "email${personCounter++}@testdomain.com" 678 // ).save() 679 // } 680 // 681 // // Create a few publications 682 // def publication1 = new Publication( 683 // title : "Postnatal development of hypothalamic leptin receptors", 684 // authorsList : "Cottrell EC, Mercer JG, Ozanne SE.", 685 // pubMedID : "20472140", 686 // comments : "Not published yet", 687 // DOI : "unknown" 688 // ).save(); 689 // 690 // def publication2 = new Publication( 691 // title : "Induction of regulatory T cells decreases adipose inflammation and alleviates insulin resistance in ob/ob mice", 692 // authorsList : "Ilan Y, Maron R, Tukpah AM, Maioli TU, Murugaiyan G, Yang K, Wu HY, Weiner HL.", 693 // pubMedID : "20445103", 694 // comments : "", 695 // DOI : "" 696 // ).save(); 697 // 698 // // Add example mouse study 699 // def mouseStudy = new Study( 700 // template : studyTemplate, 701 // title : "NuGO PPS3 mouse study leptin module", 702 // 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.", 703 // code : "PPS3_leptin_module", 704 // researchQuestion: "Leptin etc.", 705 // ecCode : "2007117.c", 706 // startDate : Date.parse('yyyy-MM-dd', '2008-01-02'), 707 // owner : owner, 708 // readers : [otherUser] 709 // ).with { if (!validate()) { errors.each { println it} } else save()} 710 // 711 // def evLF = new Event( 712 // startTime : 3600, 713 // endTime : 3600 + 7 * 24 * 3600, 714 // template : dietTreatmentTemplate 715 // ).setFieldValue('Diet', 'low fat') 716 // 717 // def evHF = new Event( 718 // startTime : 3600, 719 // endTime : 3600 + 7 * 24 * 3600, 720 // template : dietTreatmentTemplate 721 // ).setFieldValue('Diet', 'high fat') 722 // 723 // def evBV = new Event( 724 // startTime : 3600, 725 // endTime : 3600 + 7 * 24 * 3600, 726 // template : boostTreatmentTemplate 727 // ).setFieldValue('Control', 'true') 728 // 729 // def evBL = new Event( 730 // startTime : 3600, 731 // endTime : 3600 + 7 * 24 * 3600, 732 // template : boostTreatmentTemplate 733 // ).setFieldValue('Control', 'false') 734 // 735 // def evLF4 = new Event( 736 // startTime : 3600, 737 // endTime : 3600 + 4 * 7 * 24 * 3600, 738 // template : dietTreatmentTemplate 739 // ).setFieldValue('Diet', 'low fat') 740 // 741 // def evHF4 = new Event( 742 // startTime : 3600, 743 // endTime : 3600 + 4 * 7 * 24 * 3600, 744 // template : dietTreatmentTemplate 745 // ).setFieldValue('Diet', 'high fat') 746 // 747 // def evBV4 = new Event( 748 // startTime : 3600, 749 // endTime : 3600 + 4 * 7 * 24 * 3600, 750 // template : boostTreatmentTemplate 751 // ).setFieldValue('Control', 'true') 752 // 753 // def evBL4 = new Event( 754 // startTime : 3600, 755 // endTime : 3600 + 4 * 7 * 24 * 3600, 756 // template : boostTreatmentTemplate 757 // ).setFieldValue('Control', 'false') 758 // 759 // def evS = new SamplingEvent( 760 // startTime : 3600 + 7 * 24 * 3600, 761 // template : liverSamplingEventTemplate, 762 // sampleTemplate: humanTissueSampleTemplate).setFieldValue('Sample weight', 5F) 763 // 764 // def evS4 = new SamplingEvent( 765 // startTime : 3600 + 7 * 24 * 3600, 766 // template : liverSamplingEventTemplate, 767 // sampleTemplate: humanTissueSampleTemplate).setFieldValue('Sample weight', 5F) 768 // 769 // // Add events to study 770 // mouseStudy.addToEvents(evLF).addToEvents(evHF).addToEvents(evBV).addToEvents(evBL).addToEvents(evLF4).addToEvents(evHF4).addToEvents(evBV4).addToEvents(evBL4).addToSamplingEvents(evS).addToSamplingEvents(evS4).with { if (!validate()) { errors.each { println it} } else save()} 771 // 772 // // Extra check if the SamplingEvents are saved correctly 773 // evS.with { if (!validate()) { errors.each { println it} } else save()} 774 // evS4.with { if (!validate()) { errors.each { println it} } else save()} 775 // 776 // def LFBV1 = new EventGroup(name: "10% fat + vehicle for 1 week").addToEvents(evLF).addToEvents(evBV).addToSamplingEvents(evS) 777 // 778 // def LFBL1 = new EventGroup(name: "10% fat + leptin for 1 week").addToEvents(evLF).addToEvents(evBL).addToSamplingEvents(evS) 779 // 780 // def HFBV1 = new EventGroup(name: "45% fat + vehicle for 1 week").addToEvents(evHF).addToEvents(evBV).addToSamplingEvents(evS) 781 // 782 // def HFBL1 = new EventGroup(name: "45% fat + leptin for 1 week").addToEvents(evHF).addToEvents(evBL).addToSamplingEvents(evS) 783 // 784 // def LFBV4 = new EventGroup(name: "10% fat + vehicle for 4 weeks").addToEvents(evLF4).addToEvents(evBV4).addToSamplingEvents(evS4) 785 // 786 // def LFBL4 = new EventGroup(name: "10% fat + leptin for 4 weeks").addToEvents(evLF4).addToEvents(evBL4).addToSamplingEvents(evS4) 787 // 788 // def HFBV4 = new EventGroup(name: "45% fat + vehicle for 4 weeks").addToEvents(evHF4).addToEvents(evBV4).addToSamplingEvents(evS4) 789 // 790 // def HFBL4 = new EventGroup(name: "45% fat + leptin for 4 weeks").addToEvents(evHF4).addToEvents(evBL4).addToSamplingEvents(evS4) 791 // 792 // // Add subjects and samples and compose EventGroups 793 // def x = 1 794 // 80.times { 795 // def currentSubject = new Subject( 796 // name: "A" + x++, 797 // species: mouseTerm, 798 // template: mouseTemplate, 799 // ).setFieldValue("Gender", "Male").setFieldValue("Genotype", c57bl6Term).setFieldValue("Age", 17).setFieldValue("Cage", "" + (int) (x / 2)) 800 // 801 // // We have to save the subject first, otherwise the parentEvent property of the sample cannot be set 802 // // (this is possibly a Grails or Hibernate bug) 803 // mouseStudy.addToSubjects(currentSubject) 804 // currentSubject.with { if (!validate()) { errors.each { println it} } else save()} 805 // 806 // // Add subject to appropriate EventGroup 807 // if (x > 70) { HFBL4.addToSubjects(currentSubject).save() } 808 // else if (x > 60) { HFBV4.addToSubjects(currentSubject).save() } 809 // else if (x > 50) { LFBL4.addToSubjects(currentSubject).save() } 810 // else if (x > 40) { LFBV4.addToSubjects(currentSubject).save() } 811 // else if (x > 30) { HFBL1.addToSubjects(currentSubject).save() } 812 // else if (x > 20) { HFBV1.addToSubjects(currentSubject).save() } 813 // else if (x > 10) { LFBL1.addToSubjects(currentSubject).save() } 814 // else { LFBV1.addToSubjects(currentSubject).save() } 815 // 816 // // Create sample 817 // def currentSample = new Sample( 818 // name: currentSubject.name + '_B', 819 // material: bloodTerm, 820 // template: humanBloodSampleTemplate, 821 // parentSubject: currentSubject, 822 // parentEvent: evS //x > 40 ? evS4 : evS 823 // ); 824 // mouseStudy.addToSamples(currentSample) 825 // currentSample.with { if (!validate()) { errors.each { println it} } else save()} 826 // currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L)) 827 // } 828 // 829 // // Add EventGroups to study 830 // mouseStudy.addToEventGroups(LFBV1).addToEventGroups(LFBL1).addToEventGroups(HFBV1).addToEventGroups(HFBL1).addToEventGroups(LFBV4).addToEventGroups(LFBL4).addToEventGroups(HFBV4).addToEventGroups(HFBL4).with { if (!validate()) { errors.each { println it} } else save()} 831 // 832 // // Add persons and publications to study 833 // def studyperson1 = new StudyPerson(person: person1, role: role1) 834 // def studyperson2 = new StudyPerson(person: person2, role: role2) 835 // 836 // mouseStudy.addToPersons(studyperson1).addToPersons(studyperson2).addToPublications(publication1).addToPublications(publication2).with { if (!validate()) { errors.each { println it} } else save()} 837 // 838 // def humanStudy = new Study( 839 // template : studyTemplate, 840 // title : "NuGO PPS human study", 841 // code : "PPSH", 842 // researchQuestion: "How much are fasting plasma and urine metabolite levels affected by prolonged fasting ?", 843 // description : "Human study performed at RRI; centres involved: RRI, IFR, TUM, Maastricht U.", 844 // ecCode : "unknown", 845 // startDate : Date.parse('yyyy-MM-dd', '2008-01-14'), 846 // owner : owner, 847 // writers : [otherUser] 848 // ).with { if (!validate()) { errors.each { println it} } else save()} 849 // 850 // def rootGroup = new EventGroup(name: 'Root group'); 851 // 852 // def fastingEvent = new Event( 853 // startTime : 3 * 24 * 3600 + 22 * 3600, 854 // endTime : 3 * 24 * 3600 + 30 * 3600, 855 // template : fastingTreatmentTemplate).setFieldValue('Fasting period', '8h'); 856 // 857 // def bloodSamplingEventBefore = new SamplingEvent( 858 // startTime : 0, 859 // template : bloodSamplingEventTemplate, 860 // sampleTemplate : humanBloodSampleTemplate).setFieldValue('Sample volume', 4.5F); 861 // 862 // def bloodSamplingEventAfter = new SamplingEvent( 863 // startTime : 3 * 24 * 3600 + 30 * 3600, 864 // template : bloodSamplingEventTemplate, 865 // sampleTemplate : humanBloodSampleTemplate).setFieldValue('Sample volume', 4.5F); 866 // 867 // rootGroup.addToEvents fastingEvent 868 // rootGroup.addToSamplingEvents bloodSamplingEventBefore 869 // rootGroup.addToSamplingEvents bloodSamplingEventAfter 870 // rootGroup.save() 871 // 872 // humanStudy.addToEvents(fastingEvent) 873 // humanStudy.addToSamplingEvents(bloodSamplingEventBefore) 874 // humanStudy.addToSamplingEvents(bloodSamplingEventAfter) 875 // humanStudy.addToEventGroups rootGroup 876 // 877 // humanStudy.save() 878 // 879 // def y = 1 880 // 11.times { 881 // def currentSubject = new Subject( 882 // name : "" + y++, 883 // species : humanTerm, 884 // template : humanTemplate 885 // ).setFieldValue("Gender", (Math.random() > 0.5) ? "Male" : "Female") 886 // //.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) 887 // 888 // humanStudy.addToSubjects(currentSubject) 889 // currentSubject.with { if (!validate()) { errors.each { println it} } else save()} 890 // 891 // rootGroup.addToSubjects currentSubject 892 // rootGroup.save() 893 // 894 // def currentSample = new Sample( 895 // name : currentSubject.name + '_B', 896 // material : bloodTerm, 897 // template : humanBloodSampleTemplate, 898 // parentSubject: currentSubject, 899 // parentEvent : bloodSamplingEventBefore 900 // ); 901 // 902 // humanStudy.addToSamples(currentSample) 903 // currentSample.with { if (!validate()) { errors.each { println it} } else save()} 904 // currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L)) 905 // 906 // currentSample = new Sample( 907 // name : currentSubject.name + '_A', 908 // material : bloodTerm, 909 // template : humanBloodSampleTemplate, 910 // parentSubject: currentSubject, 911 // parentEvent : bloodSamplingEventAfter 912 // ); 913 // 914 // humanStudy.addToSamples(currentSample) 915 // currentSample.with { if (!validate()) { errors.each { println it} } else save()} 916 // currentSample.setFieldValue("Text on vial", "T" + (Math.random() * 100L)) 917 // } 918 // 919 // // Add persons to study 920 // def studyperson3 = new StudyPerson(person: person1, role: role2) 921 // humanStudy.addToPersons(studyperson3).addToPublications(publication2).with { if (!validate()) { errors.each { println it} } else save()} 922 // 923 // // Add SAM assay reference 924 // def clinicalModule = new AssayModule( 925 // name: 'SAM module for clinical data', 926 // platform: 'clinical measurements', 927 // url: config.modules.sam.url.toString() 928 // ).with { if (!validate()) { errors.each { println it} } else save()} 929 // 930 // // Add metabolomics assay reference 931 // def metabolomicsModule = new AssayModule( 932 // name: 'Metabolomics module', 933 // platform: 'GCMS/LCMS', 934 // url: config.modules.metabolomics.url.toString() 935 // ).with { if (!validate()) { errors.each { println it} } else save()} 936 // 937 // // Add metabolomics assay reference 938 // def metagenomicsModule = new AssayModule( 939 // name: 'Metagenomics module', 940 // platform: 'High throughput sequencing', 941 // url: config.modules.metagenomics.url.toString() 942 // ).with { if (!validate()) { errors.each { println it} } else save()} 943 // 944 // def lipidAssayRef = new Assay( 945 // name: 'Lipid profiling', 946 // template: ccAssayTemplate, 947 // module: clinicalModule, 948 // externalAssayID: 'PPS3_SAM' 949 // ) 950 // 951 // def metAssayRef = new Assay( 952 // name: 'Lipidomics profile', 953 // template: metAssayTemplate, 954 // module: metabolomicsModule, 955 // externalAssayID: 'PPS3_Lipidomics' 956 // ).setFieldValue('Spectrometry technique', 'LC/MS') 957 // 958 // mouseStudy.samples*.each { 959 // lipidAssayRef.addToSamples(it) 960 // metAssayRef.addToSamples(it) 961 // } 962 // 963 // mouseStudy.addToAssays(lipidAssayRef); 964 // mouseStudy.addToAssays(metAssayRef); 965 // mouseStudy.save() 966 // 967 // def glucoseAssayBRef = new Assay( 968 // name : 'Glucose assay before', 969 // template : ccAssayTemplate, 970 // module : clinicalModule, 971 // externalAssayID: 'PPSH-Glu-B' 972 // ) 973 // 974 // def glucoseAssayARef = new Assay( 975 // name : 'Glucose assay after', 976 // template : ccAssayTemplate, 977 // module : clinicalModule, 978 // externalAssayID: 'PPSH-Glu-A' 979 // ) 980 // 981 // def metAssayRefB = new Assay( 982 // name : 'Lipidomics profile before', 983 // template : metAssayTemplate, 984 // module : metabolomicsModule, 985 // externalAssayID: 'PPSH_Lipidomics_start' 986 // ).setFieldValue('Spectrometry technique', 'GC/MS') 987 // 988 // def metAssayRefA = new Assay( 989 // name : 'Lipidomics profile after', 990 // template : metAssayTemplate, 991 // module : metabolomicsModule, 992 // externalAssayID: 'PPSH_Lipidomics_end' 993 // ).setFieldValue('Spectrometry technique', 'GC/MS') 994 // 995 // 996 // // Add sequencing (metagenomics) assays 997 // def sequencingAssay16SRef = new Assay( 998 // name : '16S Sequencing assay', 999 // template : ccAssayTemplate, 1000 // module : metagenomicsModule, 1001 // externalAssayID: 'PPSH-SEQ-16S' 1002 // ) 1003 // 1004 // // Add sequencing (metagenomics) assays 1005 // def sequencingAssay18SRef = new Assay( 1006 // name : '18S Sequencing assay', 1007 // template : ccAssayTemplate, 1008 // module : metagenomicsModule, 1009 // externalAssayID: 'PPSH-SEQ-18S' 1010 // ) 1011 // 1012 // humanStudy.samples*.each { 1013 // if (it.parentEvent.startTime == 0) { 1014 // glucoseAssayBRef.addToSamples(it) 1015 // metAssayRefB.addToSamples(it) 1016 // } 1017 // else { 1018 // glucoseAssayARef.addToSamples(it) 1019 // metAssayRefA.addToSamples(it) 1020 // sequencingAssay16SRef.addToSamples(it) 1021 // sequencingAssay18SRef.addToSamples(it) 1022 // } 1023 // } 1024 // 1025 // humanStudy.addToAssays(sequencingAssay16SRef) 1026 // humanStudy.addToAssays(sequencingAssay18SRef) 1027 // humanStudy.addToAssays(glucoseAssayARef) 1028 // humanStudy.addToAssays(glucoseAssayBRef) 1029 // humanStudy.addToAssays(metAssayRefA) 1030 // humanStudy.addToAssays(metAssayRefB) 1031 // humanStudy.save() 1032 // } 1033 //}
Note: See TracChangeset
for help on using the changeset viewer.